Return List<Artifact> in ArtifactDownloadManager 15/137815/1 master
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Tue, 30 Apr 2024 09:22:07 +0000 (11:22 +0200)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Tue, 30 Apr 2024 09:22:07 +0000 (11:22 +0200)
- return processed artifacts as List<Artifact> instead of updating the parameters in ArtifactDownloadManager
- use exceptions to signal exceptional behaviour instead of boolean success = false;

Issue-ID: AAI-3841
Change-Id: Ie99c5da1f553bebd70665914fa6be9c460fa412c
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
29 files changed:
pom.xml
releases/1.14.0-container-release.yaml [new file with mode: 0644]
src/main/java/org/onap/aai/modelloader/babel/BabelArtifactService.java
src/main/java/org/onap/aai/modelloader/entity/ArtifactHandler.java
src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java
src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifactParser.java
src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java
src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactParser.java
src/main/java/org/onap/aai/modelloader/entity/model/ModelSorter.java
src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java
src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java
src/main/java/org/onap/aai/modelloader/notification/EventCallback.java
src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientImpl.java
src/main/java/org/onap/aai/modelloader/service/ArtifactDeploymentManager.java
src/main/java/org/onap/aai/modelloader/service/BabelServiceClientFactory.java [deleted file]
src/main/java/org/onap/aai/modelloader/service/ModelController.java
src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java [deleted file]
src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactHandler.java
src/test/java/org/onap/aai/modelloader/notification/ArtifactDownloadManagerTest.java
src/test/java/org/onap/aai/modelloader/notification/ArtifactDownloadManagerVnfcTest.java
src/test/java/org/onap/aai/modelloader/notification/TestArtifactDeploymentManager.java
src/test/java/org/onap/aai/modelloader/notification/TestArtifactDownloadManager.java
src/test/java/org/onap/aai/modelloader/notification/TestBabelArtifactConverter.java
src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java
src/test/java/org/onap/aai/modelloader/restclient/MockBabelServiceClient.java [deleted file]
src/test/java/org/onap/aai/modelloader/service/MockBabelServiceClientFactory.java [deleted file]
src/test/java/org/onap/aai/modelloader/service/TestModelController.java
src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java
version.properties

diff --git a/pom.xml b/pom.xml
index 633350a..fb4aad4 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
        <parent>
                <groupId>org.onap.oparent</groupId>
                <artifactId>oparent</artifactId>
-               <version>2.1.0</version>
+               <version>3.3.3</version>
                <relativePath />
        </parent>
 
                <start-class>org.onap.aai.modelloader.service.ModelLoaderApplication</start-class>
                <nexusproxy>https://nexus.onap.org</nexusproxy>
                <docker.location>${basedir}/target</docker.location>
-               <spring-boot.version>2.4.13</spring-boot.version>
-               <spring-cloud.version>2020.0.2</spring-cloud.version>
+               <spring-boot.version>2.7.18</spring-boot.version>
+               <spring-cloud.version>2021.0.8</spring-cloud.version>
                <apache.commons-text.version>1.10.0</apache.commons-text.version>
                <commons-compress.version>1.22</commons-compress.version>
                <gson.version>2.10.1</gson.version>
                <hamcrest-all.version>1.3</hamcrest-all.version>
                <babel.version>1.13.0</babel.version>
-               <aai.rest.client.version>1.2.1</aai.rest.client.version>
                <sdc-distribution-client.version>2.1.1</sdc-distribution-client.version>
                <logback.version>1.2.11</logback.version>
                <!-- docker related properties -->
                                </exclusion>
                        </exclusions>
                </dependency>
-               <dependency>
-                       <groupId>org.glassfish.jersey.core</groupId>
-                       <artifactId>jersey-common</artifactId>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.onap.aai</groupId>
-                       <artifactId>rest-client</artifactId>
-                       <version>${aai.rest.client.version}</version>
-               </dependency>
                <dependency>
                        <groupId>com.google.code.gson</groupId>
                        <artifactId>gson</artifactId>
                        <artifactId>sdc-distribution-client</artifactId>
                        <version>${sdc-distribution-client.version}</version>
                </dependency>
-               <dependency>
-                       <groupId>org.json</groupId>
-                       <artifactId>json</artifactId>
-                       <version>20131018</version>
-                       <!--$NO-MVN-MAN-VER$ -->
-               </dependency>
-               <dependency>
-                       <groupId>org.eclipse.jetty</groupId>
-                       <artifactId>jetty-security</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>jline</groupId>
-                       <artifactId>jline</artifactId>
-                       <version>2.12.1</version>
-               </dependency>
                <dependency>
                        <groupId>org.apache.commons</groupId>
                        <artifactId>commons-compress</artifactId>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-surefire-plugin</artifactId>
-                               <version>3.0.0-M4</version>
+                               <version>3.1.2</version>
                                <configuration>
                                        <!-- Sets the VM argument line used when unit tests are run. -->
                                        <argLine>${surefireArgLine}</argLine>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-failsafe-plugin</artifactId>
-                               <version>3.0.0-M4</version>
+                               <version>3.1.2</version>
                                <executions>
                                        <!-- Ensures that both integration-test and verify goals of the Failsafe
                      Maven plugin are executed. -->
diff --git a/releases/1.14.0-container-release.yaml b/releases/1.14.0-container-release.yaml
new file mode 100644 (file)
index 0000000..cba0f30
--- /dev/null
@@ -0,0 +1,7 @@
+distribution_type: container
+container_release_tag: 1.14.0
+project: model-loader
+ref: de4e6c93f2f4038167e8b5fef92426c4daac4b83
+containers:
+    - name: model-loader
+      version: 1.14-STAGING-20240425T063121Z
index 1221861..029814a 100644 (file)
  */
 package org.onap.aai.modelloader.babel;
 
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
 
 import org.onap.aai.babel.service.data.BabelArtifact;
-import org.onap.aai.babel.service.data.BabelRequest;
 import org.onap.aai.babel.service.data.BabelArtifact.ArtifactType;
+import org.onap.aai.babel.service.data.BabelRequest;
 import org.onap.aai.cl.api.Logger;
 import org.onap.aai.cl.eelf.LoggerFactory;
 import org.onap.aai.modelloader.entity.Artifact;
@@ -39,62 +38,65 @@ import org.springframework.stereotype.Service;
 @Service
 public class BabelArtifactService {
 
-  private static Logger logger = LoggerFactory.getInstance().getLogger(BabelArtifactService.class);
+    private static Logger logger = LoggerFactory.getInstance().getLogger(BabelArtifactService.class);
+
+    private final BabelServiceClient babelServiceClient;
+    private final BabelArtifactConverter babelArtifactConverter;
+
+    public BabelArtifactService(BabelServiceClient babelServiceClient, BabelArtifactConverter babelArtifactConverter) {
+        this.babelServiceClient = babelServiceClient;
+        this.babelArtifactConverter = babelArtifactConverter;
+    }
+
+    public List<Artifact> invokeBabelService(BabelRequest babelRequest, String distributionId)
+            throws ProcessToscaArtifactsException {
+        try {
+            logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT,
+                    "Posting artifact: " + babelRequest.getArtifactName() + ", service version: "
+                            + babelRequest.getArtifactVersion()
+                            + ", artifact version: " + babelRequest.getArtifactVersion());
+
+            List<BabelArtifact> babelArtifacts = babelServiceClient.postArtifact(babelRequest, distributionId);
+
+            List<Artifact> convertedArtifacts = new ArrayList<>();
+            for(BabelArtifact babelArtifact : babelArtifacts) {
+                if(!isUnknownType(babelArtifact)) {
+                    if(babelArtifact.getType() == ArtifactType.MODEL) {
+                        convertedArtifacts.addAll(babelArtifactConverter.convertToModel(babelArtifact));
+                    } else {
+                        convertedArtifacts.add(babelArtifactConverter.convertToCatalog(babelArtifact));
+                    }
+                }
+            }
+
+            return convertedArtifacts;
 
-  private final BabelServiceClient babelServiceClient;
-  private final BabelArtifactConverter babelArtifactConverter;
+        } catch (BabelArtifactParsingException e) {
+            logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR,
+                    "Error for artifact " + babelRequest.getArtifactName() + " " + babelRequest.getArtifactVersion()
+                            + " " + e);
+            throw new ProcessToscaArtifactsException(
+                    "An error occurred while trying to parse the Babel artifacts: " + e.getLocalizedMessage());
+        } catch (Exception e) {
+            logger.error(ModelLoaderMsgs.BABEL_REST_REQUEST_ERROR, e, "POST",
+                    "Error posting artifact " + babelRequest.getArtifactName() + " " + babelRequest.getArtifactVersion()
+                            + " to Babel: "
+                            + e.getLocalizedMessage());
+            throw new ProcessToscaArtifactsException(
+                    "An error occurred while calling the Babel service: " + e.getLocalizedMessage());
+        }
+    }
 
-  public BabelArtifactService(BabelServiceClient babelServiceClient, BabelArtifactConverter babelArtifactConverter) {
-    this.babelServiceClient = babelServiceClient;
-    this.babelArtifactConverter = babelArtifactConverter;
-  }
+    private boolean isUnknownType(BabelArtifact babelArtifact) {
+        if (babelArtifact.getType() == ArtifactType.MODEL || babelArtifact.getType() == ArtifactType.VNFCATALOG) {
+            return false;
+        } else {
+            logger.warn(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR,
+                    babelArtifact.getName() + " " + babelArtifact.getType()
+                            + ". Unexpected artifact types returned by the babel service: "
+                            + babelArtifact.getPayload());
+            return true;
+        }
+    }
 
