summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Wr�bel <tomasz.wrobel@nokia.com>2021-03-19 08:32:07 +0000
committerGerrit Code Review <gerrit@onap.org>2021-03-19 08:32:07 +0000
commit6df36c389d23a73f46fafb8cc1b70e510bdfbaeb (patch)
treec3c326b0538d39016865b3878f01d2b7d70d1da7
parentcabb0ea2063b7af5e09c33c7e4695f97b902fde5 (diff)
parentc846bc1dc61ccbd43054c0a22e339149bb61905a (diff)
Merge "Add test for exception message in response"
-rw-r--r--src/test/java/org/onap/sdc/helmvalidator/api/ValidationControllerTest.java28
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());
+ }
+
}