summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2021-06-16 23:21:04 +0100
committerMichael Morris <michael.morris@est.tech>2021-07-15 13:22:37 +0000
commit53df976426f8845adf58e8ff9355764343a38549 (patch)
treeaa1653532eaf24722be2689f3d6addd0f15094eb /catalog-be/src/test
parentf94241f6b5f25ddda29e505306b16af7f5b82749 (diff)
Specify model at service creation
Allows a user to select a model when designing a service Issue-ID: SDC-3621 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: I386e43ddeb649a4ba0805f153e4b47e8a528cff0
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ModelServletTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java15
2 files changed, 9 insertions, 9 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ModelServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ModelServletTest.java
index 12f803fd19..e40124fff4 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ModelServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ModelServletTest.java
@@ -49,7 +49,6 @@ import org.glassfish.jersey.test.TestProperties;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
@@ -105,8 +104,6 @@ class ModelServletTest extends JerseyTest {
private ResourceImportManager resourceImportManager;
@Mock
private ModelBusinessLogic modelBusinessLogic;
- @InjectMocks
- private ModelServlet modelServlet;
@Mock
private ResponseFormat responseFormat;
@Mock
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java
index 31152c63e7..9d0966b770 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java
@@ -122,7 +122,6 @@ class ResourceUploadServletTest extends JerseyTest {
private final String modelName = "ETSI-SOL001-331";
private final String rootPath = "/v1/catalog/upload/multipart";
- private Response response;
private User user;
@BeforeAll
@@ -203,7 +202,7 @@ class ResourceUploadServletTest extends JerseyTest {
when(resourceImportManager.importNormativeResource(anyString(), any(), any(), anyBoolean(), anyBoolean()))
.thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.CREATED));
when(modelBusinessLogic.findModel(modelName)).thenReturn(Optional.of(new Model(modelName)));
- response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
+ final var response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
.header(Constants.USER_ID_HEADER, USER_ID)
.post(Entity.entity(buildFormDataMultiPart("node-types/TestNodeType001.zip",
"src/test/resources/node-types/nodeTypeWithModelsField.json"), MediaType.MULTIPART_FORM_DATA), Response.class);
@@ -219,7 +218,7 @@ class ResourceUploadServletTest extends JerseyTest {
when(resourceBusinessLogic.validatePropertiesDefaultValues(any())).thenReturn(true);
when(resourceImportManager.importNormativeResource(anyString(), any(), any(), anyBoolean(), anyBoolean()))
.thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.CREATED));
- response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
+ final var response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
.header(Constants.USER_ID_HEADER, USER_ID)
.post(Entity.entity(buildFormDataMultiPart("node-types/TestNodeType002.zip",
"src/test/resources/node-types/nodeTypeWithoutModelsField.json"), MediaType.MULTIPART_FORM_DATA), Response.class);
@@ -228,11 +227,13 @@ class ResourceUploadServletTest extends JerseyTest {
@Test
void uploadMultipartFailWithEmptyModelsTest() throws IOException, ParseException, URISyntaxException {
+ when(responseFormat.getStatus()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(responseFormat);
when(servletUtils.getUserAdmin()).thenReturn(userBusinessLogic);
when(userBusinessLogic.getUser(anyString())).thenReturn(user);
when(resourceBusinessLogic.validatePropertiesDefaultValues(any())).thenReturn(true);
when(modelBusinessLogic.findModel("")).thenReturn(Optional.empty());
- response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
+ final Response response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
.header(Constants.USER_ID_HEADER, USER_ID)
.post(Entity.entity(buildFormDataMultiPart("node-types/TestNodeType002.zip",
"src/test/resources/node-types/nodeTypeWithEmptyModels.json"), MediaType.MULTIPART_FORM_DATA), Response.class);
@@ -245,7 +246,7 @@ class ResourceUploadServletTest extends JerseyTest {
when(userBusinessLogic.getUser(anyString())).thenReturn(user);
when(resourceBusinessLogic.validatePropertiesDefaultValues(any())).thenReturn(true);
when(modelBusinessLogic.findModel(modelName)).thenReturn(Optional.empty());
- response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
+ final var response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
.header(Constants.USER_ID_HEADER, USER_ID)
.post(Entity.entity(buildFormDataMultiPart("node-types/TestNodeType001.zip",
"src/test/resources/node-types/nodeTypeWithModelsField.json"), MediaType.MULTIPART_FORM_DATA), Response.class);
@@ -254,10 +255,12 @@ class ResourceUploadServletTest extends JerseyTest {
@Test
void uploadMultipartThrowsBusinessExceptionTest() throws IOException, ParseException, URISyntaxException {
+ when(responseFormat.getStatus()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(responseFormat);
when(servletUtils.getUserAdmin()).thenReturn(userBusinessLogic);
when(userBusinessLogic.getUser(anyString())).thenReturn(user);
when(resourceBusinessLogic.validatePropertiesDefaultValues(any())).thenReturn(true);
- response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
+ final var response = target().path(rootPath).request(MediaType.APPLICATION_JSON)
.header(Constants.USER_ID_HEADER, USER_ID)
.post(Entity.entity(buildFormDataMultiPart("node-types/TestNodeType001.zip",
"src/test/resources/node-types/invalid.json"), MediaType.MULTIPART_FORM_DATA), Response.class);