/** * Verifies that we find the correct results for the following constellation. * * <ol> * <li>Build with result * <li>Build with no result * <li>Baseline * </ol> * * @throws Exception the exception */ @Test @SuppressWarnings("rawtypes") public void testHasPreviousResult() throws Exception { AbstractBuild withResult = mock(AbstractBuild.class); AbstractBuild noResult = mock(AbstractBuild.class); AbstractBuild baseline = mock(AbstractBuild.class); when(baseline.getPreviousBuild()).thenReturn(noResult); when(noResult.getPreviousBuild()).thenReturn(withResult); TestResultAction action = mock(TestResultAction.class); when(withResult.getAction(TestResultAction.class)).thenReturn(action); BuildResult result = mock(BuildResult.class); when(action.getResult()).thenReturn(result); AnnotationContainer container = mock(AnnotationContainer.class); when(result.getContainer()).thenReturn(container); BuildHistory history = createHistory(baseline); assertTrue("Build has no previous result", history.hasPreviousResult()); assertSame("Build has wrong previous result", result, history.getPreviousResult()); assertSame("Build has wrong reference result", container, history.getReferenceAnnotations()); }
/** * Verifies that we find the correct results for the following constellation. * * <ol> * <li>Build with result, build result = SUCCESS * <li>Build with no result * <li>Build with result, build result = FAILURE * <li>Build with no result * <li>Baseline * </ol> * * @throws Exception the exception */ @SuppressWarnings("rawtypes") @Test public void testHasReferenceResult() throws Exception { AbstractBuild withSuccessResult = mock(AbstractBuild.class); AbstractBuild noResult2 = mock(AbstractBuild.class); AbstractBuild withFailureResult = mock(AbstractBuild.class); AbstractBuild noResult1 = mock(AbstractBuild.class); AbstractBuild baseline = mock(AbstractBuild.class); when(baseline.getPreviousBuild()).thenReturn(noResult1); when(noResult1.getPreviousBuild()).thenReturn(withFailureResult); when(withFailureResult.getPreviousBuild()).thenReturn(noResult2); when(noResult2.getPreviousBuild()).thenReturn(withSuccessResult); TestResultAction failureAction = mock(TestResultAction.class); when(withFailureResult.getAction(TestResultAction.class)).thenReturn(failureAction); when(failureAction.isSuccessful()).thenReturn(false); BuildResult failureResult = mock(BuildResult.class); when(failureAction.getResult()).thenReturn(failureResult); TestResultAction successAction = mock(TestResultAction.class); when(withSuccessResult.getAction(TestResultAction.class)).thenReturn(successAction); when(successAction.isSuccessful()).thenReturn(true); BuildResult successResult = mock(BuildResult.class); AnnotationContainer container = mock(AnnotationContainer.class); when(successResult.getContainer()).thenReturn(container); when(successAction.getResult()).thenReturn(successResult); BuildHistory history = createHistory(baseline); assertTrue("Build has no previous result", history.hasPreviousResult()); assertSame("Build has wrong previous result", failureResult, history.getPreviousResult()); assertSame("Build has wrong reference result", container, history.getReferenceAnnotations()); }