From 0e228506998882d6232aea943d7d9ea93ebb92b8 Mon Sep 17 00:00:00 2001 From: David Mason Date: Wed, 18 Apr 2012 17:20:59 +1000 Subject: [PATCH] factor AppPresenter tests to proper mock order --- .../client/presenter/AppPresenterTest.java | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/server/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/AppPresenterTest.java b/server/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/AppPresenterTest.java index 240f820f48..0d645d53b0 100644 --- a/server/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/AppPresenterTest.java +++ b/server/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/AppPresenterTest.java @@ -172,48 +172,35 @@ public void testPerformsRequiredActionsOnBind() public void testShowsNotificationEvents() { - replayAllMocks(); - appPresenter.bind(); - verifyAllMocks(); - - reset(mockDisplay); String testMessage = "test notification message"; mockDisplay.setNotificationMessage(testMessage, Severity.Warning); expectLastCall().once(); - expect(mockDisplay.getDismissVisibility()).andReturn(mockDismissVisibility).anyTimes(); - replay(mockDisplay); - - reset(mockDismissVisibility); mockDismissVisibility.setVisible(true); expectLastCall().once(); - replay(mockDismissVisibility); + replayAllMocks(); + appPresenter.bind(); NotificationEvent notification = new NotificationEvent(Severity.Warning, testMessage); capturedNotificationEventHandler.getValue().onNotification(notification); - verify(mockDisplay); - verify(mockDismissVisibility); + verifyAllMocks(); } public void testShowsUpdatedProjectStats() { - replayAllMocks(); - appPresenter.bind(); - verifyAllMocks(); - - reset(mockDisplay); Capture capturedTranslationStats = new Capture(); mockDisplay.setStats(and(capture(capturedTranslationStats), isA(TranslationStats.class))); expectLastCall().once(); - replay(mockDisplay); + replayAllMocks(); + + appPresenter.bind(); TranslationStats testStats = new TranslationStats(new TransUnitCount(6, 5, 4), new TransUnitWords(3, 2, 1)); ProjectStatsUpdatedEvent event = new ProjectStatsUpdatedEvent(testStats); capturedProjectStatsUpdatedEventHandler.getValue().onProjectStatsRetrieved(event); - verify(mockDisplay); - + verifyAllMocks(); assertThat(capturedTranslationStats.getValue(), is(equalTo(testStats))); }