Remove useless code 91/74991/1
authorsebdet <sebastien.determe@intl.att.com>
Thu, 20 Dec 2018 15:41:55 +0000 (16:41 +0100)
committersebdet <sebastien.determe@intl.att.com>
Thu, 20 Dec 2018 15:41:55 +0000 (16:41 +0100)
Remove code not used anymore + add tests to increase coverage

Issue-ID: CLAMP-252
Change-Id: I7a1ec163f73fe88f62fe0981148087ea8f7b7341
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java
src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java [new file with mode: 0644]
src/test/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfoTest.java [new file with mode: 0644]
src/test/resources/clds/camel/routes/flexible-flow.xml

index 16c18ae..4151c7a 100644 (file)
@@ -18,7 +18,7 @@
  * limitations under the License.\r
  * ============LICENSE_END============================================\r
  * ===================================================================\r
- * \r
+ *\r
  */\r
 \r
 package org.onap.clamp.clds.client;\r
@@ -64,7 +64,6 @@ public class DcaeDispatcherServices {
         this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;\r
     }\r
 \r
-\r
     public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {\r
         String operationStatus = "";\r
         for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {\r
@@ -83,9 +82,9 @@ public class DcaeDispatcherServices {
 \r
     /**\r
      * Get the Operation Status from a specified URL.\r
-     * \r
+     *\r
      * @param statusUrl\r
-     *            The URL provided by a previous DCAE Query\r
+     *        The URL provided by a previous DCAE Query\r
      * @return The status\r
      */\r
     public String getOperationStatus(String statusUrl) {\r
@@ -112,36 +111,15 @@ public class DcaeDispatcherServices {
         return opStatus;\r
     }\r
 \r
-    /**\r
-     * This method send a getDeployments operation to DCAE.\r
-     */\r
-    public void getDeployments() {\r
-        Date startTime = new Date();\r
-        LoggingUtils.setTargetContext("DCAE", "getDeployments");\r
-        try {\r
-            String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX;\r
-            dcaeHttpConnectionManager.doDcaeHttpQuery(url, "GET", null, null);\r
-            LoggingUtils.setResponseContext("0", "Get deployments success", this.getClass().getName());\r
-        } catch (Exception e) {\r
-            LoggingUtils.setResponseContext("900", "Get deployments failed", this.getClass().getName());\r
-            LoggingUtils.setErrorContext("900", "Get deployments error");\r
-            logger.error("Exception occurred during getDeployments Operation with DCAE", e);\r
-            throw new DcaeDeploymentException("Exception occurred during getDeployments Operation with DCAE", e);\r
-        } finally {\r
-            LoggingUtils.setTimeContext(startTime, new Date());\r
-            metricsLogger.info("getDeployments complete");\r
-        }\r
-    }\r
-\r
     /**\r
      * Returns status URL for createNewDeployment operation.\r
      *\r
      * @param deploymentId\r
-     *            The deployment ID\r
+     *        The deployment ID\r
      * @param serviceTypeId\r
-     *            Service type ID\r
+     *        Service type ID\r
      * @param blueprintInputJson\r
-     *            The value for each blueprint parameters in a flat JSON\r
+     *        The value for each blueprint parameters in a flat JSON\r
      * @return The status URL\r
      */\r
     public String createNewDeployment(String deploymentId, String serviceTypeId, JsonNode blueprintInputJson) {\r
@@ -157,7 +135,7 @@ public class DcaeDispatcherServices {
             logger.info("Dcae api Body String - " + apiBodyString);\r
             String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;\r
             String statusUrl = getDcaeResponse(url, "PUT", apiBodyString, "application/json", DCAE_LINK_FIELD,\r
-                    DCAE_STATUS_FIELD);\r
+                DCAE_STATUS_FIELD);\r
             LoggingUtils.setResponseContext("0", "Create new deployment failed", this.getClass().getName());\r
             return statusUrl;\r
         } catch (Exception e) {\r
@@ -173,11 +151,11 @@ public class DcaeDispatcherServices {
 \r
     /***\r
      * Returns status URL for deleteExistingDeployment operation.\r
-     * \r
+     *\r
      * @param deploymentId\r
-     *            The deployment ID\r
+     *        The deployment ID\r
      * @param serviceTypeId\r
-     *            The service Type ID\r
+     *        The service Type ID\r
      * @return The status URL\r
      */\r
     public String deleteExistingDeployment(String deploymentId, String serviceTypeId) {\r
@@ -188,7 +166,7 @@ public class DcaeDispatcherServices {
             logger.info("Dcae api Body String - " + apiBodyString);\r
             String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;\r
             String statusUrl = getDcaeResponse(url, "DELETE", apiBodyString, "application/json", DCAE_LINK_FIELD,\r
-                    DCAE_STATUS_FIELD);\r
+                DCAE_STATUS_FIELD);\r
             LoggingUtils.setResponseContext("0", "Delete existing deployment success", this.getClass().getName());\r
             return statusUrl;\r
 \r
@@ -197,7 +175,7 @@ public class DcaeDispatcherServices {
             LoggingUtils.setErrorContext("900", "Delete existing deployment error");\r
             logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e);\r
             throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE",\r
-                    e);\r
+                e);\r
         } finally {\r
             LoggingUtils.setTimeContext(startTime, new Date());\r
             metricsLogger.info("deleteExistingDeployment complete");\r
@@ -205,7 +183,7 @@ public class DcaeDispatcherServices {
     }\r
 \r
     private String getDcaeResponse(String url, String requestMethod, String payload, String contentType, String node,\r
-            String nodeAttr) throws IOException, ParseException {\r
+        String nodeAttr) throws IOException, ParseException {\r
         Date startTime = new Date();\r
         try {\r
             String responseStr = dcaeHttpConnectionManager.doDcaeHttpQuery(url, requestMethod, payload, contentType);\r
index 0558470..1fb86c0 100644 (file)
@@ -5,20 +5,20 @@
  * 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============================================
  * ===================================================================
- * 
+ *
  */
 
 package org.onap.clamp.clds.config.spring;
@@ -61,7 +61,7 @@ public class CldsSdcControllerConfiguration {
         SdcControllersConfiguration sdcControllersConfig = getSdcControllersConfiguration();
         sdcControllersConfig.getAllDefinedControllers().forEach((k, v) -> {
             logger.info("Creating controller instance:" + k);
-            SdcSingleController sdcController = new SdcSingleController(clampProp, csarInstaller, v, true);
+            SdcSingleController sdcController = new SdcSingleController(clampProp, csarInstaller, v, null);
             sdcControllersList.add(sdcController);
         });
     }
index 6bf4194..571e5b1 100644 (file)
@@ -18,7 +18,7 @@
  * limitations under the License.
  * ============LICENSE_END============================================
  * ===================================================================
- * 
+ *
  */
 
 package org.onap.clamp.clds.model.properties;
@@ -50,8 +50,8 @@ public abstract class AbstractModelElement {
     private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}";
 
     /**
-     * Perform base parsing of properties for a ModelElement (such as,
-     * VesCollector, Policy and Tca)
+     * Perform base parsing of properties for a ModelElement (such as, VesCollector,
+     * Policy and Tca)
      */
     protected AbstractModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) {
         this.type = type;
@@ -62,23 +62,6 @@ public abstract class AbstractModelElement {
         this.isFound = modelBpmn.isModelElementTypeInList(type);
     }
 
-    /**
-     * topicSubscribes is the topicPublishes of the from Model Element (the
-     * previous one in the chain).
-     *
-     * @return the topicSubscribes
-     */
-    public String getTopicSubscribes() {
-        // get fromId for this type
-        String fromId = modelBpmn.getFromId(type);
-        // find the type of the from model element
-        String fromType = modelBpmn.getType(fromId);
-        // get the model element for the type
-        AbstractModelElement me = modelProp.getModelElementByType(fromType);
-        // get the topic publishes for the model element
-        return me.topicPublishes;
-    }
-
     /**
      * @return the topicPublishes
      */
@@ -87,8 +70,8 @@ public abstract class AbstractModelElement {
     }
 
     /**
-     * Return the value field of the json node element that has a name field
-     * equals to the given name.
+     * Return the value field of the json node element that has a name field equals
+     * to the given name.
      */
     public static String getValueByName(JsonNode nodeIn, String name) {
         String value = null;
@@ -115,8 +98,8 @@ public abstract class AbstractModelElement {
     }
 
     /**
-     * Return the Json value field of the json node element that has a name
-     * field equals to the given name.
+     * Return the Json value field of the json node element that has a name field
+     * equals to the given name.
      */
     public static JsonNode getJsonNodeByName(JsonNode nodeIn, String name) {
         JsonNode vnode = null;
@@ -136,8 +119,8 @@ public abstract class AbstractModelElement {
     }
 
     /**
-     * Return the value field of the json node element that has a name field
-     * that equals the given name.
+     * Return the value field of the json node element that has a name field that
+     * equals the given name.
      */
     public static String getNodeValueByName(JsonNode nodeIn, String name) {
         String value = null;
@@ -153,8 +136,8 @@ public abstract class AbstractModelElement {
     }
 
     /**
-     * Return the value field of the json node element that has a name field
-     * that equals the given name.
+     * Return the value field of the json node element that has a name field that
+     * equals the given name.
      */
     public static List<String> getNodeValuesByName(JsonNode nodeIn, String name) {
         List<String> values = new ArrayList<>();
@@ -185,8 +168,8 @@ public abstract class AbstractModelElement {
     }
 
     /**
-     * Return an array of values for the field of the json node element that has
-     * name field equals to the given name.
+     * Return an array of values for the field of the json node element that has a
+     * name field equals to the given name.
      */
     public static List<String> getValuesByName(JsonNode nodeIn, String name) {
         List<String> values = null;
@@ -221,8 +204,8 @@ public abstract class AbstractModelElement {
     }
 
     /**
-     * Return the value field of the json node element that has a name field
-     * equals to the given name.
+     * Return the value field of the json node element that has a name field equals
+     * to the given name.
      */
     public String getValueByName(String name) {
         return getValueByName(modelElementJsonNode, name);
@@ -237,8 +220,8 @@ public abstract class AbstractModelElement {
     }
 
     /**
-     * Return an array of values for the field of the json node element that has
-     * name field equals to the given name.
+     * Return an array of values for the field of the json node element that has a
+     * name field equals to the given name.
      */
     public List<String> getValuesByName(String name) {
         return getValuesByName(modelElementJsonNode, name);
index b567940..3d7bbcc 100644 (file)
@@ -39,7 +39,6 @@ import org.apache.camel.Exchange;
 import org.onap.clamp.clds.client.req.policy.PolicyClient;
 import org.onap.clamp.clds.config.ClampProperties;
 import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.clamp.clds.model.CldsEvent;
 import org.onap.clamp.clds.model.CldsModel;
 import org.onap.clamp.clds.service.CldsService;
 import org.onap.clamp.clds.util.JacksonUtils;
@@ -75,22 +74,22 @@ public class ModelProperties {
     }
 
     /**
-     * Retain data required to parse the ModelElement objects. (Rather than
-     * parse them all - parse them on demand if requested.)
+     * Retain data required to parse the ModelElement objects. (Rather than parse
+     * them all - parse them on demand if requested.)
      *
      * @param modelName
-     *            The model name coming form the UI
+     *        The model name coming form the UI
      * @param controlName
-     *            The closed loop name coming from the UI
+     *        The closed loop name coming from the UI
      * @param actionCd
-     *            Type of operation PUT,UPDATE,DELETE
+     *        Type of operation PUT,UPDATE,DELETE
      * @param isATest
-     *            The test flag coming from the UI (for validation only, no
-     *            query are physically executed)
+     *        The test flag coming from the UI (for validation only, no query are
+     *        physically executed)
      * @param modelBpmnText
-     *            The BPMN flow in JSON from the UI
+     *        The BPMN flow in JSON from the UI
      * @param modelPropText
-     *            The BPMN parameters for all boxes defined in modelBpmnTest
+     *        The BPMN parameters for all boxes defined in modelBpmnTest
      */
     public ModelProperties(String modelName, String controlName, String actionCd, boolean isATest, String modelBpmnText,
         String modelPropText) {
@@ -108,10 +107,10 @@ public class ModelProperties {
     }
 
     /**
-     * This method is meant to ensure that one ModelElement instance exists for
-     * each ModelElement class. As new ModelElement classes could have been
-     * registered after instantiation of this ModelProperties, we need to build
-     * the missing ModelElement instances.
+     * This method is meant to ensure that one ModelElement instance exists for each
+     * ModelElement class. As new ModelElement classes could have been registered
+     * after instantiation of this ModelProperties, we need to build the missing
+     * ModelElement instances.
      */
     private final void instantiateMissingModelElements() {
         if (modelElementClasses.size() != modelElements.size()) {
@@ -120,19 +119,18 @@ public class ModelProperties {
             // Parse the list of base Model Elements and build up the
             // ModelElements
             modelElementClasses.entrySet().stream().parallel()
-            .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey())
-                && missingTypes.contains(entry.getValue())))
-            .forEach(entry -> {
-                try {
-                    modelElements.put(entry.getValue(),
-                        (entry.getKey()
-                            .getConstructor(ModelProperties.class, ModelBpmn.class, JsonNode.class)
-                            .newInstance(this, modelBpmn, modelJson)));
-                } catch (InstantiationException | NoSuchMethodException | IllegalAccessException
-                    | InvocationTargetException e) {
-                    logger.warn("Unable to instantiate a ModelElement, exception follows: ", e);
-                }
-            });
+                .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey())
+                    && missingTypes.contains(entry.getValue())))
+                .forEach(entry -> {
+                    try {
+                        modelElements.put(entry.getValue(),
+                            (entry.getKey().getConstructor(ModelProperties.class, ModelBpmn.class, JsonNode.class)
+                                .newInstance(this, modelBpmn, modelJson)));
+                    } catch (InstantiationException | NoSuchMethodException | IllegalAccessException
+                        | InvocationTargetException e) {
+                        logger.warn("Unable to instantiate a ModelElement, exception follows: ", e);
+                    }
+                });
         }
     }
 
@@ -162,10 +160,9 @@ public class ModelProperties {
      * Create ModelProperties extracted from a CamelExchange.
      *
      * @param camelExchange
-     *            The camel Exchange object that contains all info provided to
-     *            the flow
-     * @return A model Properties created from the parameters found in
-     *         camelExchange object
+     *        The camel Exchange object that contains all info provided to the flow
+     * @return A model Properties created from the parameters found in camelExchange
+     *         object
      */
     public static ModelProperties create(Exchange camelExchange) {
         String modelProp = (String) camelExchange.getProperty("modelProp");
@@ -177,20 +174,6 @@ public class ModelProperties {
         return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp);
     }
 
-    /**
-     * return appropriate model element given the type
-     *
-     * @param type
-     * @return
-     */
-    public AbstractModelElement getModelElementByType(String type) {
-        AbstractModelElement modelElement = modelElements.get(type);
-        if (modelElement == null) {
-            throw new IllegalArgumentException("Invalid or not found ModelElement type: " + type);
-        }
-        return modelElement;
-    }
-
     /**
      * @return the modelName
      */
@@ -231,12 +214,11 @@ public class ModelProperties {
     }
 
     /**
-     * @return The policyName that wil be used in input parameters of DCAE
-     *         deploy
+     * @return The policyName that wil be used in input parameters of DCAE deploy
      */
     public String getPolicyNameForDcaeDeploy(ClampProperties refProp) {
         return normalizePolicyScopeName(modelName + createScopeSeparator(modelName)
-        + refProp.getStringValue(PolicyClient.POLICY_MS_NAME_PREFIX_PROPERTY_NAME) + getCurrentPolicyName());
+            + refProp.getStringValue(PolicyClient.POLICY_MS_NAME_PREFIX_PROPERTY_NAME) + getCurrentPolicyName());
     }
 
     /**
@@ -251,8 +233,8 @@ public class ModelProperties {
      * @return the policyScopeAndNameWithUniqueId
      */
     public String getPolicyScopeAndNameWithUniqueGuardId() {
-        return normalizePolicyScopeName(
-            modelName + createScopeSeparator(modelName) + getCurrentPolicyName() + "_" + policyUniqueId+POLICY_GUARD_SUFFIX+guardUniqueId);
+        return normalizePolicyScopeName(modelName + createScopeSeparator(modelName) + getCurrentPolicyName() + "_"
+            + policyUniqueId + POLICY_GUARD_SUFFIX + guardUniqueId);
     }
 
     /**
@@ -266,18 +248,19 @@ public class ModelProperties {
     /**
      * @return the PolicyNameWithScopeContext
      */
-    public String getPolicyNameWithScopeContext(String policyScope, String policyType, String vnfScope, String context, String userDefinedName) {
-        return normalizePolicyScopeName(
-                policyScope + createScopeSeparator(policyScope) + policyType + "_" + vnfScope + "_" + context + "_" + modelName + "_" + userDefinedName);
+    public String getPolicyNameWithScopeContext(String policyScope, String policyType, String vnfScope, String context,
+        String userDefinedName) {
+        return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyType + "_" + vnfScope
+            + "_" + context + "_" + modelName + "_" + userDefinedName);
     }
 
     /**
      * @return the PolicyNameWithPrefixScopeContext
      */
-    public String getPolicyNameWithPrefixScopeContext(String policyScope, String policyType, String vnfScope,  String context,
-               String userDefinedName, String policyPrefix) {
-        return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyPrefix + policyType + "_" + vnfScope + "_"
-                + context + "_" + modelName + "_" + userDefinedName);
+    public String getPolicyNameWithPrefixScopeContext(String policyScope, String policyType, String vnfScope,
+        String context, String userDefinedName, String policyPrefix) {
+        return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyPrefix + policyType
+            + "_" + vnfScope + "_" + context + "_" + modelName + "_" + userDefinedName);
     }
 
     /**
@@ -298,11 +281,11 @@ public class ModelProperties {
     }
 
     /**
-     * When generating a policy request for a model element, must set the id of
-     * that model element using this method. Used to generate the policy name.
+     * When generating a policy request for a model element, must set the id of that
+     * model element using this method. Used to generate the policy name.
      *
      * @param currentModelElementId
-     *            the currentModelElementId to set
+     *        the currentModelElementId to set
      */
     public void setCurrentModelElementId(String currentModelElementId) {
         this.currentModelElementId = currentModelElementId;
@@ -324,11 +307,11 @@ public class ModelProperties {
     }
 
     /**
-     * When generating a policy request for a model element, must set the unique
-     * id of that policy using this method. Used to generate the policy name.
+     * When generating a policy request for a model element, must set the unique id
+     * of that policy using this method. Used to generate the policy name.
      *
      * @param policyUniqueId
-     *            the policyUniqueId to set
+     *        the policyUniqueId to set
      */
     public void setPolicyUniqueId(String policyUniqueId) {
         this.policyUniqueId = policyUniqueId;
@@ -348,26 +331,6 @@ public class ModelProperties {
         return testOnly;
     }
 
-    /**
-     * @return the isCreateRequest
-     */
-    public boolean isCreateRequest() {
-        switch (actionCd) {
-        case CldsEvent.ACTION_SUBMIT:
-        case CldsEvent.ACTION_RESTART:
-            return true;
-        }
-        return false;
-    }
-
-    public boolean isStopRequest() {
-        switch (actionCd) {
-        case CldsEvent.ACTION_STOP:
-            return true;
-        }
-        return false;
-    }
-
     /**
      * @return the global
      */
index 8796bae..5959c0f 100644 (file)
@@ -19,7 +19,7 @@
  * ============LICENSE_END============================================\r
  * Modifications copyright (c) 2018 Nokia\r
  * ===================================================================\r
- * \r
+ *\r
  */\r
 \r
 package org.onap.clamp.clds.sdc.controller;\r
@@ -81,8 +81,8 @@ public class SdcSingleController {
         }\r
 \r
         /**\r
-         * This method can be called multiple times at the same moment. The\r
-         * controller must be thread safe !\r
+         * This method can be called multiple times at the same moment. The controller\r
+         * must be thread safe !\r
          */\r
         @Override\r
         public void activateCallback(INotificationData iNotif) {\r
@@ -91,7 +91,7 @@ public class SdcSingleController {
             sdcController.treatNotification(iNotif);\r
             LoggingUtils.setTimeContext(startTime, new Date());\r
             LoggingUtils.setResponseContext("0", "SDC Notification received and processed successfully",\r
-                    this.getClass().getName());\r
+                this.getClass().getName());\r
         }\r
     }\r
 \r
@@ -110,16 +110,16 @@ public class SdcSingleController {
 \r
     protected final synchronized void changeControllerStatus(SdcSingleControllerStatus newControllerStatus) {\r
         switch (newControllerStatus) {\r
-            case BUSY:\r
-                ++this.nbOfNotificationsOngoing;\r
-                this.controllerStatus = newControllerStatus;\r
-                break;\r
-            case IDLE:\r
-                this.changeControllerStatusIdle();\r
-                break;\r
-            default:\r
-                this.controllerStatus = newControllerStatus;\r
-                break;\r
+        case BUSY:\r
+            ++this.nbOfNotificationsOngoing;\r
+            this.controllerStatus = newControllerStatus;\r
+            break;\r
+        case IDLE:\r
+            this.changeControllerStatusIdle();\r
+            break;\r
+        default:\r
+            this.controllerStatus = newControllerStatus;\r
+            break;\r
         }\r
     }\r
 \r
@@ -128,8 +128,9 @@ public class SdcSingleController {
     }\r
 \r
     public SdcSingleController(ClampProperties clampProp, CsarInstaller csarInstaller,\r
-            SdcSingleControllerConfiguration sdcSingleConfig, boolean isClientAutoManaged) {\r
-        this.isSdcClientAutoManaged = isClientAutoManaged;\r
+        SdcSingleControllerConfiguration sdcSingleConfig, IDistributionClient distributionClient) {\r
+        this.distributionClient = distributionClient;\r
+        isSdcClientAutoManaged = (distributionClient == null);\r
         this.sdcConfig = sdcSingleConfig;\r
         this.refProp = clampProp;\r
         this.csarInstaller = csarInstaller;\r
@@ -139,11 +140,10 @@ public class SdcSingleController {
      * This method initializes the SDC Controller and the SDC Client.\r
      *\r
      * @throws SdcControllerException\r
-     *             It throws an exception if the SDC Client cannot be\r
-     *             instantiated or if an init attempt is done when already\r
-     *             initialized\r
+     *         It throws an exception if the SDC Client cannot be instantiated or if\r
+     *         an init attempt is done when already initialized\r
      * @throws SdcParametersException\r
-     *             If there is an issue with the parameters provided\r
+     *         If there is an issue with the parameters provided\r
      */\r
     public void initSdc() throws SdcControllerException {\r
         logger.info("Attempt to initialize the SDC Controller: " + sdcConfig.getSdcControllerName());\r
@@ -157,8 +157,8 @@ public class SdcSingleController {
         if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {\r
             logger.error("SDC distribution client init failed with reason:" + result.getDistributionMessageResult());\r
             this.changeControllerStatus(SdcSingleControllerStatus.STOPPED);\r
-            throw new SdcControllerException("Initialization of the SDC Controller failed with reason: "\r
-                    + result.getDistributionMessageResult());\r
+            throw new SdcControllerException(\r
+                "Initialization of the SDC Controller failed with reason: " + result.getDistributionMessageResult());\r
         }\r
         logger.info("SDC Controller successfully initialized: " + sdcConfig.getSdcControllerName());\r
         logger.info("Attempt to start the SDC Controller: " + sdcConfig.getSdcControllerName());\r
@@ -167,7 +167,7 @@ public class SdcSingleController {
             logger.error("SDC distribution client start failed with reason:" + result.getDistributionMessageResult());\r
             this.changeControllerStatus(SdcSingleControllerStatus.STOPPED);\r
             throw new SdcControllerException(\r
-                    "Startup of the SDC Controller failed with reason: " + result.getDistributionMessageResult());\r
+                "Startup of the SDC Controller failed with reason: " + result.getDistributionMessageResult());\r
         }\r
         logger.info("SDC Controller successfully started: " + sdcConfig.getSdcControllerName());\r
         this.changeControllerStatus(SdcSingleControllerStatus.IDLE);\r
@@ -177,8 +177,8 @@ public class SdcSingleController {
      * This method closes the SDC Controller and the SDC Client.\r
      *\r
      * @throws SdcControllerException\r
-     *             It throws an exception if the SDC Client cannot be closed\r
-     *             because it's currently BUSY in processing notifications.\r
+     *         It throws an exception if the SDC Client cannot be closed because\r
+     *         it's currently BUSY in processing notifications.\r
      */\r
     public void closeSdc() throws SdcControllerException {\r
         if (this.getControllerStatus() == SdcSingleControllerStatus.BUSY) {\r
@@ -198,33 +198,33 @@ public class SdcSingleController {
     }\r
 \r
     private void sendAllNotificationForCsarHandler(INotificationData iNotif, CsarHandler csar,\r
-            NotificationType notificationType, DistributionStatusEnum distributionStatus, String errorMessage) {\r
+        NotificationType notificationType, DistributionStatusEnum distributionStatus, String errorMessage) {\r
         if (csar != null) {\r
             // Notify for the CSAR\r
             this.sendSdcNotification(notificationType, csar.getArtifactElement().getArtifactURL(),\r
-                    sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,\r
-                    System.currentTimeMillis());\r
+                sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,\r
+                System.currentTimeMillis());\r
             // Notify for all VF resources found\r
             for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {\r
                 // Normally always 1 artifact in resource for Clamp as we\r
                 // specified\r
                 // only VF_METADATA type\r
                 this.sendSdcNotification(notificationType,\r
-                        blueprint.getValue().getResourceAttached().getArtifacts().get(0).getArtifactURL(),\r
-                        sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,\r
-                        System.currentTimeMillis());\r
+                    blueprint.getValue().getResourceAttached().getArtifacts().get(0).getArtifactURL(),\r
+                    sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,\r
+                    System.currentTimeMillis());\r
             }\r
         } else {\r
             this.sendSdcNotification(notificationType, null, sdcConfig.getConsumerID(), iNotif.getDistributionID(),\r
-                    distributionStatus, errorMessage, System.currentTimeMillis());\r
+                distributionStatus, errorMessage, System.currentTimeMillis());\r
         }\r
     }\r
 \r
     /**\r
      * This method processes the notification received from Sdc.\r
-     * \r
+     *\r
      * @param iNotif\r
-     *            The INotificationData\r
+     *        The INotificationData\r
      */\r
     public void treatNotification(INotificationData iNotif) {\r
         CsarHandler csar = null;\r
@@ -235,37 +235,37 @@ public class SdcSingleController {
             logger.info("Notification received for service UUID:" + iNotif.getServiceUUID());\r
             this.changeControllerStatus(SdcSingleControllerStatus.BUSY);\r
             csar = new CsarHandler(iNotif, this.sdcConfig.getSdcControllerName(),\r
-                    refProp.getStringValue(CONFIG_SDC_FOLDER));\r
+                refProp.getStringValue(CONFIG_SDC_FOLDER));\r
             csar.save(downloadTheArtifact(csar.getArtifactElement()));\r
             if (csarInstaller.isCsarAlreadyDeployed(csar)) {\r
                 sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,\r
-                        DistributionStatusEnum.ALREADY_DOWNLOADED, null);\r
+                    DistributionStatusEnum.ALREADY_DOWNLOADED, null);\r
                 sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,\r
-                        DistributionStatusEnum.ALREADY_DEPLOYED, null);\r
+                    DistributionStatusEnum.ALREADY_DEPLOYED, null);\r
             } else {\r
                 sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,\r
-                        DistributionStatusEnum.DOWNLOAD_OK, null);\r
+                    DistributionStatusEnum.DOWNLOAD_OK, null);\r
                 csarInstaller.installTheCsar(csar);\r
                 sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,\r
-                        DistributionStatusEnum.DEPLOY_OK, null);\r
+                    DistributionStatusEnum.DEPLOY_OK, null);\r
             }\r
         } catch (SdcArtifactInstallerException | SdcToscaParserException e) {\r
             logger.error("SdcArtifactInstallerException exception caught during the notification processing", e);\r
             sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,\r
-                    DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());\r
+                DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());\r
         } catch (SdcDownloadException | CsarHandlerException e) {\r
             logger.error("SdcDownloadException exception caught during the notification processing", e);\r
             sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,\r
-                    DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage());\r
+                DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage());\r
         } catch (InterruptedException e) {\r
             logger.error("Interrupt exception caught during the notification processing", e);\r
             sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,\r
-                    DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());\r
+                DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());\r
             Thread.currentThread().interrupt();\r
         } catch (RuntimeException e) {\r
             logger.error("Unexpected exception caught during the notification processing", e);\r
             sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,\r
-                    DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());\r
+                DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());\r
         } finally {\r
             this.changeControllerStatus(SdcSingleControllerStatus.IDLE);\r
         }\r
