@SuppressWarnings("unchecked") @Test public void testIsBuildPromotedWhenThereAreNoPromotions() { final AbstractBuild<?, ?> mockBuild = mock(AbstractBuild.class); when(mockBuild.getAction(any(Class.class))).thenReturn(mock(BuildBadgeAction.class)); final PromotionStatusProvider.PromotedBuildActionWrapper mockPromotedBuildActionWrapper = mock(PromotionStatusProvider.PromotedBuildActionWrapper.class); when(mockPromotedBuildActionWrapper.getPromotions(mockBuild)).thenReturn(Collections.<Status>emptyList()); final PromotionStatusProvider promotionStatusProvider = new PromotionStatusProvider(); promotionStatusProvider.setPromotedBuildActionWrapper(mockPromotedBuildActionWrapper); final boolean isPromoted = promotionStatusProvider.isBuildPromoted(mockBuild); assertFalse(isPromoted); }
@SuppressWarnings("unchecked") @Test public void testIsBuildPromotedWhenThereArePromotions() { final AbstractBuild<?, ?> mockBuild = mock(AbstractBuild.class); when(mockBuild.getAction(any(Class.class))).thenReturn(mock(BuildBadgeAction.class)); final List<Status> mockPromotionList = new ArrayList<>(); PowerMockito.mockStatic(Status.class); mockPromotionList.add(mock(Status.class)); final PromotionStatusProvider.PromotedBuildActionWrapper mockPromotedBuildActionWrapper = mock(PromotionStatusProvider.PromotedBuildActionWrapper.class); when(mockPromotedBuildActionWrapper.getPromotions(anyObject())).thenReturn(mockPromotionList); final PromotionStatusProvider promotionStatusProvider = new PromotionStatusProvider(); promotionStatusProvider.setPromotedBuildActionWrapper(mockPromotedBuildActionWrapper); final boolean isPromoted = promotionStatusProvider.isBuildPromoted(mockBuild); assertTrue(isPromoted); }
public static boolean rebuild(Run<?, ?> run) { final QueueTaskFuture queueTaskFuture = asParameterizedJobMixIn(run.getParent()) .scheduleBuild2( 0, run.getAction(ParametersAction.class), run.getAction(CauseAction.class), run.getAction(BuildBadgeAction.class) ); return queueTaskFuture != null; }