-  public void invokeBabelService(List<Artifact> modelArtifacts, List<Artifact> catalogArtifacts, BabelRequest babelRequest, String distributionId)
-          throws ProcessToscaArtifactsException {
-      try {
-          logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT,
-                  "Posting artifact: " + babelRequest.getArtifactName() + ", service version: " + babelRequest.getArtifactVersion()
-                          + ", artifact version: " + babelRequest.getArtifactVersion());
-  
-          List<BabelArtifact> babelArtifacts =
-                babelServiceClient.postArtifact(babelRequest, distributionId);
-  
-          // Sort Babel artifacts based on type
-          Map<ArtifactType, List<BabelArtifact>> artifactMap =
-                  babelArtifacts.stream().collect(Collectors.groupingBy(BabelArtifact::getType));
-  
-          if (artifactMap.containsKey(BabelArtifact.ArtifactType.MODEL)) {
-              modelArtifacts.addAll(
-                      babelArtifactConverter.convertToModel(artifactMap.get(BabelArtifact.ArtifactType.MODEL)));
-              artifactMap.remove(BabelArtifact.ArtifactType.MODEL);
-          }
-  
-          if (artifactMap.containsKey(BabelArtifact.ArtifactType.VNFCATALOG)) {
-              catalogArtifacts.addAll(babelArtifactConverter
-                      .convertToCatalog(artifactMap.get(BabelArtifact.ArtifactType.VNFCATALOG)));
-              artifactMap.remove(BabelArtifact.ArtifactType.VNFCATALOG);
-          }
-  
-          // Log unexpected artifact types
-          if (!artifactMap.isEmpty()) {
-              logger.warn(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR,
-                      babelRequest.getArtifactName() + " " + babelRequest.getArtifactVersion()
-                              + ". Unexpected artifact types returned by the babel service: "
-                              + artifactMap.keySet().toString());
-          }
-  
-      } catch (BabelArtifactParsingException e) {
-          logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR,
-                  "Error for artifact " + babelRequest.getArtifactName() + " " + babelRequest.getArtifactVersion() + " " + e);
-          throw new ProcessToscaArtifactsException(
-                  "An error occurred while trying to parse the Babel artifacts: " + e.getLocalizedMessage());
-      } catch (Exception e) {
-          logger.error(ModelLoaderMsgs.BABEL_REST_REQUEST_ERROR, e, "POST",
-                  "Error posting artifact " + babelRequest.getArtifactName() + " " + babelRequest.getArtifactVersion() + " to Babel: "
-                          + e.getLocalizedMessage());
-          throw new ProcessToscaArtifactsException(
-                  "An error occurred while calling the Babel service: " + e.getLocalizedMessage());
-      }
-  }
-  
-}
+}
\ No newline at end of file
index c630822..50abdd0 100644 (file)
@@ -23,7 +23,6 @@ package org.onap.aai.modelloader.entity;
 import java.util.List;\r
 import org.onap.aai.modelloader.config.ModelLoaderConfig;\r
 import org.onap.aai.modelloader.restclient.AaiRestClient;\r
