summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java25
-rw-r--r--src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java16
-rw-r--r--src/main/java/org/onap/clamp/clds/dao/CldsDao.java83
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java16
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/Holmes.java18
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java28
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/Policy.java17
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/Tca.java18
-rw-r--r--src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java18
-rw-r--r--src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java7
10 files changed, 133 insertions, 113 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java
index a758716b8..3229337b0 100644
--- a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java
+++ b/src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -26,19 +28,15 @@ package org.onap.clamp.clds.client;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import java.io.UnsupportedEncodingException;
-
import org.apache.camel.Exchange;
import org.apache.camel.Handler;
import org.onap.clamp.clds.client.req.policy.GuardPolicyAttributesConstructor;
import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.model.properties.Policy;
import org.onap.clamp.clds.model.properties.PolicyChain;
import org.onap.clamp.clds.model.properties.PolicyItem;
import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -52,41 +50,32 @@ public class GuardPolicyDelegate {
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(GuardPolicyDelegate.class);
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
private final PolicyClient policyClient;
- private final ClampProperties refProp;
@Autowired
- public GuardPolicyDelegate(PolicyClient policyClient, ClampProperties refProp) {
+ public GuardPolicyDelegate(PolicyClient policyClient) {
this.policyClient = policyClient;
- this.refProp = refProp;
}
/**
* Perform activity. Send Guard Policies info to policy api.
*
- * @param camelExchange
- * The Camel Exchange object containing the properties
- * @throws BuilderException
- * In case of issues with OperationalPolicyRequestAttributesConstructor
- * @throws UnsupportedEncodingException
- * In case of issues with the Charset encoding
+ * @param camelExchange The Camel Exchange object containing the properties
*/
@Handler
- public void execute(Exchange camelExchange) throws BuilderException, UnsupportedEncodingException {
+ public void execute(Exchange camelExchange) {
ModelProperties prop = ModelProperties.create(camelExchange);
Policy policy = prop.getType(Policy.class);
if (policy.isFound()) {
for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- for (PolicyItem policyItem:GuardPolicyAttributesConstructor
+ for (PolicyItem policyItem : GuardPolicyAttributesConstructor
.getAllPolicyGuardsFromPolicyChain(policyChain)) {
prop.setCurrentModelElementId(policy.getId());
prop.setPolicyUniqueId(policyChain.getPolicyId());
prop.setGuardUniqueId(policyItem.getId());
policyClient.sendGuardPolicy(GuardPolicyAttributesConstructor
- .formatAttributes(prop, policyItem), prop, LoggingUtils.getRequestId(), policyItem);
+ .formatAttributes(prop, policyItem), prop, LoggingUtils.getRequestId(), policyItem);
}
}
}
}
-
-
}
diff --git a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java
index 941f519e5..ae962a0bb 100644
--- a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java
+++ b/src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -30,7 +32,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.Handler;
import org.onap.clamp.clds.client.req.policy.GuardPolicyAttributesConstructor;
import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.model.properties.Policy;
@@ -46,21 +47,19 @@ import org.springframework.stereotype.Component;
public class GuardPolicyDeleteDelegate {
protected static final EELFLogger logger = EELFManager.getInstance()
- .getLogger(GuardPolicyDeleteDelegate.class);
+ .getLogger(GuardPolicyDeleteDelegate.class);
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
private final PolicyClient policyClient;
- private final ClampProperties refProp;
@Autowired
- public GuardPolicyDeleteDelegate(PolicyClient policyClient, ClampProperties refProp) {
+ public GuardPolicyDeleteDelegate(PolicyClient policyClient) {
this.policyClient = policyClient;
- this.refProp = refProp;
}
+
/**
* Perform activity. Delete Operational Policy via policy api.
*
- * @param camelExchange
- * The Camel Exchange object containing the properties
+ * @param camelExchange The Camel Exchange object containing the properties
*/
@Handler
public void execute(Exchange camelExchange) {
@@ -70,7 +69,7 @@ public class GuardPolicyDeleteDelegate {
String eventAction = (String) camelExchange.getProperty("eventAction");
if (!eventAction.equalsIgnoreCase(CldsEvent.ACTION_CREATE) && policy.isFound()) {
for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- for (PolicyItem policyItem:GuardPolicyAttributesConstructor
+ for (PolicyItem policyItem : GuardPolicyAttributesConstructor
.getAllPolicyGuardsFromPolicyChain(policyChain)) {
prop.setCurrentModelElementId(policy.getId());
prop.setPolicyUniqueId(policyChain.getPolicyId());
@@ -80,5 +79,4 @@ public class GuardPolicyDeleteDelegate {
}
}
}
-
}
diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
index 0cf68ea1b..8378af8c5 100644
--- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
+++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -505,14 +507,15 @@ public class CldsDao {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
List<CldsToscaModel> cldsToscaModels = new ArrayList<>();
- String toscaModelSql = "SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, "
- + "tmr.tosca_model_revision_id, tmr.tosca_model_json, tmr.version, tmr.user_id, tmr.createdTimestamp, "
- + "tmr.lastUpdatedTimestamp " + ((toscaModelName != null) ? (", tmr.tosca_model_yaml ") : " ")
- + "FROM tosca_model tm, tosca_model_revision tmr WHERE tm.tosca_model_id = tmr.tosca_model_id "
- + ((toscaModelName != null) ? (" AND tm.tosca_model_name = '" + toscaModelName + "'") : " ")
- + ((policyType != null) ? (" AND tm.policy_type = '" + policyType + "'") : " ")
- + "AND tmr.version = (select max(version) from tosca_model_revision st "
- + "where tmr.tosca_model_id=st.tosca_model_id)";
+ String toscaModelSql = new StringBuilder("SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, " +
+ "tmr.tosca_model_revision_id, tmr.tosca_model_json, tmr.version, tmr.user_id, tmr.createdTimestamp, " +
+ "tmr.lastUpdatedTimestamp")
+ .append(toscaModelName != null ? (", tmr.tosca_model_yaml") : "")
+ .append(" FROM tosca_model tm, tosca_model_revision tmr WHERE tm.tosca_model_id = tmr.tosca_model_id")
+ .append(toscaModelName != null ? (" AND tm.tosca_model_name = '" + toscaModelName + "'") : "")
+ .append(policyType != null ? (" AND tm.policy_type = '" + policyType + "'") : "")
+ .append(" AND tmr.version = (select max(version) from tosca_model_revision st where tmr.tosca_model_id=st.tosca_model_id)")
+ .toString();
List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(toscaModelSql);
@@ -605,8 +608,11 @@ public class CldsDao {
*/
public void updateDictionary(String dictionaryId, CldsDictionary cldsDictionary, String userId) {
- String dictionarySql = "UPDATE dictionary " + "SET dictionary_name = '" + cldsDictionary.getDictionaryName()
- + "', modified_by = '" + userId + "'" + "WHERE dictionary_id = '" + dictionaryId + "'";
+ String dictionarySql = new StringBuilder("UPDATE dictionary SET dictionary_name = '")
+ .append(cldsDictionary.getDictionaryName())
+ .append("', modified_by = '").append(userId)
+ .append("'WHERE dictionary_id = '").append(dictionaryId).append("'")
+ .toString();
jdbcTemplateObject.update(dictionarySql);
cldsDictionary.setUpdatedBy(userId);
}
@@ -623,13 +629,21 @@ public class CldsDao {
public List<CldsDictionary> getDictionary(String dictionaryId, String dictionaryName) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
List<CldsDictionary> dictionaries = new ArrayList<>();
- String dictionarySql = "SELECT dictionary_id, dictionary_name, created_by, modified_by, "
- + "timestamp FROM dictionary"
- + ((dictionaryId != null || dictionaryName != null)
- ? (" WHERE " + ((dictionaryName != null) ? ("dictionary_name = '" + dictionaryName + "'") : "")
- + ((dictionaryId != null && dictionaryName != null) ? (" AND ") : "")
- + ((dictionaryId != null) ? ("dictionary_id = '" + dictionaryId + "'") : ""))
- : "");
+
+ String whereFilter = " WHERE ";
+ if (dictionaryName != null) {
+ whereFilter += "dictionary_name = '" + dictionaryName + "'";
+ if (dictionaryId != null){
+ whereFilter += " AND dictionary_id = '" + dictionaryId + "'";
+ }
+ } else if (dictionaryId != null) {
+ whereFilter += "dictionary_id = '" + dictionaryId + "'";
+ } else {
+ whereFilter = "";
+ }
+ String dictionarySql = new StringBuilder("SELECT dictionary_id, dictionary_name, created_by, " +
+ "modified_by, timestamp FROM dictionary")
+ .append(whereFilter).toString();
List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
@@ -680,12 +694,15 @@ public class CldsDao {
public void updateDictionaryElements(String dictionaryElementId, CldsDictionaryItem cldsDictionaryItem,
String userId) {
- String dictionarySql = "UPDATE dictionary_elements SET dict_element_name = '"
- + cldsDictionaryItem.getDictElementName() + "', dict_element_short_name = '"
- + cldsDictionaryItem.getDictElementShortName() + "', dict_element_description= '"
- + cldsDictionaryItem.getDictElementDesc() + "', dict_element_type = '"
- + cldsDictionaryItem.getDictElementType() + "', modified_by = '" + userId + "' "
- + "WHERE dict_element_id = '" + dictionaryElementId + "'";
+ String dictionarySql = new StringBuilder().append("UPDATE dictionary_elements SET dict_element_name = '")
+ .append(cldsDictionaryItem.getDictElementName())
+ .append("', dict_element_short_name = '").append(cldsDictionaryItem.getDictElementShortName())
+ .append("', dict_element_description= '").append(cldsDictionaryItem.getDictElementDesc())
+ .append("', dict_element_type = '").append(cldsDictionaryItem.getDictElementType())
+ .append("', modified_by = '").append(userId).append("'")
+ .append(" WHERE dict_element_id = '")
+ .append(dictionaryElementId).append("'")
+ .toString();
jdbcTemplateObject.update(dictionarySql);
cldsDictionaryItem.setUpdatedBy(userId);
}
@@ -706,14 +723,13 @@ public class CldsDao {
String dictElementShortName) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
List<CldsDictionaryItem> dictionaryItems = new ArrayList<>();
- String dictionarySql = "SELECT de.dict_element_id, de.dictionary_id, de.dict_element_name, "
- + "de.dict_element_short_name, de.dict_element_description, de.dict_element_type, de.created_by, "
- + "de.modified_by, de.timestamp "
- + "FROM dictionary_elements de, dictionary d WHERE de.dictionary_id = d.dictionary_id "
- + ((dictionaryId != null) ? (" AND d.dictionary_id = '" + dictionaryId + "'") : "")
- + ((dictElementShortName != null) ? (" AND de.dict_element_short_name = '" + dictElementShortName + "'")
- : "")
- + ((dictionaryName != null) ? (" AND dictionary_name = '" + dictionaryName + "'") : "");
+ String dictionarySql = new StringBuilder("SELECT de.dict_element_id, de.dictionary_id, de.dict_element_name, " +
+ "de.dict_element_short_name, de.dict_element_description, de.dict_element_type, de.created_by, " +
+ "de.modified_by, de.timestamp FROM dictionary_elements de, " +
+ "dictionary d WHERE de.dictionary_id = d.dictionary_id")
+ .append((dictionaryId != null) ? (" AND d.dictionary_id = '" + dictionaryId + "'") : "")
+ .append((dictElementShortName != null) ? (" AND de.dict_element_short_name = '" + dictElementShortName + "'") : "")
+ .append((dictionaryName != null) ? (" AND dictionary_name = '" + dictionaryName + "'") : "").toString();
List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
@@ -745,8 +761,9 @@ public class CldsDao {
*/
public Map<String, String> getDictionaryElementsByType(String dictionaryElementType) {
Map<String, String> dictionaryItems = new HashMap<>();
- String dictionarySql = "SELECT dict_element_name, dict_element_short_name " + "FROM dictionary_elements "
- + "WHERE dict_element_type = '" + dictionaryElementType + "'";
+ String dictionarySql = new StringBuilder("SELECT dict_element_name, dict_element_short_name " +
+ "FROM dictionary_elements WHERE dict_element_type = '")
+ .append(dictionaryElementType).append("'").toString();
List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
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 73f708c29..9c15524d6 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
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -36,21 +38,15 @@ public abstract class AbstractModelElement {
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class);
protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- private final String type;
- private final ModelBpmn modelBpmn;
private final String id;
protected String topicPublishes;
protected final JsonElement modelElementJsonNode;
- private boolean isFound;
- private final ModelProperties modelProp;
+ private final boolean isFound;
/**
* Perform base parsing of properties for a ModelElement (such as, VesCollector, Policy and Tca).
*/
- protected AbstractModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) {
- this.type = type;
- this.modelProp = modelProp;
- this.modelBpmn = modelBpmn;
+ protected AbstractModelElement(String type, ModelBpmn modelBpmn, JsonObject modelJson) {
this.id = modelBpmn.getId(type);
this.modelElementJsonNode = modelJson.get(id);
this.isFound = modelBpmn.isModelElementTypeInList(type);
@@ -58,15 +54,16 @@ public abstract class AbstractModelElement {
/**
* Get the topic publishes.
+ *
* @return the topicPublishes
*/
public String getTopicPublishes() {
return topicPublishes;
}
-
/**
* Get the id.
+ *
* @return the id
*/
public String getId() {
@@ -75,6 +72,7 @@ public abstract class AbstractModelElement {
/**
* Get the isFound flag.
+ *
* @return the isFound
*/
public boolean isFound() {
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java b/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java
index 63c677d9a..a93b09cfa 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -18,7 +20,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.model.properties;
@@ -30,27 +32,22 @@ import org.onap.clamp.clds.util.JsonUtils;
* Parse Holmes bpmn parameters json properties.
* Example json:
* [{"name":"correlationalLogic","value":"vcwx"},{"name":"configPolicyName","value":"cccc"}]
- *
*/
public class Holmes extends AbstractModelElement {
private static final String TYPE_HOLMES = "holmes";
- private String correlationLogic;
-
- private String configPolicyName;
+ private String correlationLogic;
+ private String configPolicyName;
/**
* Default constructor for Holmes Element.
*
- * @param modelProp
- * The ModelProperties containing the all the info, like bpmn,
- * bpmn params, etc ...
* @param modelBpmn The model bpmn
* @param modelJson The model json
*/
- public Holmes(ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) {
- super(TYPE_HOLMES, modelProp, modelBpmn, modelJson);
+ public Holmes(ModelBpmn modelBpmn, JsonObject modelJson) {
+ super(TYPE_HOLMES, modelBpmn, modelJson);
correlationLogic = JsonUtils.getStringValueByName(modelElementJsonNode, "correlationalLogic");
configPolicyName = JsonUtils.getStringValueByName(modelElementJsonNode, "configPolicyName");
@@ -67,5 +64,4 @@ public class Holmes extends AbstractModelElement {
public String getConfigPolicyName() {
return configPolicyName;
}
-
}
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 5160e10a3..a880893ee 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
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -118,19 +120,19 @@ 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, JsonObject.class)
- .newInstance(this, modelBpmn, modelJson)));
- } catch (InstantiationException | NoSuchMethodException | IllegalAccessException
- | InvocationTargetException e) {
- logger.warn("Unable to instantiate a ModelElement " + entry.getValue()
- + ", exception follows: ", e);
- }
- });
+ .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey())
+ && missingTypes.contains(entry.getValue())))
+ .forEach(entry -> {
+ try {
+ modelElements.put(entry.getValue(),
+ (entry.getKey().getConstructor(ModelBpmn.class, JsonObject.class)
+ .newInstance(modelBpmn, modelJson)));
+ } catch (InstantiationException | NoSuchMethodException | IllegalAccessException
+ | InvocationTargetException e) {
+ logger.warn("Unable to instantiate a ModelElement " + entry.getValue()
+ + ", exception follows: ", e);
+ }
+ });
}
}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Policy.java b/src/main/java/org/onap/clamp/clds/model/properties/Policy.java
index 9cb3635f0..9537cb9ed 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/Policy.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/Policy.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -25,9 +27,9 @@ package org.onap.clamp.clds.model.properties;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
@@ -51,23 +53,22 @@ import java.util.Map.Entry;
* "vf3RtPi"]}]]}]
*/
public class Policy extends AbstractModelElement {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class);
+ protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class);
protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- private List<PolicyChain> policyChains;
+ private List<PolicyChain> policyChains;
- private static final String TYPE_POLICY = "policy";
+ private static final String TYPE_POLICY = "policy";
/**
* Parse Policy given json node.
*
- * @param modelProp The model properties.
* @param modelBpmn The model bpmn
* @param modelJson The model json
* @throws IOException The IO Exception
*/
- public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) throws IOException {
- super(TYPE_POLICY, modelProp, modelBpmn, modelJson);
+ public Policy(ModelBpmn modelBpmn, JsonObject modelJson) throws IOException {
+ super(TYPE_POLICY, modelBpmn, modelJson);
// process policies
if (modelElementJsonNode != null) {
@@ -81,6 +82,7 @@ public class Policy extends AbstractModelElement {
/**
* Get the policy chains.
+ *
* @return the policyChains
*/
public List<PolicyChain> getPolicyChains() {
@@ -90,5 +92,4 @@ public class Policy extends AbstractModelElement {
public static final String getType() {
return TYPE_POLICY;
}
-
}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Tca.java b/src/main/java/org/onap/clamp/clds/model/properties/Tca.java
index 0d17b9542..efa0188e9 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/Tca.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/Tca.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -18,7 +20,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.model.properties;
@@ -27,31 +29,30 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+
import java.util.Map.Entry;
import java.util.Set;
/**
* Parse ONAP Tca json properties.
- *
*/
public class Tca extends AbstractModelElement {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class);
+ protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class);
protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- private TcaItem tcaItem;
+ private TcaItem tcaItem;
- private static final String TYPE_TCA = "tca";
+ private static final String TYPE_TCA = "tca";
/**
* Parse Tca given json node.
*
- * @param modelProp The model properties
* @param modelBpmn The model bpmn
* @param modelJson The model json
*/
- public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) {
- super(TYPE_TCA, modelProp, modelBpmn, modelJson);
+ public Tca(ModelBpmn modelBpmn, JsonObject modelJson) {
+ super(TYPE_TCA, modelBpmn, modelJson);
// process Server_Configurations
if (modelElementJsonNode != null) {
@@ -68,5 +69,4 @@ public class Tca extends AbstractModelElement {
public static final String getType() {
return TYPE_TCA;
}
-
}
diff --git a/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java b/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java
index 095df9d84..c92cdcf35 100644
--- a/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java
+++ b/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -31,7 +33,9 @@ import static org.mockito.Mockito.when;
import com.google.gson.JsonObject;
import java.io.IOException;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.clds.exception.TcaRequestFormatterException;
import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.model.properties.Tca;
import org.onap.clamp.clds.model.properties.TcaItem;
@@ -95,4 +99,18 @@ public class TcaRequestFormatterTest {
//then
assertThat(expectedRequest).isEqualTo(policyContent);
}
+
+ @Test(expected = TcaRequestFormatterException.class)
+ public void shouldThrowTcaRequestFormatterException() throws IOException{
+ //given
+ String service = "TestService";
+ String policy = "TestService_scope.PolicyName";
+ ClampProperties clampProperties = mock(ClampProperties.class);
+ ModelProperties modelProperties = mock(ModelProperties.class);
+ Tca tca = mock(Tca.class);
+ //when
+ Mockito.when(clampProperties.getJsonTemplate(any(), any())).thenThrow(IOException.class);
+ //then
+ TcaRequestFormatter.createPolicyContent(clampProperties, modelProperties, service, policy, tca);
+ }
} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java
index 871d0a651..31d0be880 100644
--- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java
+++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -26,7 +28,6 @@ package org.onap.clamp.clds.model.prop;
import com.google.gson.JsonObject;
import org.onap.clamp.clds.model.properties.AbstractModelElement;
import org.onap.clamp.clds.model.properties.ModelBpmn;
-import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.util.JsonUtils;
/**
@@ -40,8 +41,8 @@ public class CustomModelElement extends AbstractModelElement {
/**
* Main Constructor.
*/
- public CustomModelElement(ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) {
- super(CUSTOM_TYPE, modelProp, modelBpmn, modelJson);
+ public CustomModelElement(ModelBpmn modelBpmn, JsonObject modelJson) {
+ super(CUSTOM_TYPE, modelBpmn, modelJson);
topicPublishes = JsonUtils.getStringValueByName(modelElementJsonNode, "topicPublishes");
test = JsonUtils.getStringValueByName(modelElementJsonNode, "test");
}