use of org.kie.workbench.common.services.datamodeller.driver.model.AnnotationParseResponse in project kie-wb-common by kiegroup.
the class AdvancedAnnotationListEditorTest method testOnEditGenericValuePair.
@Test
public void testOnEditGenericValuePair() {
prepareValuePairEdition();
// it's the generic value case
when(valuePairEditor.isGenericEditor()).thenReturn(true);
when(valuePairEditor.getValuePairDefinition()).thenReturn(currentValuePairDefinition);
// emulates that currentAnnotation an currentValuePair where selected for edition in the UI
annotationListEditor.onEditValuePair(currentAnnotation, currentValuePairName);
verifyValuePairEditorCreatedAndShown();
// the value for the valuePairEditor should have been properly set with the current value pair source for
// the generic case.
verify(valuePairEditor, times(1)).setValue(currentValuePairSource);
// setup the returned value.
// generic case requires a parse response, and the newValuePairValue comes from server.
newValuePairValue = mock(Object.class);
AnnotationParseResponse parseResponse = mock(AnnotationParseResponse.class);
Annotation parsedAnnotation = mock(Annotation.class);
when(parseResponse.getAnnotation()).thenReturn(parsedAnnotation);
when(parsedAnnotation.getValue(currentValuePairName)).thenReturn(newValuePairValue);
when(parseResponse.hasErrors()).thenReturn(false);
when(dataModelerService.resolveParseRequest(any(AnnotationParseRequest.class), eq(kieModule))).thenReturn(parseResponse);
// emulate the user pressing the ok button on the valuePairEditor
prepareValuePairEditorSubmit();
when(valuePairEditor.isValid()).thenReturn(true);
annotationListEditor.doValuePairChange(valuePairEditor, valuePairEditor.getValue());
verify(valuePairChangeHandler, times(1)).onValuePairChange(currentAnnotationClassName, currentValuePairName, newValuePairValue);
verifyValuePairEditorDestroyedAndHidden();
}
use of org.kie.workbench.common.services.datamodeller.driver.model.AnnotationParseResponse in project kie-wb-common by kiegroup.
the class DataModelerServiceImpl method resolveParseRequest.
@Override
public AnnotationParseResponse resolveParseRequest(AnnotationParseRequest parseRequest, KieModule kieModule) {
JavaRoasterModelDriver modelDriver = new JavaRoasterModelDriver();
Pair<Annotation, List<DriverError>> driverResult = modelDriver.parseAnnotationWithValuePair(parseRequest.getAnnotationClassName(), parseRequest.getTarget(), parseRequest.getValuePairName(), parseRequest.getValuePairLiteralValue(), classLoaderHelper.getModuleClassLoader(kieModule));
AnnotationParseResponse response = new AnnotationParseResponse(driverResult.getK1());
response.withErrors(driverResult.getK2());
return response;
}
Aggregations