use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriver method addAnnotationMemberValue.
private void addAnnotationMemberValue(AnnotationSource annotationSource, AnnotationValuePairDefinition valuePairDefinition, Annotation annotation) {
AnnotationSource targetAnnotation = annotationSource.addAnnotationValue(valuePairDefinition.getName());
targetAnnotation.setName(annotation.getClassName());
if (!annotation.getAnnotationDefinition().isMarker()) {
for (AnnotationValuePairDefinition memberDefinition : annotation.getAnnotationDefinition().getValuePairs()) {
Object value = annotation.getValue(memberDefinition.getName());
if (value != null) {
addMemberValue(targetAnnotation, memberDefinition, value);
}
}
}
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriver method addAnnotation.
public AnnotationSource<?> addAnnotation(AnnotationTargetSource annotationTargetSource, Annotation annotation) {
AnnotationSource<?> newAnnotationSource = annotationTargetSource.addAnnotation();
newAnnotationSource.setName(annotation.getClassName());
AnnotationDefinition annotationDefinition = annotation.getAnnotationDefinition();
if (!annotationDefinition.isMarker()) {
for (AnnotationValuePairDefinition memberDefinition : annotationDefinition.getValuePairs()) {
Object value = annotation.getValue(memberDefinition.getName());
if (value != null) {
addMemberValue(newAnnotationSource, memberDefinition, value);
}
}
}
return newAnnotationSource;
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.
the class ValuePairEditorPageTest method testPageInitialization.
@Test
public void testPageInitialization() {
modelerServiceCaller = new CallerMock<DataModelerService>(modelerService);
ValuePairEditorPage editorPage = new ValuePairEditorPage(view, valuePairEditorProvider, modelerServiceCaller, wizardPageStatusChangeEvent);
editorPage.prepareView();
AnnotationDefinition annotationDefinition = DriverUtils.buildAnnotationDefinition(Entity.class);
AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("name");
when(valuePairEditorProvider.getValuePairEditor(valuePairDefinition)).thenReturn(valuePairEditor);
editorPage.init(annotationDefinition, valuePairDefinition, ElementType.FIELD, kieModule);
// the view should be properly initialized with the corresponding editor.
verify(view, times(1)).setValuePairEditor(valuePairEditor);
// the "name" value pair is not mandatory, so the page is completed.
WizardTestUtil.assertPageComplete(true, editorPage);
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.
the class MultipleBooleanValuePairEditorTest method testEditorLoad.
@Test
public void testEditorLoad() {
booleanEditors.clear();
List<Boolean> originalValues = new ArrayList<Boolean>();
originalValues.add(Boolean.FALSE);
originalValues.add(Boolean.FALSE);
originalValues.add(Boolean.TRUE);
originalValues.add(Boolean.TRUE);
MultipleBooleanValuePairEditor multiBooleanEditor = new MultipleBooleanValuePairEditorExtended(multipleEditorView);
AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("booleanArrayParam1");
multiBooleanEditor.init(valuePairDefinition);
verify(multipleEditorView, times(1)).setValuePairLabel(valuePairDefinition.getName());
verify(multipleEditorView, times(1)).showValuePairRequiredIndicator(false);
when(multipleEditorView.getItemEditors()).thenReturn(booleanEditors);
multiBooleanEditor.setValue(originalValues);
// four individual editors should have been created.
assertEquals(4, booleanEditors.size());
// and populated with the corresponding value
verify(singleEditorView, times(2)).setSelectedValue("true");
verify(singleEditorView, times(2)).setSelectedValue("false");
assertTrue(multiBooleanEditor.isValid());
assertEquals(originalValues, multiBooleanEditor.getValue());
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.
the class MultipleEnumValuePairEditorTest method testEditorLoad.
@Test
public void testEditorLoad() {
MultipleEnumValuePairEditor enumEditor = new MultipleEnumValuePairEditorExtended(view);
AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("enumArrayParam1");
enumEditor.init(valuePairDefinition);
verify(view, times(1)).setValuePairLabel(valuePairDefinition.getName());
verify(view, times(1)).showValuePairRequiredIndicator(false);
verify(view, times(1)).addOptionEditor(optionEditors.get(TestEnums.ENUM1.VALUE1.name()));
verify(view, times(1)).addOptionEditor(optionEditors.get(TestEnums.ENUM1.VALUE2.name()));
verify(view, times(1)).addOptionEditor(optionEditors.get(TestEnums.ENUM1.VALUE3.name()));
verify(view, times(1)).addOptionEditor(optionEditors.get("{}"));
}
Aggregations