@@ -276,8 +276,8 @@ public class SdcSingleController {
     }\r
 \r
     private IDistributionClientDownloadResult downloadTheArtifact(IArtifactInfo artifact) throws SdcDownloadException {\r
-        logger.info("Trying to download the artifact : " + artifact.getArtifactURL() + " UUID: "\r
-                + artifact.getArtifactUUID());\r
+        logger.info(\r
+            "Trying to download the artifact : " + artifact.getArtifactURL() + " UUID: " + artifact.getArtifactUUID());\r
         IDistributionClientDownloadResult downloadResult;\r
         try {\r
             downloadResult = distributionClient.download(artifact);\r
@@ -290,20 +290,20 @@ public class SdcSingleController {
         }\r
         if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult())) {\r
             logger.info("Successfully downloaded the artifact " + artifact.getArtifactURL() + " UUID "\r
-                    + artifact.getArtifactUUID() + "Size of payload " + downloadResult.getArtifactPayload().length);\r
+                + artifact.getArtifactUUID() + "Size of payload " + downloadResult.getArtifactPayload().length);\r
         } else {\r
-            throw new SdcDownloadException("Artifact " + artifact.getArtifactName()\r
-                    + " could not be downloaded from SDC URL " + artifact.getArtifactURL() + " UUID "\r
-                    + artifact.getArtifactUUID() + ")" + System.lineSeparator() + "Error message is "\r
-                    + downloadResult.getDistributionMessageResult() + System.lineSeparator());\r
+            throw new SdcDownloadException(\r
+                "Artifact " + artifact.getArtifactName() + " could not be downloaded from SDC URL "\r
+                    + artifact.getArtifactURL() + " UUID " + artifact.getArtifactUUID() + ")" + System.lineSeparator()\r
+                    + "Error message is " + downloadResult.getDistributionMessageResult() + System.lineSeparator());\r
         }\r
         return downloadResult;\r
     }\r
 \r
     private void sendSdcNotification(NotificationType notificationType, String artifactURL, String consumerID,\r
-            String distributionID, DistributionStatusEnum status, String errorReason, long timestamp) {\r
+        String distributionID, DistributionStatusEnum status, String errorReason, long timestamp) {\r
         String event = "Sending " + notificationType.name() + "(" + status.name() + ")"\r
-                + " notification to SDC for artifact:" + artifactURL;\r
+            + " notification to SDC for artifact:" + artifactURL;\r
         if (errorReason != null) {\r
             event = event + "(" + errorReason + ")";\r
         }\r
@@ -311,18 +311,18 @@ public class SdcSingleController {
         String action = "";\r
         try {\r
             IDistributionStatusMessage message = new DistributionStatusMessage(artifactURL, consumerID, distributionID,\r
-                    status, timestamp);\r
+                status, timestamp);\r
             switch (notificationType) {\r
-                case DOWNLOAD:\r
-                    this.sendDownloadStatus(message, errorReason);\r
-                    action = "sendDownloadStatus";\r
-                    break;\r
-                case DEPLOY:\r
-                    this.sendDeploymentStatus(message, errorReason);\r
-                    action = "sendDeploymentdStatus";\r
-                    break;\r
-                default:\r
-                    break;\r
+            case DOWNLOAD:\r
+                this.sendDownloadStatus(message, errorReason);\r
+                action = "sendDownloadStatus";\r
+                break;\r
+            case DEPLOY:\r
+                this.sendDeploymentStatus(message, errorReason);\r
+                action = "sendDeploymentdStatus";\r
+                break;\r
+            default:\r
+                break;\r
             }\r
         } catch (RuntimeException e) {\r
             logger.warn("Unable to send the SDC Notification (" + action + ") due to an exception", e);\r
index 1a16212..3f0a078 100644 (file)
@@ -1,15 +1,15 @@
 /*-
  * ============LICENSE_START=======================================================
- * ONAP - SO
+ * ONAP CLAMP
  * ================================================================================
  * Copyright (C) 2017 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.
  * 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.
 package org.onap.clamp.clds.config.sdc;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
@@ -46,19 +43,19 @@ import org.onap.clamp.clds.util.ResourceFileUtil;
  */
 public class SdcSingleControllerConfigurationTest {
 
-    private SdcSingleControllerConfiguration loadControllerConfiguration(String fileName, String sdcControllerName)
-            throws IOException {
+    public static SdcSingleControllerConfiguration loadControllerConfiguration(String fileName,
+        String sdcControllerName) throws IOException {
         JsonNode jsonNode = new ObjectMapper().readValue(ResourceFileUtil.getResourceAsStream(fileName),
-                JsonNode.class);
+            JsonNode.class);
         SdcSingleControllerConfiguration sdcSingleControllerConfiguration = new SdcSingleControllerConfiguration(
-                jsonNode, sdcControllerName);
+            jsonNode, sdcControllerName);
         return sdcSingleControllerConfiguration;
     }
 
     @Test
     public final void testTheInit() throws SdcParametersException, IOException {
         SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
-                "sdc-controller1");
+            "sdc-controller1");
         assertEquals("User", sdcConfig.getUser());
         assertEquals("ThePassword", sdcConfig.getPassword());
         assertEquals("consumerGroup", sdcConfig.getConsumerGroup());
@@ -78,7 +75,7 @@ public class SdcSingleControllerConfigurationTest {
     @Test(expected = SdcParametersException.class)
     public final void testAllRequiredParameters() throws IOException {
         SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
-                "sdc-controller1");
+            "sdc-controller1");
         // No exception should be raised
         sdcConfig.testAllRequiredParameters();
         sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-bad.json", "sdc-controller1");
@@ -86,10 +83,9 @@ public class SdcSingleControllerConfigurationTest {
     }
 
     @Test
-    public final void testAllRequiredParametersEmptyEncrypted()
-            throws IOException {
+    public final void testAllRequiredParametersEmptyEncrypted() throws IOException {
         SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration(
-                "clds/sdc-controller-config-empty-encrypted.json", "sdc-controller1");
+            "clds/sdc-controller-config-empty-encrypted.json", "sdc-controller1");
         sdcConfig.testAllRequiredParameters();
         assertNull(sdcConfig.getKeyStorePassword());
     }
@@ -97,7 +93,7 @@ public class SdcSingleControllerConfigurationTest {
     @Test
     public final void testConsumerGroupWithNull() throws IOException {
         SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-NULL.json",
-                "sdc-controller1");
+            "sdc-controller1");
         assertTrue(sdcConfig.getConsumerGroup() == null);
     }
 }
