diff options
Diffstat (limited to 'sonar-batch/src/test/java')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java | 48 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/mediumtest/cache/CacheSyncTest.java | 2 |
2 files changed, 49 insertions, 1 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java b/sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java index 6098850be55..ebaa797cc43 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java @@ -147,4 +147,52 @@ public class ProjectCacheSynchronizerTest { verifyNoMoreInteractions(issuesLoader, userRepositoryLoader, qualityProfileLoader, activeRulesLoader, projectRepositoriesLoader); } + + @Test + public void testLastAnalysisToday() { + ProjectCacheSynchronizer synchronizer = createMockedLoaders(true, new Date()); + + when(cacheStatus.getSyncStatus()).thenReturn(new Date()); + synchronizer.load(PROJECT_KEY, false); + + verify(cacheStatus).getSyncStatus(); + verifyNoMoreInteractions(issuesLoader, userRepositoryLoader, qualityProfileLoader, activeRulesLoader, projectRepositoriesLoader, cacheStatus); + } + + @Test + public void testLastAnalysisYesterday() { + ProjectCacheSynchronizer synchronizer = createMockedLoaders(true, new Date()); + + Date d = new Date(new Date().getTime() - 60 * 60 * 24 * 1000); + when(cacheStatus.getSyncStatus()).thenReturn(d); + synchronizer.load(PROJECT_KEY, false); + + verify(cacheStatus).save(); + verify(cacheStatus).getSyncStatus(); + } + + @Test + public void testDontFailOnError() { + ProjectCacheSynchronizer synchronizer = createMockedLoaders(true, new Date()); + + Date d = new Date(new Date().getTime() - 60 * 60 * 24 * 1000); + when(cacheStatus.getSyncStatus()).thenReturn(d); + + when(projectRepositoriesLoader.load(anyString(), anyBoolean(), any(MutableBoolean.class))).thenThrow(IllegalStateException.class); + synchronizer.load(PROJECT_KEY, false); + + verify(cacheStatus).getSyncStatus(); + verifyNoMoreInteractions(cacheStatus); + } + + @Test + public void testForce() { + ProjectCacheSynchronizer synchronizer = createMockedLoaders(true, new Date()); + + when(cacheStatus.getSyncStatus()).thenReturn(new Date()); + synchronizer.load(PROJECT_KEY, true); + + verify(cacheStatus).save(); + verify(cacheStatus).getSyncStatus(); + } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/cache/CacheSyncTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/cache/CacheSyncTest.java index 41c5eda71cf..052e33a43e2 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/cache/CacheSyncTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/cache/CacheSyncTest.java @@ -119,7 +119,7 @@ public class CacheSyncTest { tester.syncProject("test-project"); assertThat(logOutput.getAsString()).contains("-- Found project [test-project]"); assertThat(logOutput.getAsString()).contains("not found, synchronizing data"); - assertThat(logOutput.getAsString()).contains("], synchronizing data.."); + assertThat(logOutput.getAsString()).contains("], synchronizing data (forced).."); } @Test |