-import org.springframework.web.client.RestTemplate;\r
 \r
 public abstract class ArtifactHandler {\r
 \r
index 95d3426..9b05024 100644 (file)
@@ -46,7 +46,6 @@ import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;\r
 import org.springframework.http.ResponseEntity;\r
 import org.springframework.stereotype.Component;\r
-import org.springframework.web.client.RestTemplate;\r
 import org.w3c.dom.Document;\r
 import org.w3c.dom.Element;\r
 import org.w3c.dom.Node;\r
index 35405e6..14f46f3 100644 (file)
@@ -82,7 +82,8 @@ public abstract class AbstractModelArtifactParser implements IModelParser {
 
             IModelArtifact model = parseModel(doc.getDocumentElement(), artifactPayload);
 
-            if (!processParsedModel(modelList, artifactName, model)) {
+            boolean success = processParsedModel(modelList, artifactName, model);
+            if (!success) {
                 modelList = null;
             }
         } catch (Exception ex) {
index fa22969..364fc78 100644 (file)
 package org.onap.aai.modelloader.entity.model;
 
 import java.util.List;
+
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
 import org.onap.aai.modelloader.entity.Artifact;
 import org.onap.aai.modelloader.entity.ArtifactType;
 import org.onap.aai.modelloader.restclient.AaiRestClient;
+import org.onap.aai.modelloader.service.ModelLoaderMsgs;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpServerErrorException;
 
 
 public class ModelArtifact extends AbstractModelArtifact {
 
+    private static Logger logger = LoggerFactory.getInstance().getLogger(ModelArtifact.class);
+
     private static final String AAI_MODEL_VER_SUB_URL = "/model-vers/model-ver";
 
     private static final String FAILURE_MSG_PREFIX = "Ingestion failed for ";
@@ -121,8 +128,13 @@ public class ModelArtifact extends AbstractModelArtifact {
      * @return true if the resource PUT as XML media was successful (status OK)
      */
     private boolean putXmlResource(AaiRestClient aaiClient, String distId, String resourceUrl, String payload) {
-        ResponseEntity<String> putResponse =
-                aaiClient.putResource(resourceUrl, payload, distId, MediaType.APPLICATION_XML, String.class);
+        ResponseEntity<String> putResponse = null;
+        try {
+            putResponse =
+                    aaiClient.putResource(resourceUrl, payload, distId, MediaType.APPLICATION_XML, String.class);
+        } catch (HttpClientErrorException | HttpServerErrorException e) {
+            logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "Error putting resource: " + e.toString());
+        }
         return putResponse != null && putResponse.getStatusCode() == HttpStatus.CREATED;
     }
 
index de99880..367b212 100644 (file)
@@ -37,10 +37,12 @@ import org.onap.aai.cl.api.Logger;
 import org.onap.aai.cl.eelf.LoggerFactory;
 import org.onap.aai.modelloader.entity.Artifact;
 import org.onap.aai.modelloader.service.ModelLoaderMsgs;
+import org.springframework.stereotype.Component;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+@Component
 public class ModelArtifactParser extends AbstractModelArtifactParser {
 
     public static final String MODEL_VER = "model-ver";
index 4c39975..22367c6 100644 (file)
@@ -29,7 +29,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
-import jline.internal.Log;
+
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
 import org.onap.aai.modelloader.entity.Artifact;
 
 /**
@@ -39,6 +41,8 @@ import org.onap.aai.modelloader.entity.Artifact;
  */
 public class ModelSorter {
 
+    private static Logger logger = LoggerFactory.getInstance().getLogger(ModelSorter.class);
+
     /**
      * Wraps a Model object to form dependencies other Models using Edges.
      */
@@ -168,7 +172,7 @@ public class ModelSorter {
                     // create node
                     AbstractModelArtifact referencedModel = versionIdToModelMap.get(referencedModelId);
                     if (referencedModel == null) {
-                        Log.debug("ignoring " + referencedModelId);
+                        logger.debug("ignoring " + referencedModelId);
                         continue; // referenced model not supplied, no need to sort it
                     }
                     referencedNode = new Node(referencedModel);
index f0c96bd..e2c5e27 100644 (file)
@@ -22,8 +22,12 @@ package org.onap.aai.modelloader.notification;
 
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.Base64;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
 import org.onap.aai.babel.service.data.BabelRequest;
 import org.onap.aai.cl.api.Logger;
 import org.onap.aai.cl.eelf.LoggerFactory;
@@ -31,6 +35,8 @@ import org.onap.aai.cl.mdc.MdcContext;
 import org.onap.aai.cl.mdc.MdcOverride;
 import org.onap.aai.modelloader.babel.BabelArtifactService;
 import org.onap.aai.modelloader.entity.Artifact;
+import org.onap.aai.modelloader.entity.ArtifactType;
+import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifact;
 import org.onap.aai.modelloader.entity.model.BabelArtifactParsingException;
 import org.onap.aai.modelloader.entity.model.IModelParser;
 import org.onap.aai.modelloader.entity.model.NamedQueryArtifactParser;
@@ -81,29 +87,25 @@ public class ArtifactDownloadManager {
      * @param modelArtifacts collection of artifacts for model query specs
      * @param catalogArtifacts collection of artifacts that represent vnf catalog files
      * @return boolean <code>true</code> if the download process was successful otherwise <code>false</code>
+     * @throws Exception 
      */
-    boolean downloadArtifacts(INotificationData data, List<IArtifactInfo> artifacts, List<Artifact> modelArtifacts,
-            List<Artifact> catalogArtifacts) {
-        boolean success = true;
+    List<Artifact> downloadArtifacts(INotificationData data, List<IArtifactInfo> artifacts) throws Exception {
 
+        List<Artifact> allArtifacts = new ArrayList<>();
         for (IArtifactInfo artifact : artifacts) {
             try {
                 IDistributionClientDownloadResult downloadResult = downloadIndividualArtifacts(data, artifact);
-                processDownloadedArtifacts(modelArtifacts, catalogArtifacts, artifact, downloadResult, data);
+                List<Artifact> processedArtifacts = processDownloadedArtifacts(artifact, downloadResult, data);
+                allArtifacts.addAll(processedArtifacts);
             } catch (DownloadFailureException e) {
                 notificationPublisher.publishDownloadFailure(client, data, artifact, e.getMessage());
-                success = false;
-            } catch (Exception e) {
+                throw e;
+            } catch (ProcessToscaArtifactsException | InvalidArchiveException | BabelArtifactParsingException e) {
                 notificationPublisher.publishDeployFailure(client, data, artifact);
-                success = false;
-            }
-
-            if (!success) {
-                break;
+                throw e;
             }
         }
-
-        return success;
+        return allArtifacts;
     }
 
     private IDistributionClientDownloadResult downloadIndividualArtifacts(INotificationData data,
@@ -129,46 +131,59 @@ public class ArtifactDownloadManager {
         return downloadResult;
     }
 
-    private void processDownloadedArtifacts(List<Artifact> modelArtifacts, List<Artifact> catalogArtifacts,
+    private List<Artifact> processDownloadedArtifacts(
             IArtifactInfo artifactInfo, IDistributionClientDownloadResult downloadResult, INotificationData data)
             throws ProcessToscaArtifactsException, InvalidArchiveException, BabelArtifactParsingException {
+        List<Artifact> artifacts = new ArrayList<>();
+        List<Artifact> querySpecArtifacts = new ArrayList<>();
         if ("TOSCA_CSAR".equalsIgnoreCase(artifactInfo.getArtifactType())) {
-            processToscaArtifacts(modelArtifacts, catalogArtifacts, downloadResult.getArtifactPayload(), artifactInfo,
+            artifacts = processToscaArtifacts(downloadResult.getArtifactPayload(), artifactInfo,
                     data.getDistributionID(), data.getServiceVersion());
+            
         } else if (ArtifactTypeEnum.MODEL_QUERY_SPEC.toString().equalsIgnoreCase(artifactInfo.getArtifactType())) {
-            processModelQuerySpecArtifact(modelArtifacts, downloadResult);
+            querySpecArtifacts = processModelQuerySpecArtifact(downloadResult);
         } else {
             logger.info(ModelLoaderMsgs.UNSUPPORTED_ARTIFACT_TYPE, artifactInfo.getArtifactName(),
                     artifactInfo.getArtifactType());
             throw new InvalidArchiveException("Unsupported artifact type: " + artifactInfo.getArtifactType());
         }
+        return Stream
+            .concat(artifacts.stream(), querySpecArtifacts.stream())
+            .collect(Collectors.toList());
     }
 
-    public void processToscaArtifacts(List<Artifact> modelArtifacts, List<Artifact> catalogArtifacts, byte[] payload,
-            IArtifactInfo artifactInfo, String distributionId, String serviceVersion)
+    public List<Artifact> processToscaArtifacts(byte[] payload, IArtifactInfo artifactInfo, String distributionId, String serviceVersion)
             throws ProcessToscaArtifactsException, InvalidArchiveException {
         // Get translated artifacts from Babel Service
         BabelRequest babelRequest = new BabelRequest();
         babelRequest.setArtifactName(artifactInfo.getArtifactName());
         babelRequest.setCsar(Base64.getEncoder().encodeToString(payload));
         babelRequest.setArtifactVersion(serviceVersion);
-        babelArtifactService.invokeBabelService(modelArtifacts, catalogArtifacts, babelRequest, distributionId);
+        List<Artifact> artifacts = babelArtifactService.invokeBabelService(babelRequest, distributionId);
 
         // Get VNF Catalog artifacts directly from CSAR
         List<Artifact> csarCatalogArtifacts = vnfCatalogExtractor.extract(payload, artifactInfo.getArtifactName());
 
         // Throw an error if VNF Catalog data is present in the Babel payload and directly in the CSAR
-        if (!catalogArtifacts.isEmpty() && !csarCatalogArtifacts.isEmpty()) {
+        if (isDuplicateVnfCatalogData(artifacts, csarCatalogArtifacts)) {
             logger.error(ModelLoaderMsgs.DUPLICATE_VNFC_DATA_ERROR, artifactInfo.getArtifactName());
             throw new InvalidArchiveException("CSAR: " + artifactInfo.getArtifactName()
                     + " contains VNF Catalog data in the format of both TOSCA and XML files. Only one format can be used for each CSAR file.");
-        } else if (!csarCatalogArtifacts.isEmpty()) {
-            catalogArtifacts.addAll(csarCatalogArtifacts);
         }
+        return Stream
+                .concat(artifacts.stream(), csarCatalogArtifacts.stream())
+                .collect(Collectors.toList());
+
     }
 
-    private void processModelQuerySpecArtifact(List<Artifact> modelArtifacts,
-            IDistributionClientDownloadResult downloadResult) throws BabelArtifactParsingException {
+    private boolean isDuplicateVnfCatalogData(List<Artifact> babelArtifacts, List<Artifact> csarCatalogArtifacts) {
+        boolean babelIsEmpty = babelArtifacts.stream()
+            .filter(VnfCatalogArtifact.class::isInstance)
+            .findAny().isEmpty();
+        return !csarCatalogArtifacts.isEmpty() && !babelIsEmpty;
+    }
+
+    private List<Artifact> processModelQuerySpecArtifact(IDistributionClientDownloadResult downloadResult) throws BabelArtifactParsingException {
         logger.debug(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Processing named query artifact.");
 
         IModelParser parser = new NamedQueryArtifactParser();
@@ -176,15 +191,11 @@ public class ArtifactDownloadManager {
         List<Artifact> parsedArtifacts =
                 parser.parse(new String(downloadResult.getArtifactPayload()), downloadResult.getArtifactFilename());
 
-        if (parsedArtifactsExist(parsedArtifacts)) {
-            modelArtifacts.addAll(parsedArtifacts);
+        if (parsedArtifacts != null && !parsedArtifacts.isEmpty()) {
+            return parsedArtifacts;
         } else {
             throw new BabelArtifactParsingException(
                     "Could not parse generated XML: " + new String(downloadResult.getArtifactPayload()));
         }
     }
-
-    private boolean parsedArtifactsExist(List<Artifact> parsedArtifacts) {
-        return parsedArtifacts != null && !parsedArtifacts.isEmpty();
-    }
 }
index 5118652..59d3348 100644 (file)
@@ -20,7 +20,6 @@
  */
 package org.onap.aai.modelloader.notification;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import org.onap.aai.babel.service.data.BabelArtifact;
@@ -38,6 +37,12 @@ import org.springframework.stereotype.Component;
 @Component
 public class BabelArtifactConverter {
 
+    private final ModelArtifactParser modelArtifactParser;
+
+    public BabelArtifactConverter(ModelArtifactParser modelArtifactParser) {
+        this.modelArtifactParser = modelArtifactParser;
+    }
+
     /**
      * This method converts BabelArtifacts into instances of {@link ModelArtifact}.
      *
@@ -46,24 +51,15 @@ public class BabelArtifactConverter {
      * @throws BabelArtifactParsingException if an error occurs trying to parse the generated XML files that were
      *         converted from tosca artifacts
      */
-    public List<Artifact> convertToModel(List<BabelArtifact> xmlArtifacts) throws BabelArtifactParsingException {
-        Objects.requireNonNull(xmlArtifacts);
-        List<Artifact> modelArtifacts = new ArrayList<>();
-        ModelArtifactParser modelArtParser = new ModelArtifactParser();
-
-        // Parse TOSCA payloads
-        for (BabelArtifact xmlArtifact : xmlArtifacts) {
-
-            List<Artifact> parsedArtifacts = modelArtParser.parse(xmlArtifact.getPayload(), xmlArtifact.getName());
-
-            if (parsedArtifacts == null || parsedArtifacts.isEmpty()) {
-                throw new BabelArtifactParsingException("Could not parse generated XML: " + xmlArtifact.getPayload());
-            }
-
-            modelArtifacts.addAll(parsedArtifacts);
+    public List<Artifact> convertToModel(BabelArtifact babelArtifact) throws BabelArtifactParsingException {
+        Objects.requireNonNull(babelArtifact);
+        List<Artifact> parsedArtifacts = modelArtifactParser.parse(babelArtifact.getPayload(), babelArtifact.getName());
+        
+        if (parsedArtifacts == null || parsedArtifacts.isEmpty()) {
+            throw new BabelArtifactParsingException("Could not parse generated XML: " + babelArtifact.getPayload());
         }
 
-        return modelArtifacts;
+        return parsedArtifacts;
     }
 
     /**
@@ -72,14 +68,7 @@ public class BabelArtifactConverter {
      * @param xmlArtifacts xml artifacts to be parsed
      * @return List<org.openecomp.modelloader.entity.Artifact> list of converted catalog artifacts
      */
-    public List<Artifact> convertToCatalog(List<BabelArtifact> xmlArtifacts) {
-        Objects.requireNonNull(xmlArtifacts);
-        List<Artifact> catalogArtifacts = new ArrayList<>();
-
-        for (BabelArtifact xmlArtifact : xmlArtifacts) {
-            catalogArtifacts.add(new VnfCatalogArtifact(xmlArtifact.getPayload()));
-        }
-
-        return catalogArtifacts;
+    public Artifact convertToCatalog(BabelArtifact babelArtifact) {
+        return new VnfCatalogArtifact(babelArtifact.getPayload());
     }
-}
+}
\ No newline at end of file
index 754eaff..6993948 100644 (file)
@@ -27,6 +27,7 @@ import org.onap.aai.cl.api.Logger;
 import org.onap.aai.cl.eelf.LoggerFactory;
 import org.onap.aai.cl.mdc.MdcContext;
 import org.onap.aai.modelloader.entity.Artifact;
+import org.onap.aai.modelloader.entity.ArtifactType;
 import org.onap.aai.modelloader.extraction.ArtifactInfoExtractor;
 import org.onap.aai.modelloader.service.ArtifactDeploymentManager;
 import org.onap.aai.modelloader.service.ModelLoaderMsgs;
@@ -60,14 +61,29 @@ public class EventCallback implements INotificationCallback {
         logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Received distribution " + data.getDistributionID());
 
         List<IArtifactInfo> artifacts = new ArtifactInfoExtractor().extract(data);
+        boolean success = true;
+        List<Artifact> downloadedArtifacts = new ArrayList<>();
+        try {
+            downloadedArtifacts =
+                    artifactDownloadManager.downloadArtifacts(data, artifacts);
+        } catch (Exception e) {
+            success = false;
+        }
+
         List<Artifact> catalogArtifacts = new ArrayList<>();
         List<Artifact> modelArtifacts = new ArrayList<>();
-
-        boolean success =
-                artifactDownloadManager.downloadArtifacts(data, artifacts, modelArtifacts, catalogArtifacts);
+        if(downloadedArtifacts != null) {
+            for(Artifact artifact : downloadedArtifacts) {
+                if(artifact.getType() == ArtifactType.VNF_CATALOG || artifact.getType() == ArtifactType.VNF_CATALOG_XML) {
+                    catalogArtifacts.add(artifact);
+                } else {
+                    modelArtifacts.add(artifact);
+                }
+            }
+        }
 
         if (success) {
-            success = artifactDeploymentManager.deploy(data, modelArtifacts, catalogArtifacts);
+            success = artifactDeploymentManager.deploy(data.getDistributionID(), modelArtifacts, catalogArtifacts);
         }
 
         String statusString = success ? "SUCCESS" : "FAILURE";
index 474fcc6..63bd7e9 100644 (file)
@@ -57,8 +57,8 @@ public class BabelServiceClientImpl implements BabelServiceClient {
 
     @Override
     public List<BabelArtifact> postArtifact(BabelRequest babelRequest, String transactionId) throws BabelServiceClientException {
-        if (logger.isInfoEnabled()) {
-            logger.info(ModelLoaderMsgs.BABEL_REST_REQUEST_PAYLOAD, " Artifact Name: " + babelRequest.getArtifactName()
+        if (logger.isDebugEnabled()) {
+            logger.debug(ModelLoaderMsgs.BABEL_REST_REQUEST_PAYLOAD, " Artifact Name: " + babelRequest.getArtifactName()
                     + " Artifact version: " + babelRequest.getArtifactVersion() + " Artifact payload: " + babelRequest.getCsar());
         }
 
index 222ae34..e4535be 100644 (file)
@@ -22,11 +22,11 @@ package org.onap.aai.modelloader.service;
 
 import java.util.ArrayList;
 import java.util.List;
+
 import org.onap.aai.modelloader.entity.Artifact;
 import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifactHandler;
 import org.onap.aai.modelloader.entity.model.ModelArtifactHandler;
 import org.onap.aai.modelloader.restclient.AaiRestClient;
-import org.onap.sdc.api.notification.INotificationData;
 import org.springframework.stereotype.Component;
 
 /**
@@ -48,17 +48,15 @@ public class ArtifactDeploymentManager {
     /**
      * Deploys model and catalog artifacts to A&AI.
      *
-     * @param data data about the notification that is being processed
+     * @param distributionId data about the notification that is being processed
      * @param modelArtifacts collection of artifacts that represent yml files found in a TOSCA_CSAR file that have been
      *        converted to XML and also those for model query specs
      * @param catalogArtifacts collection of artifacts that represent vnf catalog files
      * @return boolean <code>true</code> if all deployments were successful otherwise <code>false</code>
      */
-    public boolean deploy(final INotificationData data, final List<Artifact> modelArtifacts,
+    public boolean deploy(final String distributionId, final List<Artifact> modelArtifacts,
             final List<Artifact> catalogArtifacts) {
 
-        String distributionId = data.getDistributionID();
-
         List<Artifact> completedArtifacts = new ArrayList<>();
         boolean deploySuccess =
                 modelArtifactHandler.pushArtifacts(modelArtifacts, distributionId, completedArtifacts, aaiClient);
@@ -77,4 +75,4 @@ public class ArtifactDeploymentManager {
 
         return deploySuccess;
     }
-}
+}
\ No newline at end of file
diff --git a/src/main/java/org/onap/aai/modelloader/service/BabelServiceClientFactory.java b/src/main/java/org/onap/aai/modelloader/service/BabelServiceClientFactory.java
deleted file mode 100644 (file)
index ce690c5..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 European Software Marketing Ltd.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.aai.modelloader.service;
-
-import org.onap.aai.modelloader.config.ModelLoaderConfig;
-import org.onap.aai.modelloader.restclient.BabelServiceClient;
-import org.onap.aai.modelloader.restclient.BabelServiceClientException;
-
-public interface BabelServiceClientFactory {
-    public BabelServiceClient create(ModelLoaderConfig config) throws BabelServiceClientException;
-}
index 41a7c86..233f2ab 100644 (file)
@@ -25,19 +25,22 @@ import java.util.ArrayList;
 import java.util.Base64;
 import java.util.List;
 
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
 import org.onap.aai.cl.api.Logger;
 import org.onap.aai.cl.eelf.LoggerFactory;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
 import org.onap.aai.modelloader.entity.Artifact;
+import org.onap.aai.modelloader.entity.ArtifactType;
 import org.onap.aai.modelloader.notification.ArtifactDownloadManager;
 import org.onap.aai.modelloader.notification.NotificationDataImpl;
 import org.onap.aai.modelloader.notification.NotificationPublisher;
 import org.onap.sdc.api.IDistributionClient;
 import org.onap.sdc.api.notification.IArtifactInfo;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -47,7 +50,7 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("/services/model-loader/v1/model-service")
-public class ModelController implements ModelLoaderInterface {
+public class ModelController {
 
     private static final Logger logger = LoggerFactory.getInstance().getLogger(ModelController.class);
 
@@ -63,47 +66,37 @@ public class ModelController implements ModelLoaderInterface {
         this.artifactDownloadManager = artifactDownloadManager;
     }
 
-    /**
-     * (non-Javadoc)
-     *
-     * @see org.onap.aai.modelloader.service.ModelLoaderInterface#loadModel(java.lang.String)
-     */
-    @Override
-    public Response loadModel(@PathVariable String modelid) {
-        return Response.ok("{\"model_loaded\":\"" + modelid + "\"}").build();
+    @GetMapping(value = "/loadModel/{modelid}", produces = "application/json")
+    public ResponseEntity<String> loadModel(@PathVariable String modelid) {
+        return ResponseEntity.ok("{\"model_loaded\":\"" + modelid + "\"}");
     }
 
-    /**
-     * (non-Javadoc)
-     *
-     * @see org.onap.aai.modelloader.service.ModelLoaderInterface#saveModel(java.lang.String, java.lang.String)
-     */
-    @Override
-    public Response saveModel(@PathVariable String modelid, @PathVariable String modelname) {
-        return Response.ok("{\"model_saved\":\"" + modelid + "-" + modelname + "\"}").build();
+    @PutMapping(value = "/saveModel/{modelid}/{modelname}", produces = "application/json")
+    public ResponseEntity<String> saveModel(@PathVariable String modelid, @PathVariable String modelname) {
+        return ResponseEntity.ok("{\"model_saved\":\"" + modelid + "-" + modelname + "\"}");
     }
 
-    @Override
-    public Response ingestModel(@PathVariable String modelName, @PathVariable String modelVersion,
+    @PostMapping(value = "/ingestModel/{modelName}/{modelVersion}", produces = "application/json")
+    public ResponseEntity<String> ingestModel(@PathVariable String modelName, @PathVariable String modelVersion,
             @RequestBody String payload) throws IOException {
-        Response response;
+        ResponseEntity<String> response;
 
         if (config.getIngestSimulatorEnabled()) {
             response = processTestArtifact(modelName, modelVersion, payload);
         } else {
             logger.debug("Simulation interface disabled");
-            response = Response.serverError().build();
+            response = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
         }
 
         return response;
     }
 
-    private Response processTestArtifact(String modelName, String modelVersion, String payload) {
+    private ResponseEntity<String> processTestArtifact(String modelName, String modelVersion, String payload) {
         IArtifactInfo artifactInfo = new ArtifactInfoImpl();
         ((ArtifactInfoImpl) artifactInfo).setArtifactName(modelName);
         ((ArtifactInfoImpl) artifactInfo).setArtifactVersion(modelVersion);
 
-        Response response;
+        ResponseEntity<String> response;
         try {
             logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Received test artifact " + modelName + " " + modelVersion);
 
@@ -111,11 +104,16 @@ public class ModelController implements ModelLoaderInterface {
 
             logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Generating XML models from test artifact");
 
+            List<Artifact> artifacts = artifactDownloadManager.processToscaArtifacts(csarFile, artifactInfo, "test-transaction-id", modelVersion);
             List<Artifact> modelArtifacts = new ArrayList<>();
             List<Artifact> catalogArtifacts = new ArrayList<>();
-
-            artifactDownloadManager.processToscaArtifacts(modelArtifacts,
-                    catalogArtifacts, csarFile, artifactInfo, "test-transaction-id", modelVersion);
+            for(Artifact artifact : artifacts) {
+                if(artifact.getType().equals(ArtifactType.MODEL)) {
+                    modelArtifacts.add(artifact);
+                } else {
+                    catalogArtifacts.add(artifact);
+                }
+            }
 
             logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Loading xml models from test artifacts: "
                     + modelArtifacts.size() + " model(s) and " + catalogArtifacts.size() + " catalog(s)");
@@ -123,9 +121,9 @@ public class ModelController implements ModelLoaderInterface {
             NotificationDataImpl notificationData = new NotificationDataImpl();
             notificationData.setDistributionID("TestDistributionID");
             boolean success =
-                    artifactDeploymentManager.deploy(notificationData, modelArtifacts, catalogArtifacts);
+                    artifactDeploymentManager.deploy(notificationData.getDistributionID(), modelArtifacts, catalogArtifacts);
             logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Deployment success was " + success);
-            response = success ? Response.ok().build() : Response.serverError().build();
+            response = success ? ResponseEntity.ok().build() : ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
         } catch (Exception e) {
             String responseMessage = e.getMessage();
             logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Exception handled: " + responseMessage);
@@ -135,7 +133,7 @@ public class ModelController implements ModelLoaderInterface {
             } else {
                 responseMessage += "\nSDC publishing is enabled but has been bypassed";
             }
-            response = Response.serverError().entity(responseMessage).type(MediaType.APPLICATION_XML).build();
+            response = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseMessage);
         }
         return response;
     }
diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java
deleted file mode 100644 (file)
index 4c7b182..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 European Software Marketing Ltd.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.modelloader.service;
-
-import java.io.IOException;
-import javax.ws.rs.core.Response;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-public interface ModelLoaderInterface {
-
-    @GetMapping(value = "/loadModel/{modelid}", produces = "application/json")
-    @ResponseBody
-    Response loadModel(String modelid);
-
-    @PutMapping(value = "/saveModel/{modelid}/{modelname}", produces = "application/json")
-    @ResponseBody
-    Response saveModel(String modelid, String modelname);
-
-    @PostMapping(value = "/ingestModel/{modelName}/{modelVersion}", produces = "application/json")
-    @ResponseBody
-    Response ingestModel(String modelid, String modelVersion, String payload) throws IOException;
-}
index b16c8a0..7a630b5 100644 (file)
@@ -22,7 +22,6 @@ package org.onap.aai.modelloader.entity.model;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
index eb31688..f1bbd31 100644 (file)
@@ -28,15 +28,16 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.DistributionClientTestConfiguration;
 import org.onap.aai.modelloader.entity.Artifact;
 import org.onap.aai.modelloader.entity.ArtifactType;
+import org.onap.aai.modelloader.entity.model.ModelArtifact;
 import org.onap.aai.modelloader.service.ArtifactInfoImpl;
 import org.onap.sdc.api.notification.IArtifactInfo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -47,8 +48,6 @@ import org.springframework.http.MediaType;
 import org.springframework.kafka.test.context.EmbeddedKafka;
 import org.springframework.test.annotation.DirtiesContext;
 
-import com.fasterxml.jackson.core.JsonProcessingException;
-
 @DirtiesContext
 @AutoConfigureWireMock(port = 0)
 @EmbeddedKafka(partitions = 1, ports = 9092, topics = {"${topics.distribution.notification}"})
@@ -59,7 +58,7 @@ public class ArtifactDownloadManagerTest {
   @Autowired ArtifactDownloadManager artifactDownloadManager;
 
   @Test
-  public void downloadArtifacts() throws JsonProcessingException {
+  public void downloadArtifacts() throws Exception {
     NotificationDataImpl notificationData = new NotificationDataImpl();
     notificationData.setDistributionID("distributionID");
     notificationData.setServiceVersion("2.0");
@@ -94,13 +93,16 @@ public class ArtifactDownloadManagerTest {
     artifactInfo.setArtifactUUID("f6f907f1-3f45-4fb4-8cbe-15a4c6ee16db");
     List<IArtifactInfo> artifacts = new ArrayList<>();
     artifacts.add(artifactInfo);
-    List<Artifact> modelArtifacts = new ArrayList<>(); // processed artifacts will be written to this list
-    List<Artifact> catalogArtifacts = new ArrayList<>(); // processed artifacts will be written to this list
-    boolean result = artifactDownloadManager.downloadArtifacts(notificationData, artifacts, modelArtifacts, catalogArtifacts);
+    List<Artifact> result = artifactDownloadManager.downloadArtifacts(notificationData, artifacts);
     
-    assertEquals(1, modelArtifacts.size());
-    assertEquals(ArtifactType.MODEL, modelArtifacts.get(0).getType());
-    assertTrue(result);
+    assertEquals(1, result.size());
+    ModelArtifact modelArtifact = (ModelArtifact) result.get(0);
+    assertEquals(ArtifactType.MODEL, modelArtifact.getType());
+    assertEquals("3c8bc8e7-e387-46ed-8616-70e99e2206dc", modelArtifact.getModelInvariantId());
+    assertEquals("http://org.onap.aai.inventory/v28", modelArtifact.getModelNamespace());
+    assertEquals("v28", modelArtifact.getModelNamespaceVersion());
+    assertEquals("71f47717-b100-4eac-940b-7d4e86a4cbb7", modelArtifact.getModelVerId());
+    assertEquals(Set.of("82194af1-3c2c-485a-8f44-420e22a9eaa4|46b92144-923a-4d20-b85a-3cbd847668a9"), modelArtifact.getDependentModelIds());
   }
 
 }
index a64c00c..acd250b 100644 (file)
@@ -20,9 +20,8 @@
  */
 package org.onap.aai.modelloader.notification;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.when;
@@ -32,6 +31,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+import java.util.stream.Collectors;
 
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -50,7 +50,6 @@ import org.onap.aai.modelloader.extraction.InvalidArchiveException;
 import org.onap.aai.modelloader.extraction.VnfCatalogExtractor;
 import org.onap.aai.modelloader.restclient.BabelServiceClient;
 import org.onap.aai.modelloader.restclient.BabelServiceClientException;
-import org.onap.aai.modelloader.service.BabelServiceClientFactory;
 import org.onap.aai.modelloader.util.ArtifactTestUtils;
 import org.onap.sdc.api.IDistributionClient;
 import org.onap.sdc.api.notification.IArtifactInfo;
@@ -69,14 +68,12 @@ public class ArtifactDownloadManagerVnfcTest {
     @Mock private IDistributionClient mockDistributionClient;
     @Mock private NotificationPublisher mockNotificationPublisher;
     @Mock private BabelArtifactConverter mockBabelArtifactConverter;
-    @Mock private BabelServiceClientFactory mockClientFactory;
     @Mock private VnfCatalogExtractor mockVnfCatalogExtractor;
     @InjectMocks private BabelArtifactService babelArtifactService;
 
     @BeforeEach
     public void setup() throws Exception {
         MockitoAnnotations.openMocks(this);
-        when(mockClientFactory.create(Mockito.any())).thenReturn(mockBabelClient);
 
         Properties configProperties = new Properties();
         configProperties.load(this.getClass().getClassLoader().getResourceAsStream("model-loader.properties"));
@@ -86,7 +83,7 @@ public class ArtifactDownloadManagerVnfcTest {
 
     @Test
     public void downloadArtifacts_validToscaVnfcCsarFile()
-            throws IOException, BabelServiceClientException, BabelArtifactParsingException, InvalidArchiveException {
+            throws Exception {
         INotificationData data = getNotificationDataWithToscaCsarFile();
         IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
 
@@ -94,17 +91,20 @@ public class ArtifactDownloadManagerVnfcTest {
         when(mockBabelClient.postArtifact(any(), any())).thenReturn(createBabelArtifacts());
         when(mockVnfCatalogExtractor.extract(any(), any())).thenReturn(new ArrayList<>());
 
-        List<Artifact> modelArtifacts = new ArrayList<>();
-        List<Artifact> catalogFiles = new ArrayList<>();
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, catalogFiles),
-                is(true));
-
-        assertEquals(2, catalogFiles.size(), "There should have been some catalog files");
+        List<Artifact> artifacts = downloadManager.downloadArtifacts(data, data.getServiceArtifacts());
+        List<Artifact> catalogArtifacts = artifacts.stream()
+                .filter(VnfCatalogArtifact.class::isInstance)
+                .collect(Collectors.toList());
+        List<Artifact> modelArtifacts = artifacts.stream()
+                .filter(ModelArtifact.class::isInstance)
+                .collect(Collectors.toList());
+        assertEquals(1, catalogArtifacts.size(), "There should be a catalog artifact");
+        assertEquals(1, modelArtifacts.size(), "There should be a model artifact");
     }
 
     @Test
     public void downloadArtifacts_validXmlVnfcCsarFile()
-            throws IOException, BabelServiceClientException, BabelArtifactParsingException, InvalidArchiveException {
+            throws Exception {
         INotificationData data = getNotificationDataWithToscaCsarFile();
         IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
 
@@ -112,17 +112,21 @@ public class ArtifactDownloadManagerVnfcTest {
         when(mockBabelClient.postArtifact(any(), any())).thenReturn(createBabelArtifactsNoVnfc());
         when(mockVnfCatalogExtractor.extract(any(), any())).thenReturn(createXmlVnfcArtifacts());
 
-        List<Artifact> modelArtifacts = new ArrayList<>();
-        List<Artifact> catalogFiles = new ArrayList<>();
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, catalogFiles),
-                is(true));
+        List<Artifact> artifacts = downloadManager.downloadArtifacts(data, data.getServiceArtifacts());
 
-        assertEquals(3, catalogFiles.size(), "There should have been some catalog files");
+        List<Artifact> catalogArtifacts = artifacts.stream()
+                .filter(VnfCatalogArtifact.class::isInstance)
+                .collect(Collectors.toList());
+        List<Artifact> modelArtifacts = artifacts.stream()
+                .filter(ModelArtifact.class::isInstance)
+                .collect(Collectors.toList());
+        assertEquals(3, catalogArtifacts.size(), "There should be three catalog artifacts");
+        assertEquals(1, modelArtifacts.size(), "There should be a model artifact");
     }
 
     @Test
     public void downloadArtifacts_validNoVnfcCsarFile()
-            throws IOException, BabelServiceClientException, BabelArtifactParsingException, InvalidArchiveException {
+            throws Exception {
         INotificationData data = getNotificationDataWithToscaCsarFile();
         IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
 
@@ -130,17 +134,17 @@ public class ArtifactDownloadManagerVnfcTest {
         when(mockBabelClient.postArtifact(any(), any())).thenReturn(createBabelArtifactsNoVnfc());
         when(mockVnfCatalogExtractor.extract(any(), any())).thenReturn(new ArrayList<>());
 
-        List<Artifact> modelArtifacts = new ArrayList<>();
-        List<Artifact> catalogFiles = new ArrayList<>();
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, catalogFiles),
-                is(true));
+        List<Artifact> artifacts = downloadManager.downloadArtifacts(data, data.getServiceArtifacts());
+        List<Artifact> catalogArtifacts = artifacts.stream()
+                .filter(VnfCatalogArtifact.class::isInstance)
+                .collect(Collectors.toList());
 
-        assertEquals(0, catalogFiles.size(), "There should not have been any catalog files");
+        assertEquals(0, catalogArtifacts.size(), "There should not have been any catalog files");
     }
 
     @Test
     public void downloadArtifacts_invalidXmlAndToscaVnfcCsarFile()
-            throws IOException, BabelServiceClientException, BabelArtifactParsingException, InvalidArchiveException {
+            throws Exception {
         INotificationData data = getNotificationDataWithToscaCsarFile();
         IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
 
@@ -149,10 +153,8 @@ public class ArtifactDownloadManagerVnfcTest {
         when(mockVnfCatalogExtractor.extract(any(), any())).thenReturn(createXmlVnfcArtifacts());
         doNothing().when(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifactInfo);
 
-        List<Artifact> modelArtifacts = new ArrayList<>();
-        List<Artifact> catalogFiles = new ArrayList<>();
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, catalogFiles),
-                is(false));
+        InvalidArchiveException invalidArchiveException = assertThrows(InvalidArchiveException.class,
+                () -> downloadManager.downloadArtifacts(data, data.getServiceArtifacts()));
 
         Mockito.verify(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifactInfo);
     }
@@ -171,8 +173,8 @@ public class ArtifactDownloadManagerVnfcTest {
         when(mockDistributionClient.download(artifactInfo))
                 .thenReturn(createDistributionClientDownloadResult(DistributionActionResultEnum.SUCCESS, null,
                         new ArtifactTestUtils().loadResource("compressedArtifacts/service-VscpaasTest-csar.csar")));
-        when(mockBabelArtifactConverter.convertToModel(Mockito.anyList())).thenReturn(createModelArtifacts());
-        when(mockBabelArtifactConverter.convertToCatalog(Mockito.anyList())).thenReturn(createToscaVnfcArtifacts());
+        when(mockBabelArtifactConverter.convertToModel(Mockito.any(BabelArtifact.class))).thenReturn(createModelArtifacts());
+        when(mockBabelArtifactConverter.convertToCatalog(Mockito.any(BabelArtifact.class))).thenReturn(new VnfCatalogArtifact("Some VNFC payload"));
     }
 
     private List<BabelArtifact> createBabelArtifacts() {
@@ -191,17 +193,9 @@ public class ArtifactDownloadManagerVnfcTest {
     private List<Artifact> createModelArtifacts() {
         List<Artifact> modelArtifacts = new ArrayList<>();
         modelArtifacts.add(new ModelArtifact());
-        modelArtifacts.add(new ModelArtifact());
         return modelArtifacts;
     }
 
-    private List<Artifact> createToscaVnfcArtifacts() {
-        List<Artifact> vnfcArtifacts = new ArrayList<>();
-        vnfcArtifacts.add(new VnfCatalogArtifact("Some VNFC payload"));
-        vnfcArtifacts.add(new VnfCatalogArtifact("Some VNFC payload"));
-        return vnfcArtifacts;
-    }
-
     private List<Artifact> createXmlVnfcArtifacts() {
         List<Artifact> vnfcArtifacts = new ArrayList<>();
         vnfcArtifacts.add(new VnfCatalogArtifact(ArtifactType.VNF_CATALOG_XML, "Some VNFC payload"));
index 618a268..2ff4ed5 100644 (file)
@@ -46,6 +46,7 @@ import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifact;
 import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifactHandler;
 import org.onap.aai.modelloader.entity.model.BabelArtifactParsingException;
 import org.onap.aai.modelloader.entity.model.ModelArtifactHandler;
+import org.onap.aai.modelloader.entity.model.ModelArtifactParser;
 import org.onap.aai.modelloader.extraction.InvalidArchiveException;
 import org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder;
 import org.onap.aai.modelloader.restclient.AaiRestClient;
@@ -91,13 +92,13 @@ public class TestArtifactDeploymentManager {
     public void deploy_csarDeploymentsFailed() throws IOException, BabelArtifactParsingException {
         INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile();
         byte[] xml = new ArtifactTestUtils().loadResource("convertedYmls/AAI-SCP-Test-VSP-resource-1.0.xml");
-        List<BabelArtifact> toscaArtifacts = setupTest(xml, data);
-        List<Artifact> modelArtifacts = new BabelArtifactConverter().convertToModel(toscaArtifacts);
+        BabelArtifact toscaArtifact = setupTest(xml, data);
+        List<Artifact> modelArtifacts = new BabelArtifactConverter(new ModelArtifactParser()).convertToModel(toscaArtifact);
 
         when(modelArtifactHandlerMock.pushArtifacts(eq(modelArtifacts), eq(data.getDistributionID()), any(), any()))
                 .thenReturn(false);
 
-        assertThat(SHOULD_HAVE_RETURNED_FALSE, manager.deploy(data, modelArtifacts, new ArrayList<>()), is(false));
+        assertThat(SHOULD_HAVE_RETURNED_FALSE, manager.deploy(data.getDistributionID(), modelArtifacts, new ArrayList<>()), is(false));
 
         Mockito.verify(modelArtifactHandlerMock).pushArtifacts(eq(modelArtifacts), eq(data.getDistributionID()), any(),
                 any());
@@ -109,15 +110,13 @@ public class TestArtifactDeploymentManager {
                 eq(data.getDistributionID()), any());
     }
 
-    private List<BabelArtifact> setupTest(byte[] xml, INotificationData data) throws IOException {
-        List<BabelArtifact> toscaArtifacts = new ArrayList<>();
+    private BabelArtifact setupTest(byte[] xml, INotificationData data) throws IOException {
         org.onap.sdc.api.notification.IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
 
         BabelArtifact xmlArtifact =
                 new BabelArtifact(artifactInfo.getArtifactName(), BabelArtifact.ArtifactType.MODEL, new String(xml));
-        toscaArtifacts.add(xmlArtifact);
 
-        return toscaArtifacts;
+        return xmlArtifact;
     }
 
     @Test
@@ -132,7 +131,7 @@ public class TestArtifactDeploymentManager {
         when(vnfCatalogArtifactHandlerMock.pushArtifacts(eq(catalogFiles), eq(data.getDistributionID()), any(), any()))
                 .thenReturn(false);
 
-        assertThat(SHOULD_HAVE_RETURNED_FALSE, manager.deploy(data, new ArrayList<>(), catalogFiles), is(false));
+        assertThat(SHOULD_HAVE_RETURNED_FALSE, manager.deploy(data.getDistributionID(), new ArrayList<>(), catalogFiles), is(false));
 
         Mockito.verify(modelArtifactHandlerMock).pushArtifacts(eq(new ArrayList<Artifact>()),
                 eq(data.getDistributionID()), any(), any());
@@ -163,8 +162,8 @@ public class TestArtifactDeploymentManager {
             throws IOException, BabelArtifactParsingException, InvalidArchiveException {
         INotificationData data = getNotificationDataWithOneOfEach();
         byte[] xml = new ArtifactTestUtils().loadResource("convertedYmls/AAI-SCP-Test-VSP-resource-1.0.xml");
-        List<BabelArtifact> toscaArtifacts = setupTest(xml, data);
-        List<Artifact> modelArtifacts = new BabelArtifactConverter().convertToModel(toscaArtifacts);
+        BabelArtifact toscaArtifact = setupTest(xml, data);
+        List<Artifact> modelArtifacts = new BabelArtifactConverter(new ModelArtifactParser()).convertToModel(toscaArtifact);
 
         List<org.onap.aai.modelloader.entity.Artifact> catalogFiles = new ArrayList<>();
         catalogFiles.add(new VnfCatalogArtifact("Some catalog content"));
@@ -174,7 +173,7 @@ public class TestArtifactDeploymentManager {
         when(modelArtifactHandlerMock.pushArtifacts(eq(modelArtifacts), eq(data.getDistributionID()), any(), any()))
                 .thenReturn(modelsDeployed);
 
-        assertThat(SHOULD_HAVE_RETURNED_FALSE, manager.deploy(data, modelArtifacts, catalogFiles), is(false));
+        assertThat(SHOULD_HAVE_RETURNED_FALSE, manager.deploy(data.getDistributionID(), modelArtifacts, catalogFiles), is(false));
 
         // Catalog artifacts are only pushed if models are successful.
         Mockito.verify(modelArtifactHandlerMock).pushArtifacts(eq(modelArtifacts), eq(data.getDistributionID()), any(),
@@ -212,8 +211,8 @@ public class TestArtifactDeploymentManager {
     public void testDeploySuccess() throws IOException, BabelArtifactParsingException, InvalidArchiveException {
         INotificationData data = getNotificationDataWithOneOfEach();
         byte[] xml = new ArtifactTestUtils().loadResource("convertedYmls/AAI-SCP-Test-VSP-resource-1.0.xml");
-        List<BabelArtifact> toscaArtifacts = setupTest(xml, data);
-        List<Artifact> modelArtifacts = new BabelArtifactConverter().convertToModel(toscaArtifacts);
+        BabelArtifact toscaArtifact = setupTest(xml, data);
+        List<Artifact> modelArtifacts = new BabelArtifactConverter(new ModelArtifactParser()).convertToModel(toscaArtifact);
 
         List<org.onap.aai.modelloader.entity.Artifact> catalogFiles = new ArrayList<>();
         catalogFiles.add(new VnfCatalogArtifact("Some catalog content"));
@@ -223,7 +222,7 @@ public class TestArtifactDeploymentManager {
         when(modelArtifactHandlerMock.pushArtifacts(eq(modelArtifacts), eq(data.getDistributionID()), any(), any()))
                 .thenReturn(true);
 
-        assertThat(manager.deploy(data, modelArtifacts, catalogFiles), is(true));
+        assertThat(manager.deploy(data.getDistributionID(), modelArtifacts, catalogFiles), is(true));
 
         Mockito.verify(vnfCatalogArtifactHandlerMock).pushArtifacts(eq(catalogFiles), eq(data.getDistributionID()),
                 any(), any());
index 27d0aa9..79eb94d 100644 (file)
 package org.onap.aai.modelloader.notification;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsEmptyCollection.empty;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyList;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.when;
 import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.getNotificationDataWithInvalidType;
@@ -38,8 +37,8 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+import java.util.stream.Collectors;
 
-import org.hamcrest.collection.IsEmptyCollection;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -50,11 +49,14 @@ import org.mockito.MockitoAnnotations;
 import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.modelloader.babel.BabelArtifactService;
 import org.onap.aai.modelloader.entity.Artifact;
+import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifact;
 import org.onap.aai.modelloader.entity.model.BabelArtifactParsingException;
+import org.onap.aai.modelloader.entity.model.ModelArtifact;
+import org.onap.aai.modelloader.entity.model.NamedQueryArtifact;
+import org.onap.aai.modelloader.extraction.InvalidArchiveException;
 import org.onap.aai.modelloader.extraction.VnfCatalogExtractor;
 import org.onap.aai.modelloader.restclient.BabelServiceClient;
 import org.onap.aai.modelloader.restclient.BabelServiceClientException;
-import org.onap.aai.modelloader.service.BabelServiceClientFactory;
 import org.onap.aai.modelloader.util.ArtifactTestUtils;
 import org.onap.sdc.api.IDistributionClient;
 import org.onap.sdc.api.notification.IArtifactInfo;
@@ -73,7 +75,6 @@ public class TestArtifactDownloadManager {
     @Mock private IDistributionClient mockDistributionClient;
     @Mock private NotificationPublisher mockNotificationPublisher;
     @Mock private BabelArtifactConverter mockBabelArtifactConverter;
-    @Mock private BabelServiceClientFactory mockClientFactory;
     @InjectMocks BabelArtifactService babelArtifactService;
     private VnfCatalogExtractor vnfCatalogExtractor;
 
@@ -81,7 +82,6 @@ public class TestArtifactDownloadManager {
     public void setup() throws Exception {
         MockitoAnnotations.openMocks(this);
         vnfCatalogExtractor = new VnfCatalogExtractor();
-        when(mockClientFactory.create(any())).thenReturn(mockBabelClient);
 
         Properties configProperties = new Properties();
         configProperties.load(this.getClass().getClassLoader().getResourceAsStream("model-loader.properties"));
@@ -98,15 +98,12 @@ public class TestArtifactDownloadManager {
 
     /**
      * Test downloading zero artifacts from SDC.
+ * @throws Exception 
      */
     @Test
-    public void testDownloadWithZeroArtifacts() {
-        List<Artifact> modelFiles = new ArrayList<>();
-        List<Artifact> catalogFiles = new ArrayList<>();
-        assertThat(downloadManager.downloadArtifacts(getNotificationDataWithOneService(), new ArrayList<>(), modelFiles,
-                catalogFiles), is(true));
-        assertThat(modelFiles, is(empty()));
-        assertThat(catalogFiles, is(empty()));
+    public void testDownloadWithZeroArtifacts() throws Exception {
+        List<Artifact> artifacts = downloadManager.downloadArtifacts(getNotificationDataWithOneService(), new ArrayList<>());
+        assertThat(artifacts, is(empty()));
         Mockito.verifyNoInteractions(mockBabelClient, mockDistributionClient, mockNotificationPublisher,
                 mockBabelArtifactConverter);
     }
@@ -121,7 +118,8 @@ public class TestArtifactDownloadManager {
         doNothing().when(mockNotificationPublisher).publishDownloadFailure(mockDistributionClient, data, artifact,
                 errorMessage);
 
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), null, null), is(false));
+        assertThrows(DownloadFailureException.class,
+                () -> downloadManager.downloadArtifacts(data, data.getServiceArtifacts()));
 
         Mockito.verify(mockDistributionClient).download(artifact);
         Mockito.verify(mockNotificationPublisher).publishDownloadFailure(mockDistributionClient, data, artifact,
@@ -130,22 +128,6 @@ public class TestArtifactDownloadManager {
         Mockito.verifyNoInteractions(mockBabelClient, mockBabelArtifactConverter);
     }
 
-    @Test
-    public void testErrorCreatingBabelClient() throws Exception {
-        when(mockClientFactory.create(any())).thenThrow(new BabelServiceClientException(new Exception()));
-
-        INotificationData data = getNotificationDataWithToscaCsarFile();
-        IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
-        setupValidDownloadCsarMocks(data, artifactInfo, new ArtifactTestUtils());
-        doNothing().when(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifactInfo);
-
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), null, null), is(false));
-
-        Mockito.verify(mockDistributionClient).download(artifactInfo);
-        Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifactInfo);
-        Mockito.verify(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifactInfo);
-    }
-
     @Test
     public void downloadArtifacts_invalidToscaCsarFile() throws IOException, BabelServiceClientException {
         INotificationData data = getNotificationDataWithToscaCsarFile();
@@ -156,7 +138,8 @@ public class TestArtifactDownloadManager {
         when(mockBabelClient.postArtifact(any(), any())).thenThrow(new BabelServiceClientException(""));
         doNothing().when(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifact);
 
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), null, null), is(false));
+        assertThrows(ProcessToscaArtifactsException.class,
+                () -> downloadManager.downloadArtifacts(data, data.getServiceArtifacts()));
 
         Mockito.verify(mockDistributionClient).download(artifact);
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
@@ -178,8 +161,8 @@ public class TestArtifactDownloadManager {
                 DistributionActionResultEnum.SUCCESS, null, "This is not a valid Model Query Spec".getBytes()));
         doNothing().when(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
 
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, null),
-                is(false));
+        assertThrows(BabelArtifactParsingException.class,
+                () -> downloadManager.downloadArtifacts(data, data.getServiceArtifacts()));
 
         Mockito.verify(mockDistributionClient).download(artifact);
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
@@ -190,17 +173,19 @@ public class TestArtifactDownloadManager {
 
     @Test
     public void downloadArtifacts_validToscaCsarFile()
-            throws IOException, BabelServiceClientException, BabelArtifactParsingException {
+            throws Exception {
         INotificationData data = getNotificationDataWithToscaCsarFile();
         IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
 
         setupValidDownloadCsarMocks(data, artifactInfo, new ArtifactTestUtils());
 
-        List<org.onap.aai.modelloader.entity.Artifact> modelArtifacts = new ArrayList<>();
-        List<org.onap.aai.modelloader.entity.Artifact> catalogFiles = new ArrayList<>();
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, catalogFiles),
-                is(true));
-        assertThat(catalogFiles.size(), is(0));
+        List<Artifact> artifacts = downloadManager.downloadArtifacts(data, data.getServiceArtifacts());
+        List<Artifact> modelArtifacts = artifacts.stream().filter(ModelArtifact.class::isInstance)
+                .collect(Collectors.toList());
+        List<Artifact> catalogArtifacts = artifacts.stream().filter(VnfCatalogArtifact.class::isInstance)
+                .collect(Collectors.toList());
+        assertThat(modelArtifacts.size(), is(1));
+        assertThat(catalogArtifacts.size(), is(1));
 
         Mockito.verify(mockDistributionClient).download(artifactInfo);
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifactInfo);
@@ -210,11 +195,14 @@ public class TestArtifactDownloadManager {
     }
 
     private void setupValidDownloadCsarMocks(INotificationData data, IArtifactInfo artifactInfo,
-            ArtifactTestUtils artifactTestUtils) throws IOException, BabelServiceClientException {
+            ArtifactTestUtils artifactTestUtils) throws IOException, BabelServiceClientException, BabelArtifactParsingException {
         when(mockDistributionClient.download(artifactInfo))
                 .thenReturn(createDistributionClientDownloadResult(DistributionActionResultEnum.SUCCESS, null,
                         artifactTestUtils.loadResource("compressedArtifacts/service-VscpaasTest-csar.csar")));
         when(mockBabelClient.postArtifact(any(), any())).thenReturn(createBabelArtifacts());
+
+        when(mockBabelArtifactConverter.convertToModel(any(BabelArtifact.class))).thenReturn(List.of(new ModelArtifact()));
+        when(mockBabelArtifactConverter.convertToCatalog(any(BabelArtifact.class))).thenReturn(new VnfCatalogArtifact(""));
     }
 
     private List<BabelArtifact> createBabelArtifacts() {
@@ -226,18 +214,19 @@ public class TestArtifactDownloadManager {
 
     @Test
     public void downloadArtifactsWithValidModelQuerySpec()
-            throws IOException, BabelServiceClientException, BabelArtifactParsingException {
+            throws Exception {
         INotificationData data = getNotificationDataWithModelQuerySpec();
         IArtifactInfo artifact = data.getServiceArtifacts().get(0);
         setupValidModelQuerySpecMocks(new ArtifactTestUtils(), data, artifact);
 
-        List<org.onap.aai.modelloader.entity.Artifact> modelFiles = new ArrayList<>();
-        List<org.onap.aai.modelloader.entity.Artifact> catalogFiles = new ArrayList<>();
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelFiles, catalogFiles),
-                is(true));
+        List<Artifact> artifacts = downloadManager.downloadArtifacts(data, data.getServiceArtifacts());
+        List<Artifact> namedQueryArtifacts = artifacts.stream().filter(NamedQueryArtifact.class::isInstance)
+                .collect(Collectors.toList());
+        List<Artifact> catalogArtifacts = artifacts.stream().filter(VnfCatalogArtifact.class::isInstance)
+                .collect(Collectors.toList());
 
-        assertThat(modelFiles, is(not(IsEmptyCollection.empty())));
-        assertThat(catalogFiles, is(empty()));
+        assertThat(namedQueryArtifacts.size(), is(1));
+        assertThat(catalogArtifacts, is(empty()));
 
         Mockito.verify(mockDistributionClient).download(artifact);
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
@@ -255,23 +244,27 @@ public class TestArtifactDownloadManager {
 
     @Test
     public void downloadArtifacts_validCsarAndModelFiles()
-            throws IOException, BabelServiceClientException, BabelArtifactParsingException {
+            throws Exception {
         ArtifactTestUtils artifactTestUtils = new ArtifactTestUtils();
         INotificationData data = getNotificationDataWithOneOfEach();
-        List<IArtifactInfo> artifacts = new ArrayList<>();
+        List<IArtifactInfo> artifactInfos = new ArrayList<>();
 
         IArtifactInfo serviceArtifact = data.getServiceArtifacts().get(0);
         IArtifactInfo modelSpecArtifact = data.getResources().get(1).getArtifacts().get(0);
 
-        artifacts.add(serviceArtifact);
-        artifacts.add(modelSpecArtifact);
+        artifactInfos.add(serviceArtifact);
+        artifactInfos.add(modelSpecArtifact);
 
         setupValidDownloadCsarMocks(data, serviceArtifact, artifactTestUtils);
         setupValidModelQuerySpecMocks(artifactTestUtils, data, modelSpecArtifact);
 
-        List<org.onap.aai.modelloader.entity.Artifact> modelFiles = new ArrayList<>();
-        List<org.onap.aai.modelloader.entity.Artifact> catalogFiles = new ArrayList<>();
-        assertThat(downloadManager.downloadArtifacts(data, artifacts, modelFiles, catalogFiles), is(true));
+        List<Artifact> artifacts = downloadManager.downloadArtifacts(data, artifactInfos);
+        List<Artifact> modelArtifacts = artifacts.stream().filter(artifact -> !(artifact instanceof VnfCatalogArtifact))
+                .collect(Collectors.toList());
+        List<Artifact> catalogArtifacts = artifacts.stream().filter(VnfCatalogArtifact.class::isInstance)
+                .collect(Collectors.toList());
+        assertThat(modelArtifacts.size(), is(2));
+        assertThat(catalogArtifacts.size(), is(1));
 
         Mockito.verify(mockDistributionClient).download(serviceArtifact);
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, serviceArtifact);
@@ -295,15 +288,16 @@ public class TestArtifactDownloadManager {
         when(mockDistributionClient.download(artifactInfo))
                 .thenReturn(createDistributionClientDownloadResult(DistributionActionResultEnum.SUCCESS, null,
                         artifactTestUtils.loadResource("compressedArtifacts/service-VscpaasTest-csar.csar")));
-        when(mockBabelArtifactConverter.convertToModel(anyList()))
+        when(mockBabelArtifactConverter.convertToModel(any()))
                 .thenThrow(BabelArtifactParsingException.class);
         doNothing().when(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifactInfo);
         when(mockBabelClient.postArtifact(any(), any())).thenReturn(createBabelArtifacts());
 
         List<Artifact> modelArtifacts = new ArrayList<>();
         List<Artifact> catalogFiles = new ArrayList<>();
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, catalogFiles),
-                is(false));
+        assertThrows(ProcessToscaArtifactsException.class,
+                () -> downloadManager.downloadArtifacts(data, data.getServiceArtifacts()));
+
         assertThat(modelArtifacts, is(empty()));
         assertThat(catalogFiles, is(empty()));
 
@@ -323,8 +317,9 @@ public class TestArtifactDownloadManager {
                 DistributionActionResultEnum.SUCCESS, null, "This content does not matter.".getBytes()));
         doNothing().when(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
 
-        assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), null, new ArrayList<>()),
-                is(false));
+        assertThrows(InvalidArchiveException.class,
+                () -> downloadManager.downloadArtifacts(data, data.getServiceArtifacts()));
+
         Mockito.verify(mockDistributionClient).download(artifact);
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
         Mockito.verify(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifact);
index 1d81513..aee3dc2 100644 (file)
@@ -22,11 +22,9 @@ package org.onap.aai.modelloader.notification;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.junit.jupiter.api.Test;
@@ -34,6 +32,7 @@ import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.modelloader.entity.Artifact;
 import org.onap.aai.modelloader.entity.ArtifactType;
 import org.onap.aai.modelloader.entity.model.BabelArtifactParsingException;
+import org.onap.aai.modelloader.entity.model.ModelArtifactParser;
 import org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder;
 import org.onap.aai.modelloader.util.ArtifactTestUtils;
 import org.onap.sdc.api.notification.IArtifactInfo;
@@ -47,17 +46,11 @@ public class TestBabelArtifactConverter {
     @Test
     public void convert_nullToscaFiles() throws BabelArtifactParsingException {
         assertThrows(NullPointerException.class, () -> {
-            new BabelArtifactConverter().convertToModel(null);
+            new BabelArtifactConverter(new ModelArtifactParser()).convertToModel(null);
             fail("An instance of ArtifactGenerationException should have been thrown");
         });
     }
 
-    @Test
-    public void testEmptyToscaFiles() throws BabelArtifactParsingException {
-        assertTrue(new BabelArtifactConverter().convertToModel(new ArrayList<>()).isEmpty(),
-                "Nothing should have been returned");
-    }
-
     @Test
     public void testInvalidXml() throws IOException, BabelArtifactParsingException {
         assertThrows(BabelArtifactParsingException.class, () -> {
@@ -67,22 +60,20 @@ public class TestBabelArtifactConverter {
 
             INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile();
 
-            List<BabelArtifact> toscaArtifacts = setupTest(problemXml, data);
+            BabelArtifact toscaArtifact = setupTest(problemXml, data);
 
-            new BabelArtifactConverter().convertToModel(toscaArtifacts);
+            new BabelArtifactConverter(new ModelArtifactParser()).convertToModel(toscaArtifact);
             fail("An instance of ModelArtifactParsingException should have been thrown");
         });
     }
 
-    private List<BabelArtifact> setupTest(byte[] xml, INotificationData data) throws IOException {
-        List<BabelArtifact> toscaArtifacts = new ArrayList<>();
+    private BabelArtifact setupTest(byte[] xml, INotificationData data) throws IOException {
         IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
 
         BabelArtifact xmlArtifact =
                 new BabelArtifact(artifactInfo.getArtifactName(), BabelArtifact.ArtifactType.MODEL, new String(xml));
-        toscaArtifacts.add(xmlArtifact);
 
-        return toscaArtifacts;
+        return xmlArtifact;
     }
 
     @Test
@@ -90,9 +81,9 @@ public class TestBabelArtifactConverter {
         INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile();
 
         byte[] xml = new ArtifactTestUtils().loadResource("convertedYmls/AAI-SCP-Test-VSP-resource-1.0.xml");
-        List<BabelArtifact> toscaArtifacts = setupTest(xml, data);
+        BabelArtifact toscaArtifact = setupTest(xml, data);
 
-        List<Artifact> modelArtifacts = new BabelArtifactConverter().convertToModel(toscaArtifacts);
+        List<Artifact> modelArtifacts = new BabelArtifactConverter(new ModelArtifactParser()).convertToModel(toscaArtifact);
 
         assertEquals(1, modelArtifacts.size(), "There should have been 1 artifact");
         assertEquals(new String(xml), modelArtifacts.get(0).getPayload());
index 1073a61..ef346db 100644 (file)
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
@@ -34,7 +35,6 @@ import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
-import org.onap.aai.modelloader.entity.model.BabelArtifactParsingException;
 import org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder;
 import org.onap.aai.modelloader.service.ArtifactDeploymentManager;
 import org.onap.sdc.api.IDistributionClient;
@@ -75,34 +75,32 @@ public class TestEventCallback {
 
     @Test
     @SuppressWarnings("unchecked")
-    public void activateCallback_downloadFails() {
+    public void activateCallback_downloadFails() throws Exception {
         INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile();
 
-        when(mockArtifactDownloadManager.downloadArtifacts(any(INotificationData.class), any(List.class),
-                any(List.class), any(List.class))).thenReturn(false);
+        when(mockArtifactDownloadManager.downloadArtifacts(any(INotificationData.class), any(List.class)
+                )).thenThrow(DownloadFailureException.class);
 
         eventCallback.activateCallback(data);
 
-        verify(mockArtifactDownloadManager).downloadArtifacts(any(INotificationData.class), any(List.class),
-                any(List.class), any(List.class));
+        verify(mockArtifactDownloadManager).downloadArtifacts(any(INotificationData.class), any(List.class));
         Mockito.verifyNoInteractions(mockArtifactDeploymentManager);
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void activateCallback() throws BabelArtifactParsingException {
+    public void activateCallback() throws Exception {
         INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile();
 
-        when(mockArtifactDownloadManager.downloadArtifacts(any(INotificationData.class), any(List.class),
-                any(List.class), any(List.class))).thenReturn(true);
+        when(mockArtifactDownloadManager.downloadArtifacts(any(INotificationData.class), any(List.class)))
+            .thenReturn(Collections.emptyList());
 
-        when(mockArtifactDeploymentManager.deploy(any(INotificationData.class), any(List.class), any(List.class)))
+        when(mockArtifactDeploymentManager.deploy(any(String.class), any(List.class), any(List.class)))
                 .thenReturn(true);
 
         eventCallback.activateCallback(data);
 
-        verify(mockArtifactDownloadManager).downloadArtifacts(any(INotificationData.class), any(List.class),
-                any(List.class), any(List.class));
-        verify(mockArtifactDeploymentManager).deploy(any(INotificationData.class), any(List.class), any(List.class));
+        verify(mockArtifactDownloadManager).downloadArtifacts(any(INotificationData.class), any(List.class));
+        verify(mockArtifactDeploymentManager).deploy(any(String.class), any(List.class), any(List.class));
     }
 }
diff --git a/src/test/java/org/onap/aai/modelloader/restclient/MockBabelServiceClient.java b/src/test/java/org/onap/aai/modelloader/restclient/MockBabelServiceClient.java
deleted file mode 100644 (file)
index 783ad2e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 European Software Marketing Ltd.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.modelloader.restclient;
-
-import java.util.Collections;
-import java.util.List;
-import org.onap.aai.babel.service.data.BabelArtifact;
-import org.onap.aai.babel.service.data.BabelRequest;
-import org.onap.aai.modelloader.config.ModelLoaderConfig;
-
-/**
- * Mocked Client for interfacing with Babel.
- *
- */
-public class MockBabelServiceClient implements BabelServiceClient {
-
-    public MockBabelServiceClient(ModelLoaderConfig config) throws BabelServiceClientException {}
-
-    @Override
-    public List<BabelArtifact> postArtifact(BabelRequest babelRequest, String transactionId)
-            throws BabelServiceClientException {
-        return Collections.emptyList();
-    }
-}
diff --git a/src/test/java/org/onap/aai/modelloader/service/MockBabelServiceClientFactory.java b/src/test/java/org/onap/aai/modelloader/service/MockBabelServiceClientFactory.java
deleted file mode 100644 (file)
index fa369ce..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 European Software Marketing Ltd.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.modelloader.service;
-
-import org.onap.aai.modelloader.config.ModelLoaderConfig;
-import org.onap.aai.modelloader.restclient.BabelServiceClient;
-import org.onap.aai.modelloader.restclient.BabelServiceClientException;
-import org.onap.aai.modelloader.restclient.MockBabelServiceClient;
-import org.springframework.stereotype.Service;
-
-@Service
-public class MockBabelServiceClientFactory implements BabelServiceClientFactory {
-
-    @Override
-    public BabelServiceClient create(ModelLoaderConfig config) throws BabelServiceClientException {
-        return new MockBabelServiceClient(config);
-    }
-
-}
index 970aa7a..3387b32 100644 (file)
@@ -29,8 +29,6 @@ import java.io.IOException;
 import java.util.Base64;
 import java.util.Collections;
 
-import javax.ws.rs.core.Response;
-
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;
@@ -47,6 +45,8 @@ import org.onap.aai.modelloader.util.ArtifactTestUtils;
 import org.onap.sdc.api.IDistributionClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.test.context.TestPropertySource;
 
 /**
@@ -64,7 +64,6 @@ public class TestModelController {
     @Autowired NotificationPublisher notificationPublisher;
     @Autowired VnfCatalogExtractor vnfCatalogExtractor;
 
-    @Mock BabelServiceClientFactory clientFactory;
     @Mock BabelServiceClient babelServiceClient;
     @InjectMocks BabelArtifactService babelArtifactService;
     
@@ -72,7 +71,6 @@ public class TestModelController {
 
     @BeforeEach
     public void init() throws BabelServiceClientException {
-        when(clientFactory.create(any())).thenReturn(babelServiceClient);
         when(babelServiceClient.postArtifact(any(), any())).thenReturn(Collections.emptyList());
         ArtifactDownloadManager artifactDownloadManager = new ArtifactDownloadManager(iDistributionClient, notificationPublisher, vnfCatalogExtractor, babelArtifactService);
         this.modelController = new ModelController(iDistributionClient, modelLoaderConfig, artifactDeploymentManager, artifactDownloadManager);
@@ -80,28 +78,28 @@ public class TestModelController {
 
     @Test
     public void testLoadModel() {
-        Response response = modelController.loadModel("");
-        assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        ResponseEntity<String> response = modelController.loadModel("");
+        assertThat(response.getStatusCode(), is(HttpStatus.OK));
     }
 
     @Test
     public void testSaveModel() {
-        Response response = modelController.saveModel("", "");
-        assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        ResponseEntity<String> response = modelController.saveModel("", "");
+        assertThat(response.getStatusCode(), is(HttpStatus.OK));
     }
 
     @Test
     public void testIngestModel() throws IOException {
         byte[] csarPayload = new ArtifactTestUtils().loadResource("compressedArtifacts/service-VscpaasTest-csar.csar");
-        Response response = modelController.ingestModel("model-name", "", Base64.getEncoder().encodeToString(csarPayload));
-        assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        ResponseEntity<String> response = modelController.ingestModel("model-name", "", Base64.getEncoder().encodeToString(csarPayload));
+        assertThat(response.getStatusCode(), is(HttpStatus.OK));
     }
 
     @Test
     public void testIngestModelMissingName() throws IOException {
         byte[] csarPayload = new ArtifactTestUtils().loadResource("compressedArtifacts/service-VscpaasTest-csar.csar");
-        Response response = modelController.ingestModel("", "", Base64.getEncoder().encodeToString(csarPayload));
-        assertThat(response.getStatus(), is(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
+        ResponseEntity<String> response = modelController.ingestModel("", "", Base64.getEncoder().encodeToString(csarPayload));
+        assertThat(response.getStatusCode(), is(HttpStatus.INTERNAL_SERVER_ERROR));
     }
 
 }
index 6dc1b3d..5d64dec 100644 (file)
@@ -26,12 +26,13 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import java.io.IOException;
 import java.util.Base64;
 
-import javax.ws.rs.core.Response;
-
 import org.junit.jupiter.api.Test;
+import org.onap.aai.modelloader.config.BeanConfig;
 import org.onap.aai.modelloader.util.ArtifactTestUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.test.context.TestPropertySource;
 
 /**
@@ -48,8 +49,8 @@ public class TestModelLoaderServiceWithSdc {
     @Test
     public void testIngestModel() throws IOException {
         byte[] csarPayload = new ArtifactTestUtils().loadResource("compressedArtifacts/service-VscpaasTest-csar.csar");
-        Response response = controller.ingestModel("model-name", "", Base64.getEncoder().encodeToString(csarPayload));
-        assertThat(response.getStatus(), is(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
+        ResponseEntity<String> response = controller.ingestModel("model-name", "", Base64.getEncoder().encodeToString(csarPayload));
+        assertThat(response.getStatusCode(), is(HttpStatus.INTERNAL_SERVER_ERROR));
     }
 
 
index b2aac49..d035ea2 100644 (file)
@@ -24,8 +24,8 @@
 # because they are used in Jenkins, whose plug-in doesn't support
 
 major=1
-minor=13
-patch=6
+minor=14
+patch=0
 
 base_version=${major}.${minor}.${patch}