|
| 1 | +package edu.tamu.app.controller; |
| 2 | + |
| 3 | +import static edu.tamu.weaver.response.ApiStatus.SUCCESS; |
| 4 | +import static org.junit.Assert.assertEquals; |
| 5 | +import static org.mockito.Mockito.when; |
| 6 | + |
| 7 | +import org.junit.Before; |
| 8 | +import org.junit.Test; |
| 9 | +import org.junit.runner.RunWith; |
| 10 | +import org.mockito.InjectMocks; |
| 11 | +import org.mockito.Mock; |
| 12 | +import org.mockito.MockitoAnnotations; |
| 13 | +import org.springframework.test.context.junit4.SpringRunner; |
| 14 | + |
| 15 | +import edu.tamu.app.enums.OverallMessageType; |
| 16 | +import edu.tamu.app.model.OverallStatus; |
| 17 | +import edu.tamu.app.service.MonitorService; |
| 18 | +import edu.tamu.weaver.response.ApiResponse; |
| 19 | + |
| 20 | +@RunWith(SpringRunner.class) |
| 21 | +public class StatusControllerTest { |
| 22 | + |
| 23 | + private static final String TEST_OVERALL_STATUS_MESSAGE = "Test message"; |
| 24 | + private static final OverallMessageType TEST_STATUS = OverallMessageType.SUCCESS; |
| 25 | + |
| 26 | + private static OverallStatus TEST_OVERALL_STATUS = new OverallStatus(TEST_STATUS, TEST_OVERALL_STATUS_MESSAGE); |
| 27 | + |
| 28 | + private ApiResponse response; |
| 29 | + |
| 30 | + @Mock |
| 31 | + private MonitorService monitorService; |
| 32 | + |
| 33 | + @InjectMocks |
| 34 | + private StatusController statusController; |
| 35 | + |
| 36 | + @Before |
| 37 | + public void setup() { |
| 38 | + MockitoAnnotations.initMocks(this); |
| 39 | + when(monitorService.getOverallStatus()).thenReturn(TEST_OVERALL_STATUS); |
| 40 | + when(monitorService.getOverallStatusPublic()).thenReturn(TEST_OVERALL_STATUS); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void testOverallFull() { |
| 45 | + response = statusController.overallFull(); |
| 46 | + assertEquals("Response was not successfull", SUCCESS, response.getMeta().getStatus()); |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + public void testOverallPublic() { |
| 51 | + response = statusController.overallPublic(); |
| 52 | + assertEquals("Response was not successfull", SUCCESS, response.getMeta().getStatus()); |
| 53 | + } |
| 54 | +} |
0 commit comments