Search in sources :

Example 11 with AnnotationValuePairDefinition

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

the class MultipleEnumValuePairEditorTest method testValueChanges.

@Test
public void testValueChanges() {
    MultipleEnumValuePairEditor enumEditor = new MultipleEnumValuePairEditorExtended(view);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("enumArrayParam1");
    enumEditor.init(valuePairDefinition);
    // emulate the selection of values VALUE1 and VALUE2
    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();
    List<String> expectedValues = new ArrayList<String>();
    expectedValues.add(TestEnums.ENUM1.VALUE1.name());
    expectedValues.add(TestEnums.ENUM2.VALUE2.name());
    assertEquals(expectedValues, enumEditor.getValue());
}
Also used : ArrayList(java.util.ArrayList) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 12 with AnnotationValuePairDefinition

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

the class CharacterValuePairEditorTest method testEditorLoad.

@Test
public void testEditorLoad() {
    CharacterValuePairEditor characterEditor = new CharacterValuePairEditor(view);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("charParam1");
    characterEditor.init(valuePairDefinition);
    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 13 with AnnotationValuePairDefinition

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

the class MultipleCharacterValuePairEditorTest method testAddValuesChange.

@Test
public void testAddValuesChange() {
    characterEditors.clear();
    MultipleCharacterValuePairEditor multiCharacterEditor = new MultipleCharacterValuePairEditorExtended(multipleEditorView);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("charArrayParam1");
    CharacterValuePairEditor addItemEditor = new CharacterValuePairEditor(singleEditorView);
    addItemEditor.init(valuePairDefinition);
    when(multipleEditorView.getAddItemEditor()).thenReturn((ValuePairEditor) addItemEditor);
    multiCharacterEditor.init(valuePairDefinition);
    List<String> expectedValues = new ArrayList<String>();
    expectedValues.add("A");
    expectedValues.add("B");
    expectedValues.add("C");
    // emulate the user adding values to the array.
    when(singleEditorView.getValue()).thenReturn("A");
    addItemEditor.onValueChange();
    multiCharacterEditor.onAddItem();
    when(singleEditorView.getValue()).thenReturn("B");
    addItemEditor.onValueChange();
    multiCharacterEditor.onAddItem();
    when(singleEditorView.getValue()).thenReturn("C");
    addItemEditor.onValueChange();
    multiCharacterEditor.onAddItem();
    when(multipleEditorView.getItemEditors()).thenReturn(characterEditors);
    assertTrue(multiCharacterEditor.isValid());
    assertEquals(expectedValues, multiCharacterEditor.getValue());
}
Also used : ArrayList(java.util.ArrayList) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 14 with AnnotationValuePairDefinition

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

the class MultipleCharacterValuePairEditorTest method testEditorLoad.

@Test
public void testEditorLoad() {
    characterEditors.clear();
    List<String> originalValues = new ArrayList<String>();
    originalValues.add("A");
    originalValues.add("B");
    originalValues.add("C");
    MultipleCharacterValuePairEditor multiCharacterEditor = new MultipleCharacterValuePairEditorExtended(multipleEditorView);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("charArrayParam1");
    multiCharacterEditor.init(valuePairDefinition);
    verify(multipleEditorView, times(1)).setValuePairLabel(valuePairDefinition.getName());
    verify(multipleEditorView, times(1)).showValuePairRequiredIndicator(false);
    multiCharacterEditor.setValue(originalValues);
    // three individual editors should have been created.
    assertEquals(3, characterEditors.size());
    // and populated with the corresponding value
    verify(singleEditorView, times(1)).setValue("A");
    verify(singleEditorView, times(1)).setValue("B");
    verify(singleEditorView, times(1)).setValue("C");
    assertTrue(multiCharacterEditor.isValid());
}
Also used : ArrayList(java.util.ArrayList) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 15 with AnnotationValuePairDefinition

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

the class MultipleStringValuePairEditorTest method testAddValuesChange.

@Test
public void testAddValuesChange() {
    stringEditors.clear();
    MultipleStringValuePairEditor multiStringEditor = new MultipleStringValuePairEditorExtended(multipleEditorView);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("stringParam1");
    StringValuePairEditor addItemEditor = new StringValuePairEditor(singleEditorView);
    addItemEditor.init(valuePairDefinition);
    when(multipleEditorView.getAddItemEditor()).thenReturn((ValuePairEditor) addItemEditor);
    multiStringEditor.init(valuePairDefinition);
    List<String> expectedValues = new ArrayList<String>();
    expectedValues.add("AAA");
    expectedValues.add("BBB");
    expectedValues.add("CCC");
    // emulate the user adding values to the array.
    when(singleEditorView.getValue()).thenReturn("AAA");
    addItemEditor.onValueChange();
    multiStringEditor.onAddItem();
    when(singleEditorView.getValue()).thenReturn("BBB");
    addItemEditor.onValueChange();
    multiStringEditor.onAddItem();
    when(singleEditorView.getValue()).thenReturn("CCC");
    addItemEditor.onValueChange();
    multiStringEditor.onAddItem();
    when(multipleEditorView.getItemEditors()).thenReturn(stringEditors);
    assertTrue(multiStringEditor.isValid());
    assertEquals(expectedValues, multiStringEditor.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