Provide typed API for UI components with type parameter #1253

Fix tests
This commit is contained in:
Yuriy Artamonov 2018-09-11 20:56:34 +04:00
parent 07943c7d8a
commit b1fa7a4af4
2 changed files with 24 additions and 22 deletions

View File

@ -19,6 +19,7 @@ package com.haulmont.cuba.gui.components;
import com.haulmont.cuba.client.testsupport.CubaClientTestCase;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.View;
import com.haulmont.cuba.gui.components.factories.DefaultComponentGenerationStrategy;
import com.haulmont.cuba.gui.components.factories.FieldGroupFieldFactoryImpl;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.DsBuilder;
@ -26,8 +27,8 @@ import com.haulmont.cuba.gui.data.impl.DatasourceImpl;
import com.haulmont.cuba.gui.executors.BackgroundWorker;
import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
import com.haulmont.cuba.security.entity.User;
import mockit.Mocked;
import mockit.Expectations;
import mockit.Mocked;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.junit.Before;
import org.junit.Ignore;
@ -35,6 +36,8 @@ import org.junit.Test;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.*;
@ -50,15 +53,11 @@ public class FieldGroupTest extends CubaClientTestCase {
@SuppressWarnings("ReassignmentInjectVariable")
@Before
public void setUp() throws Exception {
public void setUp() {
addEntityPackage("com.haulmont.cuba");
setupInfrastructure();
fieldFactory = new TestFieldGroupFieldFactoryImpl() {
{
this.componentsFactory = FieldGroupTest.this.componentsFactory;
}
};
fieldFactory = new TestFieldGroupFieldFactoryImpl();
new Expectations() {
{
@ -76,8 +75,18 @@ public class FieldGroupTest extends CubaClientTestCase {
messages.init();
DefaultComponentGenerationStrategy strategy = new DefaultComponentGenerationStrategy(messages, null);
strategy.setComponentsFactory(FieldGroupTest.this.componentsFactory);
UiComponentsGenerator uiComponentsGenerator = new UiComponentsGenerator(){
@Override
protected List<ComponentGenerationStrategy> getComponentGenerationStrategies() {
return Collections.singletonList(strategy);
}
};
componentsFactory = createComponentsFactory();
fieldFactory.setComponentsFactory(componentsFactory);
fieldFactory.setUiComponentsGenerator(uiComponentsGenerator);
}
protected void initExpectations() {
@ -461,8 +470,8 @@ public class FieldGroupTest extends CubaClientTestCase {
}
protected static class TestFieldGroupFieldFactoryImpl extends FieldGroupFieldFactoryImpl {
public void setComponentsFactory(ComponentsFactory componentsFactory) {
this.componentsFactory = componentsFactory;
public void setUiComponentsGenerator(UiComponentsGenerator generator) {
this.uiComponentsGenerator = generator;
}
}
}

View File

@ -18,21 +18,18 @@ package com.haulmont.cuba.web.test.ui;
import com.google.common.collect.ImmutableMap;
import com.haulmont.cuba.core.sys.AppContext;
import com.haulmont.cuba.gui.components.ComponentGenerationStrategy;
import com.haulmont.cuba.gui.components.factories.DefaultComponentGenerationStrategy;
import com.haulmont.cuba.gui.components.FieldGroup;
import com.haulmont.cuba.gui.components.FieldGroupTest;
import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
import com.haulmont.cuba.web.gui.WebComponentsFactory;
import com.vaadin.v7.data.util.converter.DefaultConverterFactory;
import com.haulmont.cuba.web.gui.WebUiComponents;
import com.vaadin.server.VaadinSession;
import com.vaadin.ui.GridLayout;
import mockit.Mocked;
import com.vaadin.v7.data.util.converter.DefaultConverterFactory;
import mockit.Expectations;
import mockit.Mocked;
import org.junit.Ignore;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@Ignore
@ -60,12 +57,8 @@ public class WebFieldGroupTest extends FieldGroupTest {
@Override
protected ComponentsFactory createComponentsFactory() {
return new WebComponentsFactory() {
@Override
public List<ComponentGenerationStrategy> getComponentGenerationStrategies() {
// vaadin8 fix
DefaultComponentGenerationStrategy strategy = new DefaultComponentGenerationStrategy(messages, null);
strategy.setComponentsFactory(this);
return Collections.singletonList(strategy);
{
this.uiComponents = new WebUiComponents();
}
};
}