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