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());
}
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);
}
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());
}
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());
}
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());
}
Aggregations