summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java1
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java2
-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
6 files changed, 16 insertions, 10 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java
index 6eb806d3d1..de79ec165d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java
@@ -50,7 +50,7 @@ public class ModelBusinessLogic {
}
public Model createModel(final Model model) {
- LOGGER.debug("createModel: creating model {}", model);
+ LOGGER.debug("creating model {}", model);
return modelOperation.createModel(model, false);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 2956abfe1b..c0c68d6c47 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -2451,6 +2451,9 @@ public class ServiceImportBusinessLogic {
if (CollectionUtils.isEmpty(newResource.getProperties())) {
newResource.setProperties(oldResource.getProperties());
}
+ if (newResource.getModel() == null) {
+ newResource.setModel(oldResource.getModel());
+ }
}
protected Map<String, Resource> createResourcesFromYamlNodeTypesList(String yamlName, Service service, Map<String, Object> mappedToscaTemplate,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
index 706f7a7304..32a63dcc46 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
@@ -445,6 +445,7 @@ public class UiComponentDataConverter {
dataTransfer.setMetadata(metadata);
dataTransfer.setDerivedFromGenericType(service.getDerivedFromGenericType());
dataTransfer.setDerivedFromGenericVersion(service.getDerivedFromGenericVersion());
+ dataTransfer.setModel(service.getModel());
break;
case NODE_FILTER:
if (service.getNodeFilterComponents() == null) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java
index bdc9ffce43..e7966e0d08 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java
@@ -123,6 +123,7 @@ public class ResourceUploadServlet extends AbstractValidationsServlet {
commonGeneralValidations(responseWrapper, userWrapper, uploadResourceInfoWrapper, resourceAuthorityEnum, userId, resourceInfoJsonString);
final String modelNameToBeAssociated = uploadResourceInfoWrapper.getInnerElement().getModel();
if (modelNameToBeAssociated != null) {
+ log.debug("Model Name to be validated {}", modelNameToBeAssociated);
validateModel(modelNameToBeAssociated);
}
fillPayload(responseWrapper, uploadResourceInfoWrapper, yamlStringWrapper, userWrapper.getInnerElement(), resourceInfoJsonString,
@@ -155,6 +156,7 @@ public class ResourceUploadServlet extends AbstractValidationsServlet {
*/
private void validateModel(final String modelName) {
if (modelBusinessLogic.findModel(modelName).isEmpty()) {
+ log.error("Could not find model name {}", modelName);
throw ModelOperationExceptionSupplier.invalidModel(modelName).get();
}
}
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);