Commit 71ee6126 authored by Mingyang Zhu's avatar Mingyang Zhu
Browse files

add negative test cases for the health check apis

parent 89ef1ccc
...@@ -24,6 +24,7 @@ import org.opengroup.osdu.partition.provider.interfaces.IHealthCheckService; ...@@ -24,6 +24,7 @@ import org.opengroup.osdu.partition.provider.interfaces.IHealthCheckService;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
...@@ -42,9 +43,21 @@ public class HealthCheckTest { ...@@ -42,9 +43,21 @@ public class HealthCheckTest {
assertEquals(HttpStatus.OK, this.sut.livenessCheck().getStatusCode()); assertEquals(HttpStatus.OK, this.sut.livenessCheck().getStatusCode());
} }
@Test(expected = Exception.class)
public void should_throwException_when_customizedLivenessCheckFail() {
doThrow(new Exception()).when(healthCheckService).performLivenessCheck();
this.sut.livenessCheck();
}
@Test @Test
public void should_returnHttp200_when_checkReadiness() { public void should_returnHttp200_when_checkReadiness() {
assertEquals(HttpStatus.OK, this.sut.readinessCheck().getStatusCode()); assertEquals(HttpStatus.OK, this.sut.readinessCheck().getStatusCode());
verify(healthCheckService).performReadinessCheck(); verify(healthCheckService).performReadinessCheck();
} }
@Test(expected = Exception.class)
public void should_throwException_when_customizedReadinessCheckFail() {
doThrow(new Exception()).when(healthCheckService).performReadinessCheck();
this.sut.readinessCheck();
}
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment