Additional tosca method 87/74487/4
authorsebdet <sebastien.determe@intl.att.com>
Tue, 11 Dec 2018 11:43:26 +0000 (12:43 +0100)
committersebdet <sebastien.determe@intl.att.com>
Tue, 11 Dec 2018 14:26:27 +0000 (15:26 +0100)
new tosca method for future code

Issue-ID: CLAMP-252
Change-Id: I1fbd15e8a76ccb7629c800d8c64e2d526bd77554
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
src/main/java/org/onap/clamp/clds/dao/CldsDao.java
src/main/java/org/onap/clamp/clds/service/CldsService.java
src/main/resources/clds/camel/rest/clds-services.xml
src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java
src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java
src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java

index b6e27c5..622b617 100644 (file)
@@ -32,6 +32,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import javax.sql.DataSource;
 
@@ -46,6 +47,8 @@ import org.onap.clamp.clds.model.CldsMonitoringDetails;
 import org.onap.clamp.clds.model.CldsServiceData;
 import org.onap.clamp.clds.model.CldsTemplate;
 import org.onap.clamp.clds.model.CldsToscaModel;
+import org.onap.clamp.clds.model.CldsToscaModelDetails;
+import org.onap.clamp.clds.model.CldsToscaModelRevision;
 import org.onap.clamp.clds.model.ValueItem;
 import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -542,6 +545,58 @@ public class CldsDao {
         return cldsToscaModels;
     }
 
+    // Retrieve Tosca Models & its revisions by policy Type.
+    private List<CldsToscaModelDetails> getAllToscaModelVersion(String toscaModelName, String policyType,
+        String version) {
+        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
+        List<CldsToscaModelDetails> cldsToscaModelDetailsList = new ArrayList<>();
+        String toscaModelSql = "SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, tmr.tosca_model_revision_id, tmr.version, tmr.user_id, tmr.createdTimestamp, tmr.lastUpdatedTimestamp "
+            + "FROM tosca_model tm, tosca_model_revision tmr " + "WHERE tmr.tosca_model_id = tm.tosca_model_id "
+            + ((policyType != null) ? (" AND tm.policy_type = '" + policyType + "'") : " ")
+            + ((toscaModelName != null) ? (" AND tm.tosca_model_name = '" + toscaModelName + "'") : " ")
+            + ((version != null) ? (" AND tmr.version = '" + version + "'") : "");
+
+        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(toscaModelSql);
+
+        if (rows != null && !rows.isEmpty()) {
+            // Get list of all available modelIds
+            List<String> listofModelIds = new ArrayList<>();
+            for (Map<String, Object> r : rows) {
+                if (r != null) {
+                    listofModelIds.add((String) r.get("tosca_model_id"));
+                }
+            }
+            // Filter Distinct elements using streams
+            listofModelIds = listofModelIds.stream().distinct().collect(Collectors.toList());
+
+            // TODO change logic using java8
+            for (String modelId : listofModelIds) {
+                CldsToscaModelDetails cldsToscaModelDetails = new CldsToscaModelDetails();
+                List<CldsToscaModelRevision> revisions = new ArrayList<>();
+                for (Map<String, Object> row : rows) {
+                    String id = (String) row.get("tosca_model_id");
+                    if (modelId.equalsIgnoreCase(id)) {
+                        cldsToscaModelDetails.setId(id);
+                        cldsToscaModelDetails.setPolicyType((String) row.get("policy_type"));
+                        cldsToscaModelDetails.setToscaModelName((String) row.get("tosca_model_name"));
+                        cldsToscaModelDetails.setUserId((String) row.get("user_id"));
+
+                        CldsToscaModelRevision modelRevision = new CldsToscaModelRevision();
+                        modelRevision.setRevisionId((String) row.get("tosca_model_revision_id"));
+                        modelRevision.setVersion(((Double) row.get("version")));
+                        modelRevision.setUserId((String) row.get("user_id"));
+                        modelRevision.setCreatedDate(sdf.format(row.get("createdTimestamp")));
+                        modelRevision.setLastUpdatedDate(sdf.format(row.get("lastUpdatedTimestamp")));
+                        revisions.add(modelRevision);
+                    }
+                }
+                cldsToscaModelDetails.setToscaModelRevisions(revisions);
+                cldsToscaModelDetailsList.add(cldsToscaModelDetails);
+            }
+        }
+        return cldsToscaModelDetailsList;
+    }
+
     /**
      * Method to upload a new version of Tosca Model Yaml in Database
      *
index be19e31..e895519 100644 (file)
@@ -163,7 +163,7 @@ public class CldsService extends SecureServiceBase {
      * used to generate the ClosedLoop model. ACTION_CD | Current state of the
      * ClosedLoop in CLDS application.
      */
-    public List<CldsMonitoringDetails> getCLDSDetails() {
+    public List<CldsMonitoringDetails> getCldsDetails() {
         util.entering(request, "CldsService: GET model details");
         Date startTime = new Date();
         List<CldsMonitoringDetails> cldsMonitoringDetailsList = cldsDao.getCLDSMonitoringDetails();
index e67fb16..4768169 100644 (file)
@@ -4,7 +4,7 @@
                        outType="org.onap.clamp.clds.model.CldsMonitoringDetails"
                        produces="application/json">
                        <to
-                               uri="bean:org.onap.clamp.clds.service.CldsService?method=getCLDSDetails()" />
+                               uri="bean:org.onap.clamp.clds.service.CldsService?method=getCldsDetails()" />
                </get>
                <get uri="/clds/cldsInfo"
                        outType="org.onap.clamp.clds.model.CldsInfo"
index ff65f42..85218ab 100644 (file)
@@ -28,7 +28,6 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -162,11 +161,11 @@ public class CldsServiceItCase {
 
     @Test
     public void testGetCLDSDetails() throws IOException {
-        List<CldsMonitoringDetails> cldsMonitoringDetailsList = cldsService.getCLDSDetails();
+        List<CldsMonitoringDetails> cldsMonitoringDetailsList = cldsService.getCldsDetails();
         assertNotNull(cldsMonitoringDetailsList);
     }
 
-    @Test
+    @Test(expected = NotFoundException.class)
     public void testCompleteFlow() throws TransformerException, ParseException {
         SecurityContext securityContext = Mockito.mock(SecurityContext.class);
         Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
@@ -260,13 +259,8 @@ public class CldsServiceItCase {
         assertNotNull(responseEntity);
         assertTrue(responseEntity.getStatusCode().equals(HttpStatus.OK));
         assertNotNull(responseEntity.getBody());
-        try {
-            cldsService.getModel(randomNameModel);
-            fail("Should have raised an NotFoundException exception");
-        } catch (NotFoundException ne) {
-
-        }
-
+        // This will raise an exception
+        cldsService.getModel(randomNameModel);
     }
 
     @Test
@@ -277,7 +271,8 @@ public class CldsServiceItCase {
         dcaeEvent.setResourceUUID("1");
         dcaeEvent.setServiceUUID("2");
         assertEquals(cldsService.postDcaeEvent("false", dcaeEvent),
-            "event=created serviceUUID=2 resourceUUID=1 artifactName=ClosedLoop_with-enough-characters_TestArtifact.yml instance count=0 isTest=false");
+            "event=created serviceUUID=2 resourceUUID=1 artifactName="
+                + "ClosedLoop_with-enough-characters_TestArtifact.yml instance count=0 isTest=false");
     }
 
     @Test
index 407e0c5..75579df 100644 (file)
@@ -26,6 +26,9 @@ package org.onap.clamp.clds.it;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
 import java.io.IOException;
 import java.util.LinkedList;
 import java.util.List;
@@ -54,16 +57,13 @@ import org.springframework.security.core.context.SecurityContext;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
 /**
  * Test CLDS Tosca Service APIs.
  */
 @RunWith(SpringJUnit4ClassRunner.class)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
 public class CldsToscaServiceItCase {
-    
+
     protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsToscaServiceItCase.class);
     @Autowired
     private CldsToscaService cldsToscaService;
@@ -72,14 +72,14 @@ public class CldsToscaServiceItCase {
     private String toscaModelYaml;
     private Authentication authentication;
     private CldsToscaModel cldsToscaModel;
-    private List<GrantedAuthority> authList =  new LinkedList<GrantedAuthority>();
+    private List<GrantedAuthority> authList = new LinkedList<GrantedAuthority>();
     private LoggingUtils util;
-    
+
     /**
      * Setup the variable before the tests execution.
-     * 
+     *
      * @throws IOException
-     *             In case of issues when opening the files
+     *         In case of issues when opening the files
      */
     @Before
     public void setupBefore() throws IOException {
@@ -90,7 +90,7 @@ public class CldsToscaServiceItCase {
         authList.add(new SimpleGrantedAuthority("permission-type-filter-vf|dev|*"));
         authList.add(new SimpleGrantedAuthority("permission-type-tosca|dev|read"));
         authList.add(new SimpleGrantedAuthority("permission-type-tosca|dev|update"));
-        authentication =  new UsernamePasswordAuthenticationToken(new User("admin", "", authList), "", authList);
+        authentication = new UsernamePasswordAuthenticationToken(new User("admin", "", authList), "", authList);
 
         SecurityContext securityContext = Mockito.mock(SecurityContext.class);
         Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
@@ -100,9 +100,9 @@ public class CldsToscaServiceItCase {
         cldsToscaService.setLoggingUtil(util);
 
         cldsToscaService.setSecurityContext(securityContext);
-        
+
         toscaModelYaml = ResourceFileUtil.getResourceAsString("tosca/tca-policy-test.yaml");
-        
+
         cldsToscaModel = new CldsToscaModel();
         cldsToscaModel.setToscaModelName("tca-policy-test");
         cldsToscaModel.setToscaModelYaml(toscaModelYaml);
@@ -111,7 +111,7 @@ public class CldsToscaServiceItCase {
         cldsToscaService.parseToscaModelAndSave("tca-policy-test", cldsToscaModel);
         logger.info("Initial Tosca Model uploaded in DB:" + cldsToscaModel);
     }
-    
+
     @Test
     public void testParseToscaModelAndSave() throws Exception {
         ResponseEntity responseEntity = cldsToscaService.parseToscaModelAndSave("tca-policy-test", cldsToscaModel);
@@ -128,7 +128,7 @@ public class CldsToscaServiceItCase {
         assertNotNull(savedModel);
         assertEquals("tca-policy-test", savedModel.getToscaModelName());
     }
-    
+
     @Test
     public void testGetToscaModelsByPolicyType() throws Exception {
         ResponseEntity<CldsToscaModel> responseEntity = cldsToscaService.getToscaModelsByPolicyType("tca");
@@ -137,5 +137,5 @@ public class CldsToscaServiceItCase {
         assertEquals("tca-policy-test", savedModel.getToscaModelName());
         assertEquals("tca", savedModel.getPolicyType());
     }
-    
+
 }
index f849a6c..d0a0fd9 100644 (file)
@@ -78,11 +78,6 @@ public class PolicyClientItCase {
     String modelBpmnPropJson;
     ModelProperties prop;
 
-    /**
-     * Initialize Test.
-     *
-     * @throws TransformerException
-     */
     @Before
     public void setUp() throws IOException, TransformerException {
         modelProp = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/model-properties.json");
index 330ee60..d36e14c 100644 (file)
@@ -5,21 +5,21 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); 
- * you may not use this file except in compliance with the License. 
+ * 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 
+ *
+ * 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============================================
  * Modifications copyright (c) 2018 Nokia
  * ===================================================================
- * 
+ *
  */
 
 package org.onap.clamp.clds.it;
@@ -157,7 +157,7 @@ public class SdcCatalogServicesItCase {
         rawCldsSdcResourceList.add(sdcResource2);
         SdcCatalogServices catalogServices = new SdcCatalogServices();
         List<SdcResourceBasicInfo> resultList = catalogServices
-                .removeDuplicateSdcResourceBasicInfo(rawCldsSdcResourceList);
+            .removeDuplicateSdcResourceBasicInfo(rawCldsSdcResourceList);
         SdcResourceBasicInfo res1;
         SdcResourceBasicInfo res2;
         if ("resource1".equals(resultList.get(0).getName())) {
@@ -173,15 +173,13 @@ public class SdcCatalogServicesItCase {
         assertTrue("1.0".equals(res2.getVersion()));
     }
 
-
     @Test
-    public void removeDuplicateSdcFunctionShouldNotReturnNull(){
+    public void removeDuplicateSdcFunctionShouldNotReturnNull() {
         // given
         SdcCatalogServices catalogServices = new SdcCatalogServices();
 
         // when
-        List<SdcResourceBasicInfo> firstResult = catalogServices
-            .removeDuplicateSdcResourceBasicInfo(null);
+        List<SdcResourceBasicInfo> firstResult = catalogServices.removeDuplicateSdcResourceBasicInfo(null);
         List<SdcResourceBasicInfo> secondResult = catalogServices
             .removeDuplicateSdcResourceBasicInfo(new ArrayList<>());
 
@@ -194,8 +192,8 @@ public class SdcCatalogServicesItCase {
     public void getServiceUuidFromServiceInvariantIdTest() throws Exception {
         SdcCatalogServices spy = Mockito.spy(sdcCatalogWired);
         Mockito.doReturn(IOUtils.toString(
-                SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"),
-                "UTF-8")).when(spy).getSdcServicesInformation(null);
+            SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8"))
+            .when(spy).getSdcServicesInformation(null);
         // Try the vcts4 version 1.0, this one should be replaced by 1.1 so it
         // should not exist, returning empty string
         String resUuidVcts4Null = spy.getServiceUuidFromServiceInvariantId("a33ed748-3477-4434-b3f3-b5560f5e7d9b");
@@ -216,81 +214,92 @@ public class SdcCatalogServicesItCase {
     public void getCldsServiceDataWithAlarmConditionsTest() throws Exception {
         SdcCatalogServices spy = Mockito.spy(sdcCatalogWired);
         Mockito.doReturn(IOUtils.toString(
-                SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"),
-                "UTF-8")).when(spy).getSdcServicesInformation(null);
+            SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8"))
+            .when(spy).getSdcServicesInformation(null);
         // This invariant uuid is the one from vcts4 v1.1
         String serviceResourceDetailUrl = refProp.getStringValue("sdc.serviceUrl")
-                + "/29018914-966c-442d-9d08-251b9dc45b8f/metadata";
+            + "/29018914-966c-442d-9d08-251b9dc45b8f/metadata";
         Mockito.doReturn(IOUtils.toString(
-                SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServiceDetailsExample.json"),
-                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl);
+            SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServiceDetailsExample.json"), "UTF-8"))
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl);
         String resourceDetailUrl = refProp.getStringValue("sdc.catalog.url")
-                + "resources/585822c7-4027-4f84-ba50-e9248606f136/metadata";
+            + "resources/585822c7-4027-4f84-ba50-e9248606f136/metadata";
         Mockito.doReturn(IOUtils.toString(
-                SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcResourceDetailsExample.json"),
-                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl);
+            SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcResourceDetailsExample.json"), "UTF-8"))
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl);
         String securityRulesDetailUrl = refProp.getStringValue("sdc.catalog.url")
-                + "resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/metadata";
-        Mockito.doReturn(IOUtils.toString(
+            + "resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/metadata";
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcSecurityRules.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl);
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl);
         String cinderVolumeDetailUrl = refProp.getStringValue("sdc.catalog.url")
-                + "resources/b4288e07-597a-44a2-aa98-ad36e551a39d/metadata";
-        Mockito.doReturn(IOUtils.toString(
+            + "resources/b4288e07-597a-44a2-aa98-ad36e551a39d/metadata";
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCinderVolume.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl);
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl);
         String vfcGenericDetailUrl = refProp.getStringValue("sdc.catalog.url")
-                + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/metadata";
+            + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/metadata";
         Mockito.doReturn(IOUtils.toString(
-                SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCGenericWithAlarms.json"),
-                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl);
+            SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCGenericWithAlarms.json"), "UTF-8"))
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl);
         String csvAlarmsDetailUrl = refProp.getStringValue("sdc.catalog.url")
-                + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/resourceInstances/virc_fe_be/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
-        Mockito.doReturn(IOUtils.toString(
+            + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/resourceInstances/virc_fe_be/"
+            + "artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
-        Mockito.doReturn(IOUtils.toString(
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
         String csvAlarmsDetailUrl2 = refProp.getStringValue("sdc.catalog.url")
-                + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
-        Mockito.doReturn(IOUtils.toString(
+            + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl2);
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl2);
         String allVfResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VF";
-        Mockito.doReturn(IOUtils.toString(
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFResources.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl);
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl);
         String vfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url")
-                + "resources/a0475018-1e7e-4ddd-8bee-33cbf958c2e6/metadata";
+            + "resources/a0475018-1e7e-4ddd-8bee-33cbf958c2e6/metadata";
         Mockito.doReturn(IOUtils.toString(
-                SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCVFCResourceExample.json"),
-                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourcesDetailUrl);
+            SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCVFCResourceExample.json"), "UTF-8"))
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourcesDetailUrl);
         String allVfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VFC";
-        Mockito.doReturn(IOUtils.toString(
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCResources.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl);
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl);
         String allCvfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=CVFC";
-        Mockito.doReturn(IOUtils.toString(
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCVFCResources.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(allCvfcResourcesDetailUrl);
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(allCvfcResourcesDetailUrl);
         String allVfAlarms = refProp.getStringValue("sdc.catalog.url")
-                + "resources/84855843-5247-4e97-a2bd-5395a510253b/artifacts/d57ac7ec-f3c3-4793-983a-c75ac3a43153";
-        Mockito.doReturn(IOUtils.toString(
+            + "resources/84855843-5247-4e97-a2bd-5395a510253b/artifacts/d57ac7ec-f3c3-4793-983a-c75ac3a43153";
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcMeasurementsList.csv"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfAlarms);
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfAlarms);
         String vfcResourceExample = refProp.getStringValue("sdc.catalog.url")
-                + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/metadata";
-        Mockito.doReturn(IOUtils.toString(
+            + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/metadata";
+        Mockito
+            .doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCResourceExample.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourceExample);
+            .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourceExample);
         CldsServiceData cldsServiceData = spy
-                .getCldsServiceDataWithAlarmConditions("a33ed748-3477-4434-b3f3-b5560f5e7d9c");
+            .getCldsServiceDataWithAlarmConditions("a33ed748-3477-4434-b3f3-b5560f5e7d9c");
         assertTrue("a33ed748-3477-4434-b3f3-b5560f5e7d9c".equals(cldsServiceData.getServiceInvariantUUID()));
         assertTrue("29018914-966c-442d-9d08-251b9dc45b8f".equals(cldsServiceData.getServiceUUID()));
         assertTrue(cldsServiceData.getCldsVfs().size() == 1);
         List<CldsAlarmCondition> alarmsList = spy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData,
-                "alarmCondition");
+            "alarmCondition");
         assertTrue(alarmsList.size() == 12);
     }
 }
index f05b33e..971b36f 100644 (file)
@@ -18,7 +18,7 @@
  * limitations under the License.
  * ============LICENSE_END============================================
  * ===================================================================
- * 
+ *
  */
 
 package org.onap.clamp.clds.it;
@@ -68,7 +68,7 @@ public class SdcReqItCase {
         modelName = "example-model01";
         controlName = "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf";
         modelProperties = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, false, modelBpmn,
-                modelBpmnProp);
+            modelBpmnProp);
         jsonWithYamlInside = ResourceFileUtil.getResourceAsString("example/tca-policy-req/prop-text.json");
     }
 
@@ -76,26 +76,23 @@ public class SdcReqItCase {
     public void formatBlueprintTest() throws IOException {
         String blueprintFormatted = sdcReq.formatBlueprint(modelProperties, jsonWithYamlInside);
         assertEquals(ResourceFileUtil.getResourceAsString("example/tca-policy-req/blueprint-expected.yaml"),
-                blueprintFormatted);
+            blueprintFormatted);
     }
 
     @Test
     public void formatSdcLocationsReqTest() {
         String blueprintFormatted = sdcReq.formatSdcLocationsReq(modelProperties, "testos");
         assertEquals(
-                "{\"artifactName\":\"testos\",\"locations\":[\"SNDGCA64\",\"ALPRGAED\",\"LSLEILAA\",\"MDTWNJC1\"]}",
-                blueprintFormatted);
+            "{\"artifactName\":\"testos\",\"locations\":[\"SNDGCA64\",\"ALPRGAED\",\"LSLEILAA\",\"MDTWNJC1\"]}",
+            blueprintFormatted);
     }
 
     @Test
     public void formatSdcReqTest() throws JSONException {
-        String jsonResult = sdcReq.formatSdcReq("payload", "artifactName",
-                "artifactLabel", "artifactType");
-        JSONAssert.assertEquals(
-                "{\"payloadData\" : \"cGF5bG9hZA==\",\"artifactLabel\" : \"artifactLabel\"," +
-                        "\"artifactName\" :\"artifactName\",\"artifactType\" : \"artifactType\","
-                        + "\"artifactGroupType\" : \"DEPLOYMENT\",\"description\" : \"from CLAMP Cockpit\"}",
-                jsonResult, true);
+        String jsonResult = sdcReq.formatSdcReq("payload", "artifactName", "artifactLabel", "artifactType");
+        JSONAssert.assertEquals("{\"payloadData\" : \"cGF5bG9hZA==\",\"artifactLabel\" : \"artifactLabel\","
+            + "\"artifactName\" :\"artifactName\",\"artifactType\" : \"artifactType\","
+            + "\"artifactGroupType\" : \"DEPLOYMENT\",\"description\" : \"from CLAMP Cockpit\"}", jsonResult, true);
     }
 
     @Test
@@ -104,6 +101,6 @@ public class SdcReqItCase {
         assertNotNull(listUrls);
         assertTrue(listUrls.size() == 1);
         assertTrue(listUrls.get(0).contains(
-              "/sdc/v1/catalog/services/56441b4b-0467-41dc-9a0e-e68613838219/resourceInstances/vpacketgen0/artifacts"));
+            "/sdc/v1/catalog/services/56441b4b-0467-41dc-9a0e-e68613838219/resourceInstances/vpacketgen0/artifacts"));
     }
 }