@SpringBootTest(classes = {DefaultHttpRestClient.class, PmEndpointsUrlsProperties.class})
@EnableConfigurationProperties
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class DefaultHttpRestClientTest {
+class DefaultHttpRestClientTest {
private static final Adapter ADAPTER =
Adapter.builder().hostIpAddress("150.62.25.26").username("admin").password("secretPassword").build();
@Test
@DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
- public void testGetFailedToken() {
+ void testGetFailedToken() {
final SimpleHttpResponse response =
SimpleHttpResponse.create(HttpStatus.SC_UNAUTHORIZED, "error", ContentType.APPLICATION_JSON);
}
@Test
- public void testReadFiles() throws IOException {
+ void testReadFiles() throws IOException {
final String tokenJson = JsonUtils.readJson("/json/tokenResponse.json");
final SimpleHttpResponse response =
SimpleHttpResponse.create(HttpStatus.SC_OK, tokenJson, ContentType.APPLICATION_JSON);
}
@Test
- public void testReadFilesResponseFail() throws IOException {
+ void testReadFilesResponseFail() throws IOException {
final String tokenJson = JsonUtils.readJson("/json/tokenResponse.json");
final SimpleHttpResponse response =
SimpleHttpResponse.create(HttpStatus.SC_OK, tokenJson, ContentType.APPLICATION_JSON);
}
@Test
- public void testGetTimeOffset() throws IOException {
+ void testGetTimeOffset() throws IOException {
final String tokenJson = JsonUtils.readJson("/json/tokenResponse.json");
final SimpleHttpResponse response =
SimpleHttpResponse.create(HttpStatus.SC_OK, tokenJson, ContentType.APPLICATION_JSON);
}
@Test
- public void testGetTimeOffsetFail() throws IOException {
+ void testGetTimeOffsetFail() throws IOException {
final String tokenJson = JsonUtils.readJson("/json/tokenResponse.json");
final SimpleHttpResponse response =
SimpleHttpResponse.create(HttpStatus.SC_OK, tokenJson, ContentType.APPLICATION_JSON);
observer.assertError(throwable -> throwable.getMessage()
.equals("Get Zone offset failed for 150.62.25.26 . Empty output received"));
}
+
+ @Test
+ void testGetTimeOffsetFailExecutionException() {
+ final TestObserver<ZoneId> observer = restClient.getTimeZone(ADAPTER).test();
+ observer.assertError(throwable -> throwable.getMessage().equals("Failed to get Zone ID for 150.62.25.26"));
+ }
}
\ No newline at end of file