use of org.kie.workbench.common.stunner.core.marshaller.MarshallingResponse in project kie-wb-common by kiegroup.
the class DiagramMarshallerTest method unmarshallWithValidationError.
@Test
public void unmarshallWithValidationError() throws Exception {
tested = spy(new DiagramMarshaller() {
@Override
public Graph unmarshall(Metadata metadata, InputStream input) {
throw new RuntimeException(MESSAGE);
}
@Override
public String marshall(Diagram diagram) {
return null;
}
@Override
public DiagramMetadataMarshaller getMetadataMarshaller() {
return null;
}
});
final MarshallingResponse response = tested.unmarshallWithValidation(request);
verify(tested).unmarshall(metadata, input);
assertNull(response.getResult());
assertEquals(response.getState(), MarshallingResponse.State.ERROR);
assertEquals(response.getMessages().size(), 1);
final MarshallingMessage marshallingMessage = (MarshallingMessage) response.getMessages().stream().findFirst().get();
assertEquals(marshallingMessage.getMessage(), MESSAGE);
}
use of org.kie.workbench.common.stunner.core.marshaller.MarshallingResponse in project kie-wb-common by kiegroup.
the class IntegrationHandlerImpl method fromJBPMDesignerToStunner.
private void fromJBPMDesignerToStunner(Path path, PlaceRequest place) {
final RemoteCallback<MarshallingResponse<ProjectDiagram>> successCallback = (result) -> onGetDiagramByPathSuccess(result, path, place);
final ErrorCallback<Message> errorCallback = (message, throwable) -> onUnexpectedError(throwable);
final Command okCommand = () -> integrationService.call(successCallback, errorCallback).getDiagramByPath(path, MarshallingRequest.Mode.AUTO);
confirmAndMigrate(null, null, translationService.getValue(IntegrationClientConstants.MigrateToStunnerConfirmAction), okCommand);
}
use of org.kie.workbench.common.stunner.core.marshaller.MarshallingResponse in project kie-wb-common by kiegroup.
the class IntegrationServiceImplTest method mockResponse.
private static MarshallingResponse mockResponse(MarshallingResponse.State state, List<MarshallingMessage> messages, Graph result) {
MarshallingResponse response = mock(MarshallingResponse.class);
when(response.getState()).thenReturn(state);
when(response.getMessages()).thenReturn(messages);
when(response.getResult()).thenReturn(result);
return response;
}
use of org.kie.workbench.common.stunner.core.marshaller.MarshallingResponse in project kie-wb-common by kiegroup.
the class IntegrationServiceImplTest method testGetDiagramByPathSuccessful.
@Test
@SuppressWarnings("unchecked")
public void testGetDiagramByPathSuccessful() {
Graph<DefinitionSet, ?> graph = mock(Graph.class);
DefinitionSet definitionSet = mock(DefinitionSet.class);
String definitionValue = "theDefinitionValue";
when(graph.getContent()).thenReturn(definitionSet);
when(definitionSet.getDefinition()).thenReturn(definitionValue);
when(factoryRegistry.getDiagramFactory(definitionValue, ProjectMetadata.class)).thenReturn(diagramFactory);
ProjectDiagram diagram = mock(ProjectDiagram.class);
when(diagramFactory.build(eq(NAME), any(ProjectMetadata.class), eq(graph))).thenReturn(diagram);
List<MarshallingMessage> messages = new ArrayList<>();
MarshallingResponse response = mockResponse(MarshallingResponse.State.SUCCESS, messages, graph);
MarshallingResponse result = prepareTestGetDiagramByPath(response, null);
assertEquals(MarshallingResponse.State.SUCCESS, result.getState());
assertEquals(messages, result.getMessages());
assertNotNull(result.getResult());
assertEquals(diagram, result.getResult());
}
use of org.kie.workbench.common.stunner.core.marshaller.MarshallingResponse in project kie-wb-common by kiegroup.
the class DiagramMarshallerTest method unmarshallWithValidation.
@Test
public void unmarshallWithValidation() throws Exception {
tested = spy(new DiagramMarshaller() {
@Override
public Graph unmarshall(Metadata metadata, InputStream input) {
return graph;
}
@Override
public String marshall(Diagram diagram) {
return null;
}
@Override
public DiagramMetadataMarshaller getMetadataMarshaller() {
return null;
}
});
final MarshallingResponse response = tested.unmarshallWithValidation(request);
verify(tested).unmarshall(metadata, input);
assertEquals(response.getResult(), graph);
assertEquals(response.getState(), MarshallingResponse.State.SUCCESS);
}
Aggregations