summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java48
-rw-r--r--src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java20
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java51
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java129
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java126
-rw-r--r--src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java28
-rw-r--r--src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java16
-rw-r--r--src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java108
-rw-r--r--src/test/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfoTest.java100
-rw-r--r--src/test/resources/clds/camel/routes/flexible-flow.xml21
10 files changed, 393 insertions, 254 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
index 16c18ae0e..4151c7aad 100644
--- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.client;
@@ -64,7 +64,6 @@ public class DcaeDispatcherServices {
this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;
}
-
public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {
String operationStatus = "";
for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {
@@ -83,9 +82,9 @@ public class DcaeDispatcherServices {
/**
* Get the Operation Status from a specified URL.
- *
+ *
* @param statusUrl
- * The URL provided by a previous DCAE Query
+ * The URL provided by a previous DCAE Query
* @return The status
*/
public String getOperationStatus(String statusUrl) {
@@ -113,35 +112,14 @@ public class DcaeDispatcherServices {
}
/**
- * This method send a getDeployments operation to DCAE.
- */
- public void getDeployments() {
- Date startTime = new Date();
- LoggingUtils.setTargetContext("DCAE", "getDeployments");
- try {
- String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX;
- dcaeHttpConnectionManager.doDcaeHttpQuery(url, "GET", null, null);
- LoggingUtils.setResponseContext("0", "Get deployments success", this.getClass().getName());
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Get deployments failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Get deployments error");
- logger.error("Exception occurred during getDeployments Operation with DCAE", e);
- throw new DcaeDeploymentException("Exception occurred during getDeployments Operation with DCAE", e);
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("getDeployments complete");
- }
- }
-
- /**
* Returns status URL for createNewDeployment operation.
*
* @param deploymentId
- * The deployment ID
+ * The deployment ID
* @param serviceTypeId
- * Service type ID
+ * Service type ID
* @param blueprintInputJson
- * The value for each blueprint parameters in a flat JSON
+ * The value for each blueprint parameters in a flat JSON
* @return The status URL
*/
public String createNewDeployment(String deploymentId, String serviceTypeId, JsonNode blueprintInputJson) {
@@ -157,7 +135,7 @@ public class DcaeDispatcherServices {
logger.info("Dcae api Body String - " + apiBodyString);
String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
String statusUrl = getDcaeResponse(url, "PUT", apiBodyString, "application/json", DCAE_LINK_FIELD,
- DCAE_STATUS_FIELD);
+ DCAE_STATUS_FIELD);
LoggingUtils.setResponseContext("0", "Create new deployment failed", this.getClass().getName());
return statusUrl;
} catch (Exception e) {
@@ -173,11 +151,11 @@ public class DcaeDispatcherServices {
/***
* Returns status URL for deleteExistingDeployment operation.
- *
+ *
* @param deploymentId
- * The deployment ID
+ * The deployment ID
* @param serviceTypeId
- * The service Type ID
+ * The service Type ID
* @return The status URL
*/
public String deleteExistingDeployment(String deploymentId, String serviceTypeId) {
@@ -188,7 +166,7 @@ public class DcaeDispatcherServices {
logger.info("Dcae api Body String - " + apiBodyString);
String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
String statusUrl = getDcaeResponse(url, "DELETE", apiBodyString, "application/json", DCAE_LINK_FIELD,
- DCAE_STATUS_FIELD);
+ DCAE_STATUS_FIELD);
LoggingUtils.setResponseContext("0", "Delete existing deployment success", this.getClass().getName());
return statusUrl;
@@ -197,7 +175,7 @@ public class DcaeDispatcherServices {
LoggingUtils.setErrorContext("900", "Delete existing deployment error");
logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e);
throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE",
- e);
+ e);
} finally {
LoggingUtils.setTimeContext(startTime, new Date());
metricsLogger.info("deleteExistingDeployment complete");
@@ -205,7 +183,7 @@ public class DcaeDispatcherServices {
}
private String getDcaeResponse(String url, String requestMethod, String payload, String contentType, String node,
- String nodeAttr) throws IOException, ParseException {
+ String nodeAttr) throws IOException, ParseException {
Date startTime = new Date();
try {
String responseStr = dcaeHttpConnectionManager.doDcaeHttpQuery(url, requestMethod, payload, contentType);
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
index 055847085..1fb86c0ce 100644
--- a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
@@ -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);
});
}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
index 6bf4194bd..571e5b1bc 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
@@ -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;
@@ -63,23 +63,6 @@ public abstract class AbstractModelElement {
}
/**
- * 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
*/
public String getTopicPublishes() {
@@ -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
- * a 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
- * a 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);
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
index b56794005..3d7bbcc3a 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
@@ -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");
@@ -178,20 +175,6 @@ public class ModelProperties {
}
/**
- * 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
*/
public String getModelName() {
@@ -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;
@@ -349,26 +332,6 @@ public class ModelProperties {
}
/**
- * @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
*/
public Global getGlobal() {
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
index 8796bae1c..5959c0fb5 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
@@ -19,7 +19,7 @@
* ============LICENSE_END============================================
* Modifications copyright (c) 2018 Nokia
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.sdc.controller;
@@ -81,8 +81,8 @@ public class SdcSingleController {
}
/**
- * This method can be called multiple times at the same moment. The
- * controller must be thread safe !
+ * This method can be called multiple times at the same moment. The controller
+ * must be thread safe !
*/
@Override
public void activateCallback(INotificationData iNotif) {
@@ -91,7 +91,7 @@ public class SdcSingleController {
sdcController.treatNotification(iNotif);
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "SDC Notification received and processed successfully",
- this.getClass().getName());
+ this.getClass().getName());
}
}
@@ -110,16 +110,16 @@ public class SdcSingleController {
protected final synchronized void changeControllerStatus(SdcSingleControllerStatus newControllerStatus) {
switch (newControllerStatus) {
- case BUSY:
- ++this.nbOfNotificationsOngoing;
- this.controllerStatus = newControllerStatus;
- break;
- case IDLE:
- this.changeControllerStatusIdle();
- break;
- default:
- this.controllerStatus = newControllerStatus;
- break;
+ case BUSY:
+ ++this.nbOfNotificationsOngoing;
+ this.controllerStatus = newControllerStatus;
+ break;
+ case IDLE:
+ this.changeControllerStatusIdle();
+ break;
+ default:
+ this.controllerStatus = newControllerStatus;
+ break;
}
}
@@ -128,8 +128,9 @@ public class SdcSingleController {
}
public SdcSingleController(ClampProperties clampProp, CsarInstaller csarInstaller,
- SdcSingleControllerConfiguration sdcSingleConfig, boolean isClientAutoManaged) {
- this.isSdcClientAutoManaged = isClientAutoManaged;
+ SdcSingleControllerConfiguration sdcSingleConfig, IDistributionClient distributionClient) {
+ this.distributionClient = distributionClient;
+ isSdcClientAutoManaged = (distributionClient == null);
this.sdcConfig = sdcSingleConfig;
this.refProp = clampProp;
this.csarInstaller = csarInstaller;
@@ -139,11 +140,10 @@ public class SdcSingleController {
* This method initializes the SDC Controller and the SDC Client.
*
* @throws SdcControllerException
- * It throws an exception if the SDC Client cannot be
- * instantiated or if an init attempt is done when already
- * initialized
+ * It throws an exception if the SDC Client cannot be instantiated or if
+ * an init attempt is done when already initialized
* @throws SdcParametersException
- * If there is an issue with the parameters provided
+ * If there is an issue with the parameters provided
*/
public void initSdc() throws SdcControllerException {
logger.info("Attempt to initialize the SDC Controller: " + sdcConfig.getSdcControllerName());
@@ -157,8 +157,8 @@ public class SdcSingleController {
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
logger.error("SDC distribution client init failed with reason:" + result.getDistributionMessageResult());
this.changeControllerStatus(SdcSingleControllerStatus.STOPPED);
- throw new SdcControllerException("Initialization of the SDC Controller failed with reason: "
- + result.getDistributionMessageResult());
+ throw new SdcControllerException(
+ "Initialization of the SDC Controller failed with reason: " + result.getDistributionMessageResult());
}
logger.info("SDC Controller successfully initialized: " + sdcConfig.getSdcControllerName());
logger.info("Attempt to start the SDC Controller: " + sdcConfig.getSdcControllerName());
@@ -167,7 +167,7 @@ public class SdcSingleController {
logger.error("SDC distribution client start failed with reason:" + result.getDistributionMessageResult());
this.changeControllerStatus(SdcSingleControllerStatus.STOPPED);
throw new SdcControllerException(
- "Startup of the SDC Controller failed with reason: " + result.getDistributionMessageResult());
+ "Startup of the SDC Controller failed with reason: " + result.getDistributionMessageResult());
}
logger.info("SDC Controller successfully started: " + sdcConfig.getSdcControllerName());
this.changeControllerStatus(SdcSingleControllerStatus.IDLE);
@@ -177,8 +177,8 @@ public class SdcSingleController {
* This method closes the SDC Controller and the SDC Client.
*
* @throws SdcControllerException
- * It throws an exception if the SDC Client cannot be closed
- * because it's currently BUSY in processing notifications.
+ * It throws an exception if the SDC Client cannot be closed because
+ * it's currently BUSY in processing notifications.
*/
public void closeSdc() throws SdcControllerException {
if (this.getControllerStatus() == SdcSingleControllerStatus.BUSY) {
@@ -198,33 +198,33 @@ public class SdcSingleController {
}
private void sendAllNotificationForCsarHandler(INotificationData iNotif, CsarHandler csar,
- NotificationType notificationType, DistributionStatusEnum distributionStatus, String errorMessage) {
+ NotificationType notificationType, DistributionStatusEnum distributionStatus, String errorMessage) {
if (csar != null) {
// Notify for the CSAR
this.sendSdcNotification(notificationType, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
- System.currentTimeMillis());
+ sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
+ System.currentTimeMillis());
// Notify for all VF resources found
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
// Normally always 1 artifact in resource for Clamp as we
// specified
// only VF_METADATA type
this.sendSdcNotification(notificationType,
- blueprint.getValue().getResourceAttached().getArtifacts().get(0).getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
- System.currentTimeMillis());
+ blueprint.getValue().getResourceAttached().getArtifacts().get(0).getArtifactURL(),
+ sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
+ System.currentTimeMillis());
}
} else {
this.sendSdcNotification(notificationType, null, sdcConfig.getConsumerID(), iNotif.getDistributionID(),
- distributionStatus, errorMessage, System.currentTimeMillis());
+ distributionStatus, errorMessage, System.currentTimeMillis());
}
}
/**
* This method processes the notification received from Sdc.
- *
+ *
* @param iNotif
- * The INotificationData
+ * The INotificationData
*/
public void treatNotification(INotificationData iNotif) {
CsarHandler csar = null;
@@ -235,37 +235,37 @@ public class SdcSingleController {
logger.info("Notification received for service UUID:" + iNotif.getServiceUUID());
this.changeControllerStatus(SdcSingleControllerStatus.BUSY);
csar = new CsarHandler(iNotif, this.sdcConfig.getSdcControllerName(),
- refProp.getStringValue(CONFIG_SDC_FOLDER));
+ refProp.getStringValue(CONFIG_SDC_FOLDER));
csar.save(downloadTheArtifact(csar.getArtifactElement()));
if (csarInstaller.isCsarAlreadyDeployed(csar)) {
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
- DistributionStatusEnum.ALREADY_DOWNLOADED, null);
+ DistributionStatusEnum.ALREADY_DOWNLOADED, null);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.ALREADY_DEPLOYED, null);
+ DistributionStatusEnum.ALREADY_DEPLOYED, null);
} else {
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
- DistributionStatusEnum.DOWNLOAD_OK, null);
+ DistributionStatusEnum.DOWNLOAD_OK, null);
csarInstaller.installTheCsar(csar);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.DEPLOY_OK, null);
+ DistributionStatusEnum.DEPLOY_OK, null);
}
} catch (SdcArtifactInstallerException | SdcToscaParserException e) {
logger.error("SdcArtifactInstallerException exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
} catch (SdcDownloadException | CsarHandlerException e) {
logger.error("SdcDownloadException exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
- DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage());
+ DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage());
} catch (InterruptedException e) {
logger.error("Interrupt exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
Thread.currentThread().interrupt();
} catch (RuntimeException e) {
logger.error("Unexpected exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
} finally {
this.changeControllerStatus(SdcSingleControllerStatus.IDLE);
}
@@ -276,8 +276,8 @@ public class SdcSingleController {
}
private IDistributionClientDownloadResult downloadTheArtifact(IArtifactInfo artifact) throws SdcDownloadException {
- logger.info("Trying to download the artifact : " + artifact.getArtifactURL() + " UUID: "
- + artifact.getArtifactUUID());
+ logger.info(
+ "Trying to download the artifact : " + artifact.getArtifactURL() + " UUID: " + artifact.getArtifactUUID());
IDistributionClientDownloadResult downloadResult;
try {
downloadResult = distributionClient.download(artifact);
@@ -290,20 +290,20 @@ public class SdcSingleController {
}
if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult())) {
logger.info("Successfully downloaded the artifact " + artifact.getArtifactURL() + " UUID "
- + artifact.getArtifactUUID() + "Size of payload " + downloadResult.getArtifactPayload().length);
+ + artifact.getArtifactUUID() + "Size of payload " + downloadResult.getArtifactPayload().length);
} else {
- throw new SdcDownloadException("Artifact " + artifact.getArtifactName()
- + " could not be downloaded from SDC URL " + artifact.getArtifactURL() + " UUID "
- + artifact.getArtifactUUID() + ")" + System.lineSeparator() + "Error message is "
- + downloadResult.getDistributionMessageResult() + System.lineSeparator());
+ throw new SdcDownloadException(
+ "Artifact " + artifact.getArtifactName() + " could not be downloaded from SDC URL "
+ + artifact.getArtifactURL() + " UUID " + artifact.getArtifactUUID() + ")" + System.lineSeparator()
+ + "Error message is " + downloadResult.getDistributionMessageResult() + System.lineSeparator());
}
return downloadResult;
}
private void sendSdcNotification(NotificationType notificationType, String artifactURL, String consumerID,
- String distributionID, DistributionStatusEnum status, String errorReason, long timestamp) {
+ String distributionID, DistributionStatusEnum status, String errorReason, long timestamp) {
String event = "Sending " + notificationType.name() + "(" + status.name() + ")"
- + " notification to SDC for artifact:" + artifactURL;
+ + " notification to SDC for artifact:" + artifactURL;
if (errorReason != null) {
event = event + "(" + errorReason + ")";
}
@@ -311,18 +311,18 @@ public class SdcSingleController {
String action = "";
try {
IDistributionStatusMessage message = new DistributionStatusMessage(artifactURL, consumerID, distributionID,
- status, timestamp);
+ status, timestamp);
switch (notificationType) {
- case DOWNLOAD:
- this.sendDownloadStatus(message, errorReason);
- action = "sendDownloadStatus";
- break;
- case DEPLOY:
- this.sendDeploymentStatus(message, errorReason);
- action = "sendDeploymentdStatus";
- break;
- default:
- break;
+ case DOWNLOAD:
+ this.sendDownloadStatus(message, errorReason);
+ action = "sendDownloadStatus";
+ break;
+ case DEPLOY:
+ this.sendDeploymentStatus(message, errorReason);
+ action = "sendDeploymentdStatus";
+ break;
+ default:
+ break;
}
} catch (RuntimeException e) {
logger.warn("Unable to send the SDC Notification (" + action + ") due to an exception", e);
diff --git a/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java b/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java
index 1a1621271..3f0a078bb 100644
--- a/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java
+++ b/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java
@@ -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.
@@ -24,14 +24,11 @@
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);
}
}
diff --git a/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java b/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
index 4b632488a..0cab4b9d3 100644
--- a/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
@@ -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
index 000000000..9eaca5f73
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java
@@ -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
index 000000000..119fd2181
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfoTest.java
@@ -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();
+ }
+
+}
diff --git a/src/test/resources/clds/camel/routes/flexible-flow.xml b/src/test/resources/clds/camel/routes/flexible-flow.xml
index 8305c2e49..2103b4acf 100644
--- a/src/test/resources/clds/camel/routes/flexible-flow.xml
+++ b/src/test/resources/clds/camel/routes/flexible-flow.xml
@@ -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>