Search in sources :

Example 6 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class BooleanValuePairEditorTest method testValueChange.

@Test
public void testValueChange() {
    BooleanValuePairEditor booleanEditor = new BooleanValuePairEditor(view);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("booleanParam1");
    booleanEditor.init(valuePairDefinition);
    when(view.getSelectedValue()).thenReturn("false");
    booleanEditor.onValueChange();
    assertTrue(booleanEditor.isValid());
    assertEquals(Boolean.FALSE, booleanEditor.getValue());
}
Also used : AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 7 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class MultipleBooleanValuePairEditorTest method testAddValuesChange.

@Test
public void testAddValuesChange() {
    booleanEditors.clear();
    MultipleBooleanValuePairEditor multiBooleanEditor = new MultipleBooleanValuePairEditorExtended(multipleEditorView);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("booleanArrayParam1");
    BooleanValuePairEditor addItemEditor = new BooleanValuePairEditor(singleEditorView);
    addItemEditor.init(valuePairDefinition);
    when(multipleEditorView.getAddItemEditor()).thenReturn((ValuePairEditor) addItemEditor);
    multiBooleanEditor.init(valuePairDefinition);
    List<Boolean> expectedValues = new ArrayList<Boolean>();
    expectedValues.add(Boolean.FALSE);
    expectedValues.add(Boolean.TRUE);
    expectedValues.add(Boolean.FALSE);
    // emulate the user adding values to the array.
    when(singleEditorView.getSelectedValue()).thenReturn("false");
    addItemEditor.onValueChange();
    multiBooleanEditor.onAddItem();
    when(singleEditorView.getSelectedValue()).thenReturn("true");
    addItemEditor.onValueChange();
    multiBooleanEditor.onAddItem();
    when(singleEditorView.getSelectedValue()).thenReturn("false");
    addItemEditor.onValueChange();
    multiBooleanEditor.onAddItem();
    when(multipleEditorView.getItemEditors()).thenReturn(booleanEditors);
    assertTrue(multiBooleanEditor.isValid());
    assertEquals(expectedValues, multiBooleanEditor.getValue());
}
Also used : ArrayList(java.util.ArrayList) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 8 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class EnumValuePairEditorTest method testValueChange.

@Test
public void testValueChange() {
    EnumValuePairEditor enumEditor = new EnumValuePairEditor(view);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("enumParam1");
    enumEditor.init(valuePairDefinition);
    when(view.getSelectedValue()).thenReturn(TestEnums.ENUM1.VALUE3.name());
    enumEditor.onValueChange();
    assertTrue(enumEditor.isValid());
    assertEquals(TestEnums.ENUM1.VALUE3.name(), enumEditor.getValue());
}
Also used : AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 9 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class EnumValuePairEditorTest method testEditorLoad.

@Test
public void testEditorLoad() {
    EnumValuePairEditor enumEditor = new EnumValuePairEditor(view);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("enumParam1");
    enumEditor.init(valuePairDefinition);
    verify(view, times(1)).initOptions(enumOptions);
    verify(view, times(1)).setValuePairLabel(valuePairDefinition.getName());
    verify(view, times(1)).showValuePairRequiredIndicator(false);
}
Also used : AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 10 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class MultipleEnumValuePairEditorTest method testAllValuesSelected.

@Test
public void testAllValuesSelected() {
    MultipleEnumValuePairEditor enumEditor = new MultipleEnumValuePairEditorExtended(view);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("enumArrayParam1");
    enumEditor.init(valuePairDefinition);
    // emulate the selection of values VALUE1 and VALUE2, and then the selection of the "{}" option.
    EnumValuePairOptionEditor optionEditor = optionEditors.get(TestEnums.ENUM1.VALUE1.name());
    when(optionEditorView.getValue()).thenReturn(true);
    optionEditor.onValueChange();
    optionEditor = optionEditors.get(TestEnums.ENUM1.VALUE2.name());
    when(optionEditorView.getValue()).thenReturn(true);
    optionEditor.onValueChange();
    optionEditor = optionEditors.get("{}");
    when(optionEditorView.getValue()).thenReturn(true);
    optionEditor.onValueChange();
    List<String> expectedValues = new ArrayList<String>();
    assertEquals(expectedValues, enumEditor.getValue());
}
Also used : ArrayList(java.util.ArrayList) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Aggregations

AnnotationValuePairDefinition (org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition)33 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)8 AnnotationDefinition (org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition)8 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)4 AnnotationImpl (org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl)4 AnnotationSource (org.jboss.forge.roaster.model.source.AnnotationSource)3 DataModelerService (org.kie.workbench.common.screens.datamodeller.service.DataModelerService)3 Annotation (org.kie.workbench.common.services.datamodeller.core.Annotation)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entity (javax.persistence.Entity)1 ValuePair (org.jboss.forge.roaster.model.ValuePair)1 AdvancedAnnotationListEditorView (org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.annotationlisteditor.AdvancedAnnotationListEditorView)1 GenerationTools (org.kie.workbench.common.services.datamodeller.codegen.GenerationTools)1 AnnotationDefinitionRequest (org.kie.workbench.common.services.datamodeller.driver.model.AnnotationDefinitionRequest)1 AnnotationDefinitionResponse (org.kie.workbench.common.services.datamodeller.driver.model.AnnotationDefinitionResponse)1 AnnotationDescr (org.kie.workbench.common.services.datamodeller.parser.descr.AnnotationDescr)1 ElementValueDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ElementValueDescr)1 ElementValuePairDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ElementValuePairDescr)1