@Test public void testSaveOrUpdate() { final Path path = mock(Path.class); final ProjectDiagram diagram = mock(ProjectDiagram.class); final org.guvnor.common.services.shared.metadata.model.Metadata metadata = mock(org.guvnor.common.services.shared.metadata.model.Metadata.class); final String comment = "comment"; final String xml = "<dmn />"; doReturn(stringCallback).when(service).onSaveAsXmlComplete(diagram, projectDiagramCallback); doNothing().when(service).saveAsXml(any(), any(), any(), any(), any()); service.saveOrUpdate(path, diagram, metadata, comment, projectDiagramCallback); verify(dmnMarshallerService).marshall(eq(diagram), serviceCallbackArgumentCaptor.capture()); serviceCallbackArgumentCaptor.getValue().onSuccess(xml); verify(service).saveAsXml(path, xml, metadata, comment, stringCallback); }
@Override public void saveOrUpdate(final Path path, final ProjectDiagram diagram, final Metadata metadata, final String comment, final ServiceCallback<ProjectDiagram> callback) { dmnMarshallerService.marshall(diagram, new ServiceCallback<String>() { @Override public void onSuccess(final String xml) { saveAsXml(path, xml, metadata, comment, onSaveAsXmlComplete(diagram, callback)); } @Override public void onError(final ClientRuntimeError error) { callback.onError(error); } }); }
DMNClientProjectDiagramService extends ClientProjectDiagramService { @Override public void saveOrUpdate(final Path path, final ProjectDiagram diagram, final Metadata metadata, final String comment, final ServiceCallback<ProjectDiagram> callback) { dmnMarshallerService.marshall(diagram, new ServiceCallback<String>() { @Override public void onSuccess(final String xml) { saveAsXml(path, xml, metadata, comment, onSaveAsXmlComplete(diagram, callback)); } @Override public void onError(final ClientRuntimeError error) { callback.onError(error); } }); } }
DMNClientProjectDiagramService extends ClientProjectDiagramService { @Override public void saveOrUpdate(final Path path, final ProjectDiagram diagram, final Metadata metadata, final String comment, final ServiceCallback<ProjectDiagram> callback) { dmnMarshallerService.marshall(diagram, new ServiceCallback<String>() { @Override public void onSuccess(final String xml) { saveAsXml(path, xml, metadata, comment, onSaveAsXmlComplete(diagram, callback)); } @Override public void onError(final ClientRuntimeError error) { callback.onError(error); } }); } @Inject  DMNClientProjectDiagramService(final ShapeManager shapeManager,
                                          final SessionManager sessionManager,
                                          final Caller<ProjectDiagramService> diagramServiceCaller,
                                          final Caller<DiagramLookupService> diagramLookupServiceCaller,
                                          final Event<SessionDiagramSavedEvent> saveEvent,
                                          final Caller<DMNContentService> dmnContentServiceCaller,
                                          final DMNMarshallerService dmnMarshallerService); }
DMNClientProjectDiagramService extends ClientProjectDiagramService { @Override public void saveOrUpdate(final Path path, final ProjectDiagram diagram, final Metadata metadata, final String comment, final ServiceCallback<ProjectDiagram> callback) { dmnMarshallerService.marshall(diagram, new ServiceCallback<String>() { @Override public void onSuccess(final String xml) { saveAsXml(path, xml, metadata, comment, onSaveAsXmlComplete(diagram, callback)); } @Override public void onError(final ClientRuntimeError error) { callback.onError(error); } }); } @Inject  DMNClientProjectDiagramService(final ShapeManager shapeManager,
                                          final SessionManager sessionManager,
                                          final Caller<ProjectDiagramService> diagramServiceCaller,
                                          final Caller<DiagramLookupService> diagramLookupServiceCaller,
                                          final Event<SessionDiagramSavedEvent> saveEvent,
                                          final Caller<DMNContentService> dmnContentServiceCaller,
                                          final DMNMarshallerService dmnMarshallerService); @Override void getByPath(final Path path,
                          final ServiceCallback<ProjectDiagram> callback); @Override void saveOrUpdate(final Path path,
                             final ProjectDiagram diagram,
                             final Metadata metadata,
                             final String comment,
                             final ServiceCallback<ProjectDiagram> callback); }
DMNClientProjectDiagramService extends ClientProjectDiagramService { @Override public void saveOrUpdate(final Path path, final ProjectDiagram diagram, final Metadata metadata, final String comment, final ServiceCallback<ProjectDiagram> callback) { dmnMarshallerService.marshall(diagram, new ServiceCallback<String>() { @Override public void onSuccess(final String xml) { saveAsXml(path, xml, metadata, comment, onSaveAsXmlComplete(diagram, callback)); } @Override public void onError(final ClientRuntimeError error) { callback.onError(error); } }); } @Inject  DMNClientProjectDiagramService(final ShapeManager shapeManager,
                                          final SessionManager sessionManager,
                                          final Caller<ProjectDiagramService> diagramServiceCaller,
                                          final Caller<DiagramLookupService> diagramLookupServiceCaller,
                                          final Event<SessionDiagramSavedEvent> saveEvent,
                                          final Caller<DMNContentService> dmnContentServiceCaller,
                                          final DMNMarshallerService dmnMarshallerService); @Override void getByPath(final Path path,
                          final ServiceCallback<ProjectDiagram> callback); @Override void saveOrUpdate(final Path path,
                             final ProjectDiagram diagram,
                             final Metadata metadata,
                             final String comment,
                             final ServiceCallback<ProjectDiagram> callback);  }