index 4b63248..0cab4b9 100644 (file)
@@ -1,15 +1,15 @@
 /*-
  * ============LICENSE_START=======================================================
- * ONAP - SO
+ * ONAP CLAMP
  * ================================================================================
  * Copyright (C) 2017 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.
  * 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.
@@ -56,7 +56,7 @@ public class SdcControllersConfigurationItCase {
     public void testGetAllDefinedControllers() throws IOException {
         loadFile("classpath:/clds/sdc-controllers-config.json");
         Map<String, SdcSingleControllerConfiguration> mapResult = sdcControllersConfiguration
-                .getAllDefinedControllers();
+            .getAllDefinedControllers();
         assertTrue(mapResult.size() == 2);
         assertEquals("sdc-controller1", mapResult.get("sdc-controller1").getSdcControllerName());
         assertEquals("sdc-controller2", mapResult.get("sdc-controller2").getSdcControllerName());
@@ -65,10 +65,10 @@ public class SdcControllersConfigurationItCase {
     @Test
     public void testGetSdcSingleControllerConfiguration() throws IOException {
         loadFile("classpath:/clds/sdc-controllers-config.json");
-        assertEquals("sdc-controller1", sdcControllersConfiguration
-                .getSdcSingleControllerConfiguration("sdc-controller1").getSdcControllerName());
-        assertEquals("sdc-controller2", sdcControllersConfiguration
-                .getSdcSingleControllerConfiguration("sdc-controller2").getSdcControllerName());
+        assertEquals("sdc-controller1",
+            sdcControllersConfiguration.getSdcSingleControllerConfiguration("sdc-controller1").getSdcControllerName());
+        assertEquals("sdc-controller2",
+            sdcControllersConfiguration.getSdcSingleControllerConfiguration("sdc-controller2").getSdcControllerName());
     }
 
     @Test(expected = IOException.class)
diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java
new file mode 100644 (file)
index 0000000..9eaca5f
--- /dev/null
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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.clamp.clds.it.sdc.controller;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.assertj.core.api.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfigurationTest;
+import org.onap.clamp.clds.sdc.controller.SdcSingleController;
+import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
+import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.api.notification.IResourceInstance;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SdcSingleControllerItCase {
+
+    private static final String SDC_FOLDER = "/tmp/csar-handler-tests";
+    private static final String CSAR_ARTIFACT_NAME = "testArtifact.csar";
+    private static final String SERVICE_UUID = "serviceUUID";
+    private static final String RESOURCE1_UUID = "resource1UUID";
+    private static final String RESOURCE1_INSTANCE_NAME = "sim-1802 0";
+    private static final String RESOURCE1_INSTANCE_NAME_IN_CSAR = "sim18020";
+    private static final String BLUEPRINT1_NAME = "FOI.Simfoimap223S0112.event_proc_bp.yaml";
+
+    @Autowired
+    private ClampProperties clampProp;
+
+    private SdcSingleController sdcSingleController;
+
+    private INotificationData buildFakeSdcNotification() {
+        // BUild what is needed for CSAR
+        IArtifactInfo serviceArtifact = Mockito.mock(IArtifactInfo.class);
+        Mockito.when(serviceArtifact.getArtifactType()).thenReturn(CsarHandler.CSAR_TYPE);
+        Mockito.when(serviceArtifact.getArtifactName()).thenReturn(CSAR_ARTIFACT_NAME);
+        List<IArtifactInfo> servicesList = new ArrayList<>();
+        servicesList.add(serviceArtifact);
+        INotificationData notifData = Mockito.mock(INotificationData.class);
+        Mockito.when(notifData.getServiceArtifacts()).thenReturn(servicesList);
+        // Build what is needed for UUID
+        Mockito.when(notifData.getServiceInvariantUUID()).thenReturn(SERVICE_UUID);
+        // Build fake resource with one artifact BLUEPRINT
+        IResourceInstance resource1 = Mockito.mock(IResourceInstance.class);
+        Mockito.when(resource1.getResourceType()).thenReturn("VF");
+        Mockito.when(resource1.getResourceInvariantUUID()).thenReturn(RESOURCE1_UUID);
+        Mockito.when(resource1.getResourceInstanceName()).thenReturn(RESOURCE1_INSTANCE_NAME);
+        // Create a fake artifact for resource
+        IArtifactInfo blueprintArtifact = Mockito.mock(IArtifactInfo.class);
+        Mockito.when(blueprintArtifact.getArtifactType()).thenReturn(CsarHandler.BLUEPRINT_TYPE);
+        List<IArtifactInfo> artifactsListForResource = new ArrayList<>();
+        artifactsListForResource.add(blueprintArtifact);
+        Mockito.when(resource1.getArtifacts()).thenReturn(artifactsListForResource);
+        List<IResourceInstance> resourcesList = new ArrayList<>();
+        resourcesList.add(resource1);
+        Mockito.when(notifData.getResources()).thenReturn(resourcesList);
+        return notifData;
+    }
+
+    @Before
+    public void init() throws IOException {
+        sdcSingleController = new SdcSingleController(clampProp, Mockito.mock(CsarInstaller.class),
+            SdcSingleControllerConfigurationTest.loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
+                "sdc-controller1"),
+            null) {
+        };
+    }
+
+    @Test
+    public void testTreatNotification() {
+        sdcSingleController.treatNotification(buildFakeSdcNotification());
+        Assertions.assertThat(sdcSingleController.getNbOfNotificationsOngoing()).isEqualTo(0);
+
+    }
+
+}
diff --git a/src/test/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfoTest.java b/src/test/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfoTest.java
new file mode 100644 (file)
index 0000000..119fd21
--- /dev/null
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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=========================================================
+ * Modifications copyright (c) 2018 Nokia
+ * ================================================================================
+ *
+ */
+
+package org.onap.clamp.clds.model.sdc;
+
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
+
+public class SdcResourceBasicInfoTest {
+
+    @Test
+    public void testHashCode() {
+        SdcResourceBasicInfo sdc1a = new SdcResourceBasicInfo();
+        SdcResourceBasicInfo sdc1b = new SdcResourceBasicInfo();
+        SdcResourceBasicInfo sdc2 = new SdcResourceBasicInfo();
+        sdc1a.setName("test1");
+        sdc1a.setVersion("1.0");
+        sdc1b.setName("test1");
+        sdc1b.setVersion("2.0");
+        sdc2.setName("test2");
+        sdc2.setVersion("2.0");
+
+        Assertions.assertThat(sdc1a.hashCode()).isNotEqualTo(sdc1b.hashCode());
+        Assertions.assertThat(sdc1b.hashCode()).isNotEqualTo(sdc2.hashCode());
+        sdc1b.setVersion("1.0");
+        Assertions.assertThat(sdc1a.hashCode()).isEqualTo(sdc1b.hashCode());
+
+    }
+
+    @Test
+    public void testCompareTo() {
+        SdcResourceBasicInfo sdc1a = new SdcResourceBasicInfo();
+        SdcResourceBasicInfo sdc1b = new SdcResourceBasicInfo();
+        SdcResourceBasicInfo sdc2 = new SdcResourceBasicInfo();
+        sdc1a.setName("test1");
+        sdc1a.setVersion("1.0");
+        sdc1b.setName("test1");
+        sdc1b.setVersion("2.0");
+        sdc2.setName("test2");
+        sdc2.setVersion("2.0");
+
+        Assertions.assertThat(sdc1a.compareTo(sdc1b)).isEqualTo(-1);
+        Assertions.assertThat(sdc1b.compareTo(sdc1a)).isEqualTo(1);
+        Assertions.assertThat(sdc1a.compareTo(sdc1a)).isEqualTo(0);
+        Assertions.assertThat(sdc1a.compareTo(sdc2)).isEqualTo(-1);
+    }
+
+    @Test
+    public void testEquals() {
+        SdcResourceBasicInfo sdc1a = new SdcResourceBasicInfo();
+        SdcResourceBasicInfo sdc1b = new SdcResourceBasicInfo();
+        SdcResourceBasicInfo sdc2 = new SdcResourceBasicInfo();
+        sdc1a.setName("test1");
+        sdc1a.setVersion("1.0");
+        sdc1b.setName("test1");
+        sdc1b.setVersion("2.0");
+        sdc2.setName("test2");
+        sdc2.setVersion("2.0");
+
+        Assertions.assertThat(sdc1a.equals(sdc1a)).isTrue();
+        Assertions.assertThat(sdc1a.equals(sdc1b)).isFalse();
+
+        sdc1b.setVersion(null);
+        Assertions.assertThat(sdc1a.equals(sdc1b)).isFalse();
+        sdc1b.setVersion("1.0");
+        Assertions.assertThat(sdc1a.equals(sdc1b)).isTrue();
+        sdc1a.setVersion(null);
+        sdc1b.setVersion(null);
+        Assertions.assertThat(sdc1a.equals(sdc1b)).isTrue();
+
+        sdc1b.setName(null);
+        Assertions.assertThat(sdc1a.equals(sdc1b)).isFalse();
+        sdc1b.setName("test1");
+        Assertions.assertThat(sdc1a.equals(sdc1b)).isTrue();
+        sdc1a.setName(null);
+        sdc1b.setName(null);
+        Assertions.assertThat(sdc1a.equals(sdc1b)).isTrue();
+    }
+
+}
index 8305c2e..2103b4a 100644 (file)
@@ -4,45 +4,56 @@
                                <choice>
                                                <when>
                                                                <simple> ${exchangeProperty.actionCd} == 'SUBMIT' || ${exchangeProperty.actionCd} == 'RESUBMIT'</simple>
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'INITIATED')" />
                                                                <to uri="bean:org.onap.clamp.clds.client.TcaPolicyDelegate" />
                                                                <to uri="bean:org.onap.clamp.clds.client.HolmesPolicyDelegate" />
                                                                <delay>
                                                                                <constant>30000</constant>
                                                                </delay>
                                                                <to uri="bean:org.onap.clamp.clds.client.OperationalPolicyDelegate" />
