Search in sources :

Example 6 with ComponentObjectType

use of com.vaadin.generator.metadata.ComponentObjectType in project flow by vaadin.

the class ComponentGeneratorTest method classContainsObjectProperty_componentContainsValueProperty_generatedClassImplementsHasValue.

@Test
public void classContainsObjectProperty_componentContainsValueProperty_generatedClassImplementsHasValue() {
    ComponentObjectType objectType = new ComponentObjectType();
    ComponentPropertyData property = new ComponentPropertyData();
    property.setName("value");
    property.setObjectType(Collections.singletonList(objectType));
    componentMetadata.setProperties(Collections.singletonList(property));
    ComponentEventData event = new ComponentEventData();
    event.setName("value-changed");
    componentMetadata.setEvents(Collections.singletonList(event));
    String generatedClass = generator.generateClass(componentMetadata, "com.my.test", null);
    generatedClass = ComponentGeneratorTestUtils.removeIndentation(generatedClass);
    ComponentGeneratorTestUtils.assertClassImplementsInterface(generatedClass, "MyComponent", HasValue.class);
    Assert.assertThat(generatedClass, CoreMatchers.containsString("@Override public ValueProperty getValue() { JsonObject _obj = (JsonObject) getElement().getPropertyRaw("));
    Assert.assertThat(generatedClass, CoreMatchers.containsString("@Override public void setValue(ValueProperty property) { if (!Objects.equals(property, getValue()))"));
}
Also used : ComponentEventData(com.vaadin.generator.metadata.ComponentEventData) ComponentObjectType(com.vaadin.generator.metadata.ComponentObjectType) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ComponentPropertyData(com.vaadin.generator.metadata.ComponentPropertyData) Test(org.junit.Test)

Example 7 with ComponentObjectType

use of com.vaadin.generator.metadata.ComponentObjectType in project flow by vaadin.

the class NestedClassGeneratorTest method init.

@Before
public void init() {
    generator = new NestedClassGenerator();
    type = new ComponentObjectType();
}
Also used : ComponentObjectType(com.vaadin.generator.metadata.ComponentObjectType) Before(org.junit.Before)

Aggregations

ComponentObjectType (com.vaadin.generator.metadata.ComponentObjectType)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 Test (org.junit.Test)5 ComponentObjectTypeInnerType (com.vaadin.generator.metadata.ComponentObjectType.ComponentObjectTypeInnerType)4 ComponentEventData (com.vaadin.generator.metadata.ComponentEventData)2 ComponentFunctionData (com.vaadin.generator.metadata.ComponentFunctionData)2 ComponentFunctionParameterData (com.vaadin.generator.metadata.ComponentFunctionParameterData)2 ComponentPropertyData (com.vaadin.generator.metadata.ComponentPropertyData)2 ComponentBasicType (com.vaadin.generator.metadata.ComponentBasicType)1 ComponentPropertyBaseData (com.vaadin.generator.metadata.ComponentPropertyBaseData)1 ComponentType (com.vaadin.generator.metadata.ComponentType)1 JavaClassSource (org.jboss.forge.roaster.model.source.JavaClassSource)1 Before (org.junit.Before)1