@@ -0,0 +1,2694 @@
+package org.apache.mesos.kafka.web;%0A%0Aimport org.apache.mesos.kafka.plan.KafkaUpdatePhase;%0Aimport org.apache.mesos.kafka.state.FrameworkState;%0Aimport org.apache.mesos.scheduler.plan.Block;%0Aimport org.apache.mesos.scheduler.plan.Phase;%0Aimport org.apache.mesos.scheduler.plan.Stage;%0Aimport org.apache.mesos.scheduler.plan.StageManager;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0Aimport org.mockito.Mockito;%0Aimport org.mockito.MockitoAnnotations;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0Aimport static org.mockito.Mockito.when;%0A%0A/**%0A * This class tests the BrokerCheck class.%0A */%0Apublic class BrokerCheckTest %7B%0A    @Mock private StageManager stageManager;%0A    @Mock private Stage stage;%0A    @Mock private FrameworkState frameworkState;%0A    @Mock private KafkaUpdatePhase kafkaUpdatePhase;%0A    @Mock private Block block;%0A    private BrokerCheck brokerCheck;%0A%0A    @Before%0A    public void beforeEach() %7B%0A        MockitoAnnotations.initMocks(this);%0A        brokerCheck = new BrokerCheck(stageManager, frameworkState);%0A    %7D%0A%0A    @Test%0A    public void testBrokerCheckConstruction() %7B%0A        Assert.assertNotNull(brokerCheck);%0A    %7D%0A%0A    @Test%0A    public void testCheckException() throws Exception %7B%0A        Assert.assertFalse(brokerCheck.check().isHealthy());%0A    %7D%0A%0A    @Test%0A    public void testCheckNoUpdatePhase() throws Exception %7B%0A        when(stageManager.getStage()).thenReturn(stage);%0A        when(stage.getPhases()).thenReturn(Collections.emptyList());%0A        Assert.assertFalse(brokerCheck.check().isHealthy());%0A    %7D%0A%0A    @Test%0A    public void testCheckBelowBrokerCount() throws Exception %7B%0A        when(stageManager.getStage()).thenReturn(stage);%0A        when(frameworkState.getRunningBrokersCount()).thenReturn(0);%0A        when(block.isComplete()).thenReturn(true);%0A        when(kafkaUpdatePhase.getBlocks()).thenReturn(Arrays.asList(block));%0A        Mockito.%3CList%3C? extends Phase%3E%3Ewhen(stage.getPhases()).thenReturn(getMockPhases());%0A        Assert.assertFalse(brokerCheck.check().isHealthy());%0A    %7D%0A%0A    @Test%0A    public void testCheckAtBrokerCount() throws Exception %7B%0A        when(stageManager.getStage()).thenReturn(stage);%0A        when(frameworkState.getRunningBrokersCount()).thenReturn(1);%0A        when(block.isComplete()).thenReturn(true);%0A        when(kafkaUpdatePhase.getBlocks()).thenReturn(Arrays.asList(block));%0A        Mockito.%3CList%3C? extends Phase%3E%3Ewhen(stage.getPhases()).thenReturn(getMockPhases());%0A        Assert.assertTrue(brokerCheck.check().isHealthy());%0A    %7D%0A%0A    private List%3C? extends Phase%3E getMockPhases() %7B%0A        return Arrays.asList(kafkaUpdatePhase);%0A    %7D%0A%7D

Test BrokerCheck