Source:
public void testOpenReadOnly() { final ProjectMetadata metadata = mock(ProjectMetadata.class); final Overview overview = mock(Overview.class); final ClientSessionFactory clientSessionFactory = mock(ClientSessionFactory.class); when(diagram.getMetadata()).thenReturn(metadata); when(metadata.getTitle()).thenReturn(TITLE); when(metadata.getOverview()).thenReturn(overview); when(sessionManager.getSessionFactory(eq(metadata), eq(ClientReadOnlySession.class))).thenReturn(clientSessionFactory); doReturn(true).when(presenter).isReadOnly(); presenter.open(diagram); verify(view).showLoading(); verify(presenter).setOriginalHash(anyInt()); verify(presenter).destroySession(); verify(clientSessionFactory).newSession(eq(metadata), clientReadOnlySessionConsumerCaptor.capture()); final Consumer<ClientReadOnlySession> clientReadOnlySessionConsumer = clientReadOnlySessionConsumerCaptor.getValue(); clientReadOnlySessionConsumer.accept(clientFullSession); verify(view).setWidget(eq(sessionPresenterView)); verify(readOnlySessionPresenter).withToolbar(eq(false)); verify(readOnlySessionPresenter).withPalette(eq(false)); verify(readOnlySessionPresenter).open(eq(diagram), eq(clientFullSession), clientSessionPresenterCallbackCaptor.capture()); final SessionPresenter.SessionPresenterCallback clientSessionPresenterCallback = clientSessionPresenterCallbackCaptor.getValue(); clientSessionPresenterCallback.onSuccess(); verify(view).hideBusyIndicator(); verify(overviewWidget).setContent(eq(overview), eq(filePath)); verify(kieView).clear(); verify(kieView).addMainEditorPage(eq(view)); verify(kieView).addOverviewPage(eq(overviewWidget), any(com.google.gwt.user.client.Command.class)); verify(presenter).onDiagramLoad(); assertEquals(readOnlySessionPresenter, presenter.getSessionPresenter()); }

Target:
public void testOpenReadOnly() { final ProjectMetadata metadata = mock(ProjectMetadata.class); final Overview overview = mock(Overview.class); final ClientSessionFactory clientSessionFactory = mock(ClientSessionFactory.class); when(diagram.getMetadata()).thenReturn(metadata); when(metadata.getTitle()).thenReturn(TITLE); when(metadata.getOverview()).thenReturn(overview); when(sessionManager.getSessionFactory(eq(metadata), eq(ClientReadOnlySession.class))).thenReturn(clientSessionFactory); doReturn(true).when(presenter).isReadOnly(); presenter.open(diagram); verify(view).showLoading(); verify(presenter).setOriginalHash(anyInt()); verify(presenter).destroySession(); verify(clientSessionFactory).newSession(eq(metadata), clientReadOnlySessionConsumerCaptor.capture()); final Consumer<ClientReadOnlySession> clientReadOnlySessionConsumer = clientReadOnlySessionConsumerCaptor.getValue(); clientReadOnlySessionConsumer.accept(clientReadOnlySession); verify(view).setWidget(eq(sessionPresenterView)); verify(readOnlySessionPresenter).withToolbar(eq(false)); verify(readOnlySessionPresenter).withPalette(eq(false)); verify(readOnlySessionPresenter).open(eq(diagram), eq(clientReadOnlySession), clientSessionPresenterCallbackCaptor.capture()); final SessionPresenter.SessionPresenterCallback clientSessionPresenterCallback = clientSessionPresenterCallbackCaptor.getValue(); clientSessionPresenterCallback.onSuccess(); verify(view).hideBusyIndicator(); verify(overviewWidget).setContent(eq(overview), eq(filePath)); verify(kieView).clear(); verify(kieView).addMainEditorPage(eq(view)); verify(kieView).addOverviewPage(eq(overviewWidget), any(com.google.gwt.user.client.Command.class)); verify(presenter).onDiagramLoad(); assertEquals(readOnlySessionPresenter, presenter.getSessionPresenter()); }