@Test @SuppressWarnings("unchecked") public void testSaveSessionDiagramSavedEventNotFiredWhenSaveWasUnSuccessful() { TestUtils.prepareServiceCallerError(diagramService, diagramServiceCaller, new Throwable("some error")); when(sessionManager.getCurrentSession()).thenReturn(session); ServiceCallback serviceCallback = mock(ServiceCallback.class); when(diagramService.saveOrUpdate(any())).thenReturn(metadata); tested.saveOrUpdate(diagram, serviceCallback); verify(sessionDiagramSavedEvent, never()).fire(any(SessionDiagramSavedEvent.class)); }
@Override @SuppressWarnings("unchecked") public void saveOrUpdate(final D diagram, final ServiceCallback<D> callback) { diagramServiceCaller.call(serverMetadata -> { updateClientMetadata(diagram); diagram.getMetadata().setPath(((M) serverMetadata).getPath()); callback.onSuccess(diagram); fireSavedEvent(sessionManager.getCurrentSession()); }, (message, throwable) -> { callback.onError(new ClientRuntimeError(throwable)); return false; }).saveOrUpdate(diagram); }
AbstractClientDiagramService implements ClientDiagramService<M, D, S> { @Override @SuppressWarnings("unchecked") public void saveOrUpdate(final D diagram, final ServiceCallback<D> callback) { diagramServiceCaller.call(serverMetadata -> { updateClientMetadata(diagram); diagram.getMetadata().setPath(((M) serverMetadata).getPath()); callback.onSuccess(diagram); fireSavedEvent(sessionManager.getCurrentSession()); }, (message, throwable) -> { callback.onError(new ClientRuntimeError(throwable)); return false; }).saveOrUpdate(diagram); } }
AbstractClientDiagramService implements ClientDiagramService<M, D, S> { @Override @SuppressWarnings("unchecked") public void saveOrUpdate(final D diagram, final ServiceCallback<D> callback) { diagramServiceCaller.call(serverMetadata -> { updateClientMetadata(diagram); diagram.getMetadata().setPath(((M) serverMetadata).getPath()); callback.onSuccess(diagram); fireSavedEvent(sessionManager.getCurrentSession()); }, (message, throwable) -> { callback.onError(new ClientRuntimeError(throwable)); return false; }).saveOrUpdate(diagram); } AbstractClientDiagramService(final ShapeManager shapeManager,
                                        final SessionManager sessionManager,
                                        final Caller<S> diagramServiceCaller,
                                        final Caller<DiagramLookupService> diagramLookupServiceCaller,
                                        final Event<SessionDiagramSavedEvent> saveEvent); }
AbstractClientDiagramService implements ClientDiagramService<M, D, S> { @Override @SuppressWarnings("unchecked") public void saveOrUpdate(final D diagram, final ServiceCallback<D> callback) { diagramServiceCaller.call(serverMetadata -> { updateClientMetadata(diagram); diagram.getMetadata().setPath(((M) serverMetadata).getPath()); callback.onSuccess(diagram); fireSavedEvent(sessionManager.getCurrentSession()); }, (message, throwable) -> { callback.onError(new ClientRuntimeError(throwable)); return false; }).saveOrUpdate(diagram); } AbstractClientDiagramService(final ShapeManager shapeManager,
                                        final SessionManager sessionManager,
                                        final Caller<S> diagramServiceCaller,
                                        final Caller<DiagramLookupService> diagramLookupServiceCaller,
                                        final Event<SessionDiagramSavedEvent> saveEvent); @Override void create(final Path path,
                       final String name,
                       final String defSetId,
                       final ServiceCallback<Path> callback); @Override @SuppressWarnings("unchecked") void saveOrUpdate(final D diagram,
                             final ServiceCallback<D> callback); @Override void saveOrUpdateSvg(Path diagramPath, String rawSvg, ServiceCallback<Path> callback); @Override void add(final D diagram,
                    final ServiceCallback<D> callback); @Override @SuppressWarnings("unchecked") void getByPath(final Path path,
                          final ServiceCallback<D> callback); @Override @SuppressWarnings("unchecked") void lookup(final DiagramLookupRequest request,
                       final ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>> callback); @Override void getRawContent(final D diagram,
                              final ServiceCallback<String> callback); }
AbstractClientDiagramService implements ClientDiagramService<M, D, S> { @Override @SuppressWarnings("unchecked") public void saveOrUpdate(final D diagram, final ServiceCallback<D> callback) { diagramServiceCaller.call(serverMetadata -> { updateClientMetadata(diagram); diagram.getMetadata().setPath(((M) serverMetadata).getPath()); callback.onSuccess(diagram); fireSavedEvent(sessionManager.getCurrentSession()); }, (message, throwable) -> { callback.onError(new ClientRuntimeError(throwable)); return false; }).saveOrUpdate(diagram); } AbstractClientDiagramService(final ShapeManager shapeManager,
                                        final SessionManager sessionManager,
                                        final Caller<S> diagramServiceCaller,
                                        final Caller<DiagramLookupService> diagramLookupServiceCaller,
                                        final Event<SessionDiagramSavedEvent> saveEvent); @Override void create(final Path path,
                       final String name,
                       final String defSetId,
                       final ServiceCallback<Path> callback); @Override @SuppressWarnings("unchecked") void saveOrUpdate(final D diagram,
                             final ServiceCallback<D> callback); @Override void saveOrUpdateSvg(Path diagramPath, String rawSvg, ServiceCallback<Path> callback); @Override void add(final D diagram,
                    final ServiceCallback<D> callback); @Override @SuppressWarnings("unchecked") void getByPath(final Path path,
                          final ServiceCallback<D> callback); @Override @SuppressWarnings("unchecked") void lookup(final DiagramLookupRequest request,
                       final ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>> callback); @Override void getRawContent(final D diagram,
                              final ServiceCallback<String> callback);  }