Search in sources :

Example 1 with AnnotationParseResponse

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();
}
Also used : AnnotationParseRequest(org.kie.workbench.common.services.datamodeller.driver.model.AnnotationParseRequest) AnnotationParseResponse(org.kie.workbench.common.services.datamodeller.driver.model.AnnotationParseResponse) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) Test(org.junit.Test)

Example 2 with AnnotationParseResponse

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;
}
Also used : AnnotationParseResponse(org.kie.workbench.common.services.datamodeller.driver.model.AnnotationParseResponse) List(java.util.List) ArrayList(java.util.ArrayList) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation)

Aggregations

Annotation (org.kie.workbench.common.services.datamodeller.core.Annotation)2 AnnotationParseResponse (org.kie.workbench.common.services.datamodeller.driver.model.AnnotationParseResponse)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1 JavaRoasterModelDriver (org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver)1 AnnotationParseRequest (org.kie.workbench.common.services.datamodeller.driver.model.AnnotationParseRequest)1