Skip to content
Snippets Groups Projects
Commit 1f98ed6b authored by OZGCloud's avatar OZGCloud
Browse files

OZG-1952 OZG-1975 OZG-1976 add null check on body

parent 31bbd9bd
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,11 @@ class OsiPostfachService {
ResponseEntity<Message[]> response = executeHandlingException(
() -> restTemplate.exchange(properties.getUrl(), HttpMethod.GET, null, Message[].class));
if (Objects.isNull(response.getBody())) {
LOG.warn("OSI Postfach response with an empty body");
return Stream.empty();
}
return Arrays.stream(response.getBody());
}
......
......@@ -82,7 +82,20 @@ class OsiPostfachServiceITCase {
mockServer.expect(header(PostfachConfiguration.HEADER_API_REALM, API_REALM))
.andRespond(withSuccess(String.valueOf(false), MediaType.APPLICATION_JSON));
assertThrows(OsiPostfachException.class, () -> service.sendMessage(MessageTestFactory.create()));
assertThrows(OsiPostfachException.class, () -> service.sendMessage(MessageTestFactory.create()));// NOSONAR
mockServer.verify();
}
}
@Nested
class TestGetMessages {
@Test
void shouldNotThrowErrorOnEmptyBody() {
mockServer.expect(requestTo(URL)).andRespond(withSuccess());
assertDoesNotThrow(() -> service.getAllMessages());
mockServer.verify();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment