diff options
Diffstat (limited to 'src/test/java/org/onap/dcae/common/publishing/MessageRouterHttpStatusMapperTest.java')
-rw-r--r-- | src/test/java/org/onap/dcae/common/publishing/MessageRouterHttpStatusMapperTest.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/java/org/onap/dcae/common/publishing/MessageRouterHttpStatusMapperTest.java b/src/test/java/org/onap/dcae/common/publishing/MessageRouterHttpStatusMapperTest.java index 75f3998..12f0479 100644 --- a/src/test/java/org/onap/dcae/common/publishing/MessageRouterHttpStatusMapperTest.java +++ b/src/test/java/org/onap/dcae/common/publishing/MessageRouterHttpStatusMapperTest.java @@ -20,10 +20,13 @@ package org.onap.dcae.common.publishing; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishResponse; import org.springframework.http.HttpStatus; import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.onap.dcae.ApplicationSettings.responseCompatibility; @@ -61,4 +64,21 @@ class MessageRouterHttpStatusMapperTest { //then assertSame(HttpStatus.OK, httpStatusResponse); } + + @ParameterizedTest + @EnumSource( + value = HttpStatus.class, + names = {"NOT_FOUND", "REQUEST_TIMEOUT", "TOO_MANY_REQUESTS", "INTERNAL_SERVER_ERROR", "BAD_GATEWAY", + "SERVICE_UNAVAILABLE", "GATEWAY_TIMEOUT"} + ) + void shouldMapErrorsTo503WhenBackwardsCompatibilityIsNone(HttpStatus httpStatus) { + //given + responseCompatibility = BACKWARDS_COMPATIBILITY_NONE; + MessageRouterPublishResponse messageRouterPublishResponse = mock(MessageRouterPublishResponse.class); + when(messageRouterPublishResponse.failReason()).thenReturn(httpStatus.toString()); + + //when + //then + assertThrows(RuntimeException.class,()->getHttpStatus(messageRouterPublishResponse)); + } } |