/** * Tests the isBuilding method of the class {@link BuildMemory}. With two events with started * builds in memory. */ @Test public void testIsBuildingProjectTrue2() { PatchsetCreated event = Setup.createPatchsetCreated(); AbstractProject project = mock(AbstractProject.class); AbstractBuild build = mock(AbstractBuild.class); when(build.getProject()).thenReturn(project); BuildMemory instance = new BuildMemory(); instance.started(event, build); PatchsetCreated event2 = Setup.createPatchsetCreated(); event2.getChange().setNumber(event.getChange().getNumber() + 34); AbstractProject project2 = mock(AbstractProject.class); build = mock(AbstractBuild.class); when(build.getProject()).thenReturn(project2); instance.started(event2, build); AbstractProject project3 = mock(AbstractProject.class); build = mock(AbstractBuild.class); when(build.getProject()).thenReturn(project3); instance.started(event2, build); assertTrue(instance.isBuilding(event, project)); assertTrue(instance.isBuilding(event2, project2)); assertTrue(instance.isBuilding(event2, project3)); }
/** Tests the isBuilding method of the class {@link BuildMemory}. With an empty memory. */ @Test public void testIsBuildingProjectFalse() { PatchsetCreated event = Setup.createPatchsetCreated(); BuildMemory instance = new BuildMemory(); AbstractProject project = mock(AbstractProject.class); assertFalse(instance.isBuilding(event, project)); }
/** * Tests the isBuilding method of the class {@link BuildMemory}. With a completed build in memory. */ @Test public void testIsBuildingProjectCompletedFalse() { PatchsetCreated event = Setup.createPatchsetCreated(); BuildMemory instance = new BuildMemory(); AbstractProject project = mock(AbstractProject.class); AbstractBuild build = mock(AbstractBuild.class); when(build.getProject()).thenReturn(project); when(build.getResult()).thenReturn(Result.UNSTABLE); instance.completed(event, build); assertFalse(instance.isBuilding(event, project)); }
/** * Tests the isBuilding method of the class {@link BuildMemory}. With one started project in * memory. */ @Test public void testIsBuildingProjectTrue() { PatchsetCreated event = Setup.createPatchsetCreated(); AbstractProject project = mock(AbstractProject.class); AbstractBuild build = mock(AbstractBuild.class); when(build.getProject()).thenReturn(project); BuildMemory instance = new BuildMemory(); instance.started(event, build); assertTrue(instance.isBuilding(event, project)); }
/** Tests the isBuilding method of the class {@link BuildMemory}. With a forgotten build. */ @Test public void testIsBuildingFalseWhenForgotten() { PatchsetCreated event = Setup.createPatchsetCreated(); BuildMemory instance = new BuildMemory(); AbstractProject project = mock(AbstractProject.class); AbstractBuild build = mock(AbstractBuild.class); when(build.getProject()).thenReturn(project); PatchSetKey key = instance.started(event, build); instance.forget(key); assertFalse(instance.isBuilding(event)); }
/** Tests the isBuilding method of the class {@link BuildMemory}. With no memory. */ @Test public void testIsBuildingFalse() { PatchsetCreated event = Setup.createPatchsetCreated(); BuildMemory instance = new BuildMemory(); assertFalse(instance.isBuilding(event)); }