-                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.GuardPolicyDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'COMPLETED')" />
                                                </when>
                                                <when>
                                                                <simple> ${exchangeProperty.actionCd} == 'DELETE'</simple>
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'INITIATED')" />
                                                                <to uri="bean:org.onap.clamp.clds.client.TcaPolicyDeleteDelegate" />
                                                                <to uri="bean:org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate" />
-                                                               <to uri="bean:org.onap.clamp.clds.client.ModelDeleteDelegate" />
                                                                <delay>
                                                                                <constant>30000</constant>
                                                                </delay>
                                                                <to
                                                                                uri="bean:org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.GuardPolicyDeleteDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.ModelDeleteDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'COMPLETED')" />
                                                </when>
                                                <when>
                                                                <simple> ${exchangeProperty.actionCd} == 'UPDATE'</simple>
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'INITIATED')" />
                                                                <to uri="bean:org.onap.clamp.clds.client.TcaPolicyDelegate" />
                                                                <to uri="bean:org.onap.clamp.clds.client.HolmesPolicyDelegate" />
                                                                <delay>
                                                                                <constant>30000</constant>
                                                                </delay>
                                                                <to uri="bean:org.onap.clamp.clds.client.OperationalPolicyDelegate" />
-                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.GuardPolicyDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'COMPLETED')" />
                                                </when>
                                                <when>
                                                                <simple> ${exchangeProperty.actionCd} == 'STOP'</simple>
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'INITIATED')" />
                                                                <to
                                                                                uri="bean:org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate" />
-                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.GuardPolicyDeleteDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'COMPLETED')" />
                                                </when>
                                                <when>
                                                                <simple> ${exchangeProperty.actionCd} == 'RESTART'</simple>
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'INITIATED')" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.GuardPolicyDelegate" />
                                                                <to uri="bean:org.onap.clamp.clds.client.OperationalPolicyDelegate" />
-                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate" />
+                                                               <to uri="bean:org.onap.clamp.clds.client.CldsEventDelegate?method=addEvent(*,'COMPLETED')" />
                                                </when>
                                </choice>
                </route>