Skip to content
Snippets Groups Projects
Commit 71ee6126 authored by Mingyang Zhu's avatar Mingyang Zhu
Browse files

add negative test cases for the health check apis

parent 89ef1ccc
No related branches found
No related tags found
1 merge request!53customized readiness check to make sure cache layer is ready before serving traffic
......@@ -24,6 +24,7 @@ import org.opengroup.osdu.partition.provider.interfaces.IHealthCheckService;
import org.springframework.http.HttpStatus;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
......@@ -42,9 +43,21 @@ public class HealthCheckTest {
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
public void should_returnHttp200_when_checkReadiness() {
assertEquals(HttpStatus.OK, this.sut.readinessCheck().getStatusCode());
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment