diff options
author | Piotr Marcinkiewicz <piotr.marcinkiewicz@nokia.com> | 2021-03-17 12:52:34 +0100 |
---|---|---|
committer | Piotr Marcinkiewicz <piotr.marcinkiewicz@nokia.com> | 2021-03-19 08:03:05 +0000 |
commit | c846bc1dc61ccbd43054c0a22e339149bb61905a (patch) | |
tree | b571a939e100262d9e7b3fffce2eaba9b57352db /src/test/java/org/onap | |
parent | 09d2ec0b674d07b01b530ecc48c68132358c4915 (diff) |
Add test for exception message in response
Issue-ID: SDC-3185
Signed-off-by: Piotr Marcinkiewicz <piotr.marcinkiewicz@nokia.com>
Change-Id: Ie632e85c0234b461087262704a0eacbfd830384c
Diffstat (limited to 'src/test/java/org/onap')
-rw-r--r-- | src/test/java/org/onap/sdc/helmvalidator/api/ValidationControllerTest.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/java/org/onap/sdc/helmvalidator/api/ValidationControllerTest.java b/src/test/java/org/onap/sdc/helmvalidator/api/ValidationControllerTest.java index 3c87d7a..c00b75c 100644 --- a/src/test/java/org/onap/sdc/helmvalidator/api/ValidationControllerTest.java +++ b/src/test/java/org/onap/sdc/helmvalidator/api/ValidationControllerTest.java @@ -194,4 +194,32 @@ class ValidationControllerTest { .contains(VERSION_USED); assertThat(mvcResult.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()); } + + @Test + void shouldContainsExceptionMessageInResponse() throws Exception { + MockMultipartFile file = new MockMultipartFile(FILE_KEY, SAMPLE_ORIGINAL_FILENAME, + MediaType.MULTIPART_FORM_DATA_VALUE, "test".getBytes()); + NotSupportedVersionException exception = new NotSupportedVersionException("test"); + + when(validationService.process(SAMPLE_VERSION, file, false, false)) + .thenThrow(exception); + + MvcResult mvcResult = mockMvc.perform( + multipart(VALIDATION_ENDPOINT) + .file(file) + .param(VERSION_PARAM, SAMPLE_VERSION) + .param(IS_LINTED_PARAM, "false") + .param(IS_STRICT_LINTED_PARAM, "false")) + .andReturn(); + String contentAsString = mvcResult.getResponse().getContentAsString(); + + assertThat(contentAsString) + .contains(exception.getMessage()) + .doesNotContain(VALID) + .doesNotContain(RENDER_ERRORS) + .doesNotContain(LINT_WARNING) + .doesNotContain(LINT_ERROR); + assertThat(mvcResult.getResponse().getStatus()).isNotEqualTo(HttpStatus.OK.value()); + } + } |