aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/clamp/clds/AbstractIT.java28
-rw-r--r--src/test/java/org/onap/clamp/clds/it/AsdcIT.java56
-rw-r--r--src/test/java/org/onap/clamp/clds/it/DcaeIT.java2
-rw-r--r--src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java208
-rw-r--r--src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java226
-rw-r--r--src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java47
-rw-r--r--src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java67
-rw-r--r--src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java69
8 files changed, 379 insertions, 324 deletions
diff --git a/src/test/java/org/onap/clamp/clds/AbstractIT.java b/src/test/java/org/onap/clamp/clds/AbstractIT.java
index 873c852ad..b705e38d1 100644
--- a/src/test/java/org/onap/clamp/clds/AbstractIT.java
+++ b/src/test/java/org/onap/clamp/clds/AbstractIT.java
@@ -1,3 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
package org.onap.clamp.clds;
import org.junit.BeforeClass;
@@ -6,14 +29,11 @@ import org.onap.clamp.clds.model.refprop.RefProp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles;
-/**
- * Created by j on 6/16/17.
- */
@ActiveProfiles("clamp-default")
public abstract class AbstractIT {
@Autowired
- protected RefProp refProp;
+ protected RefProp refProp;
@Autowired
protected PolicyClient policyClient;
diff --git a/src/test/java/org/onap/clamp/clds/it/AsdcIT.java b/src/test/java/org/onap/clamp/clds/it/AsdcIT.java
deleted file mode 100644
index d616b7e2e..000000000
--- a/src/test/java/org/onap/clamp/clds/it/AsdcIT.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-
-package org.onap.clamp.clds.it;
-
-import org.onap.clamp.clds.AbstractIT;
-import org.onap.clamp.clds.client.req.SdcReq;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.prop.ModelProperties;
-import org.onap.clamp.clds.transform.TransformUtil;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE Delegates in test.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class AsdcIT extends AbstractIT {
-
- @Test
- public void testBlueprint() throws Exception {
- String modelProp = TransformUtil.getResourceAsString("example/modelProp.json");
- String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnProp.json");
- String modelName = "example-model06";
- String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756";
- String docText = TransformUtil.getResourceAsString("example/templateProp.json");
- ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, modelBpmnProp, modelProp);
- String blueprint = SdcReq.formatBlueprint(refProp, prop, docText);
- System.out.println("blueprint=" + blueprint);
- }
-
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java b/src/test/java/org/onap/clamp/clds/it/DcaeIT.java
index aef4c64f6..54b27974d 100644
--- a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java
+++ b/src/test/java/org/onap/clamp/clds/it/DcaeIT.java
@@ -48,7 +48,7 @@ public class DcaeIT extends AbstractIT {
String modelName = "example-model";
String controlName = "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756";
- ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, modelBpmnProp, modelProp);
+ ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, modelProp);
String dcaeReq = DcaeReq.format(refProp, prop);
System.out.println("dcaeReq=" + dcaeReq);
diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java
index d0fcf42e6..7960c6afb 100644
--- a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java
+++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java
@@ -5,16 +5,16 @@
* 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.
+ * 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============================================
* ===================================================================
@@ -34,18 +34,20 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.clamp.clds.AbstractIT;
+import org.onap.clamp.clds.client.req.TcaMPolicyReq;
import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.prop.ModelProperties;
+import org.onap.clamp.clds.model.prop.*;
import org.onap.policy.api.AttributeType;
+import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
import org.onap.clamp.clds.client.req.OperationalPolicyReq;
import org.onap.clamp.clds.client.req.StringMatchPolicyReq;
-import org.onap.clamp.clds.model.prop.Policy;
-import org.onap.clamp.clds.model.prop.StringMatch;
import org.onap.clamp.clds.transform.TransformUtil;
+import static org.junit.Assert.assertEquals;
+
/**
* Test Policy API in org.onap.clamp.ClampDesigner.client package - replicate
* Policy Delegates in tests.
@@ -67,105 +69,131 @@ public class PolicyClientIT extends AbstractIT {
}
private void createUpdateStringMatch(String actionCd) throws Exception {
- ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, modelBpmnProp, modelProp);
- String stringMatchPolicyRequestUuid = UUID.randomUUID().toString();
- String policyJson = StringMatchPolicyReq.format(refProp, prop);
- System.out.println("String Match policyJson=" + policyJson);
- String responseMessage = policyClient.sendMicroService(policyJson, prop, stringMatchPolicyRequestUuid);
- System.out.println(responseMessage);
+ ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp);
+ StringMatch stringMatch = prop.getType(StringMatch.class);
+ if (stringMatch.isFound()) {
+ String stringMatchPolicyRequestUuid = UUID.randomUUID().toString();
+
+ String policyJson = StringMatchPolicyReq.format(refProp, prop);
+ String correctValue = TransformUtil.getResourceAsString("expected/stringmatch.json");
+ JSONAssert.assertEquals(policyJson, correctValue, true);
+ String responseMessage = "";
+ try {
+ responseMessage = policyClient.sendMicroService(policyJson, prop, stringMatchPolicyRequestUuid);
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Policy send failed: PE500 "));
+ }
+ System.out.println(responseMessage);
+ }
}
private void createUpdateOperationalPolicy(String actionCd) throws Exception {
- ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, modelBpmnProp, modelProp);
- String operationalPolicyRequestUuid = UUID.randomUUID().toString();
- Map<AttributeType, Map<String, String>> attributes = OperationalPolicyReq.formatAttributes(refProp, prop);
- String responseMessage = policyClient.sendBrms(attributes, prop, operationalPolicyRequestUuid);
- System.out.println(responseMessage);
+ ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp);
+ Policy policy = prop.getType(Policy.class);
+ if (policy.isFound()) {
+ for (PolicyChain policyChain : policy.getPolicyChains()) {
+ String operationalPolicyRequestUuid = UUID.randomUUID().toString();
+
+ Map<AttributeType, Map<String, String>> attributes = OperationalPolicyReq.formatAttributes(refProp,
+ prop, policy.getId(), policyChain);
+ String responseMessage = policyClient.sendBrms(attributes, prop, operationalPolicyRequestUuid);
+ System.out.println(responseMessage);
+ }
+ }
}
- private void createUpdatePolicies(String actionCd) throws Exception {
- createUpdateStringMatch(actionCd);
- createUpdateOperationalPolicy(actionCd);
+ private void createUpdateTcaPolicy(String actionCd) throws Exception {
+ ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp);
+ Tca tca = prop.getTca();
+ if (tca.isFound()) {
+ String tcaPolicyRequestUuid = UUID.randomUUID().toString();
+ String policyJson = TcaMPolicyReq.formatTca(refProp, prop);
+ String correctValue = TransformUtil.getResourceAsString("expected/tca.json");
+ JSONAssert.assertEquals(policyJson, correctValue, true);
+ String responseMessage = "";
+ try {
+ responseMessage = policyClient.sendMicroService(policyJson, prop, tcaPolicyRequestUuid);
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Policy send failed: PE500 "));
+ }
+ System.out.println(responseMessage);
+ }
}
private void deleteStringMatchPolicy(String actionCd) throws Exception {
- ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, modelBpmnProp, modelProp);
- StringMatch stringMatch = prop.getStringMatch();
- prop.setCurrentModelElementId(stringMatch.getId());
- String responseMessage = policyClient.deleteMicrosService(prop);
- System.out.println(responseMessage);
+ ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp);
+
+ StringMatch stringMatch = prop.getType(StringMatch.class);
+ if (stringMatch.isFound()) {
+ prop.setCurrentModelElementId(stringMatch.getId());
+ String responseMessage = "";
+ try {
+ responseMessage = policyClient.deleteMicrosService(prop);
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Policy delete failed: PE500 "));
+ }
+ System.out.println(responseMessage);
+ }
}
private void deleteOperationalPolicy(String actionCd) throws Exception {
- ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, modelBpmnProp, modelProp);
- Policy policy = prop.getPolicy();
- prop.setCurrentModelElementId(policy.getId());
- String responseMessage = policyClient.deleteBrms(prop);
- System.out.println(responseMessage);
+ ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp);
+
+ Policy policy = prop.getType(Policy.class);
+ if (policy.isFound()) {
+ prop.setCurrentModelElementId(policy.getId());
+ for (PolicyChain policyChain : policy.getPolicyChains()) {
+ prop.setPolicyUniqueId(policyChain.getPolicyId());
+ String responseMessage = policyClient.deleteBrms(prop);
+ System.out.println(responseMessage);
+ }
+ }
}
- private void deletePolicies(String actionCd) throws Exception {
- deleteStringMatchPolicy(actionCd);
- deleteOperationalPolicy(actionCd);
- }
+ private void deleteTcaPolicy(String actionCd) throws Exception {
+ ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp);
- /**
- * Delete policies so we can start with a clean state. But this is just a
- * precaution - the policies might not already exists. So ignore errors in
- * attempting to do this.
- *
- * @param actionCd
- */
- private void cleanUpPolicies(String actionCd) {
- try {
- deleteStringMatchPolicy(actionCd);
- } catch (Exception e) {
- System.err.println(
- "TestPolicyClient: The following error is ok - attempting delete in case the policy exists - the goal is to start with clean slate");
- }
- try {
- deleteOperationalPolicy(actionCd);
- } catch (Exception e) {
- System.err.println(
- "TestPolicyClient: The following error is ok - attempting delete in case the policy exists - the goal is to start with clean slate");
+ Tca tca = prop.getTca();
+ if (tca.isFound()) {
+ prop.setCurrentModelElementId(tca.getId());
+ String responseMessage = "";
+ try {
+ responseMessage = policyClient.deleteMicrosService(prop);
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Policy delete failed: PE500 "));
+ }
+
+ System.out.println(responseMessage);
}
}
- @Test
- public void testCreateUpdateDeletePolicy() throws Exception {
-
- cleanUpPolicies(CldsEvent.ACTION_DELETE);
- TimeUnit.SECONDS.sleep(5);
- System.out.println("entered into update");
- String actionCd;
-
- try {
- actionCd = CldsEvent.ACTION_SUBMIT;
- createUpdatePolicies(actionCd);
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("Policy send failed: PE500 "));
- }
+ // @Test
+ public void testCreateUpdateDeleteStringMatchPolicy() throws Exception {
- try {
- actionCd = CldsEvent.ACTION_RESUBMIT;
- createUpdatePolicies(actionCd);
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("Policy send failed: PE500 "));
- }
+ createUpdateStringMatch(CldsEvent.ACTION_SUBMIT);
- try {
- actionCd = CldsEvent.ACTION_RESUBMIT;
- createUpdatePolicies(actionCd);
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("Policy send failed: PE500 "));
- }
+ TimeUnit.SECONDS.sleep(20);
- try {
- TimeUnit.SECONDS.sleep(20);
- deletePolicies(CldsEvent.ACTION_DELETE);
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("Unable to get valid Response from PDP"));
- }
+ deleteStringMatchPolicy(CldsEvent.ACTION_DELETE);
+ }
+
+ // @Test
+ public void testCreateUpdateDeleteOperationalPolicy() throws Exception {
+
+ createUpdateOperationalPolicy(CldsEvent.ACTION_SUBMIT);
+
+ TimeUnit.SECONDS.sleep(20);
+
+ deleteOperationalPolicy(CldsEvent.ACTION_DELETE);
+ }
+
+ @Test
+ public void testCreateUpdateDeleteTcaPolicy() throws Exception {
+
+ createUpdateTcaPolicy(CldsEvent.ACTION_SUBMIT);
+
+ TimeUnit.SECONDS.sleep(20);
+ deleteTcaPolicy(CldsEvent.ACTION_DELETE);
}
}
diff --git a/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java b/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java
index 7eeb04eb8..ca849e170 100644
--- a/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java
+++ b/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java
@@ -5,16 +5,16 @@
* 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.
+ * 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============================================
* ===================================================================
@@ -23,58 +23,59 @@
package org.onap.clamp.clds.it;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onap.clamp.clds.AbstractIT;
-import org.onap.clamp.clds.client.req.SdcReq;
-import org.onap.clamp.clds.model.CldsAsdcServiceDetail;
+import java.io.IOException;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.clamp.clds.AbstractIT;
+import org.onap.clamp.clds.client.req.SdcReq;
+import org.onap.clamp.clds.model.CldsSdcServiceDetail;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
-import java.io.IOException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
/**
- * Test ASDC API - stand alone (except for some config).
- * Replicates getAsdcServices and getAsdcServicesByUUID in the CldsService
- * Adds test of putting putting an artifact to VF.
- * TODO Also needs update and perhaps delete tests.
+ * Test SDC API - stand alone (except for some config). Replicates
+ * getSdcServices and getSdcServicesByUUID in the CldsService Adds test of
+ * putting putting an artifact to VF. TODO Also needs update and perhaps delete
+ * tests.
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class PropJsonBuilderIT extends AbstractIT {
- private String globalPropsPartial;
+ private String globalPropsPartial;
private ObjectMapper mapper;
@Before
public void setUp() throws IOException {
- String url = refProp.getStringValue("asdc.serviceUrl");
- String catalogUrl = refProp.getStringValue("asdc.catalog.url");
- String basicAuth = SdcReq.getAsdcBasicAuth(refProp);
+ String url = refProp.getStringValue("sdc.serviceUrl");
+ String catalogUrl = refProp.getStringValue("sdc.catalog.url");
+ String basicAuth = SdcReq.getSdcBasicAuth(refProp);
System.out.println("value of string and basicAuth:" + url + basicAuth);
- CldsAsdcServiceDetail cldsservicedetail = new CldsAsdcServiceDetail();
- // cldsservicedetail.set
+ CldsSdcServiceDetail cldsservicedetail = new CldsSdcServiceDetail();
+ // cldsservicedetail.set
String globalProps = refProp.getStringValue("globalPropsTest");
globalPropsPartial = refProp.getStringValue("globalPropsPartialTest");
mapper = new ObjectMapper();
}
/**
- * List services from ASDC.
- * List meta data for a particular service from ASDC.
- * Test uploading artifact to a VF in ASDC.
+ * List services from SDC. List meta data for a particular service from SDC.
+ * Test uploading artifact to a VF in SDC.
*/
@Test
- public void testAsdc() throws Exception {
-// String createEmptySharedObject = createEmptySharedObject();
-// System.out.println("value of emptySharedObject:" + createEmptySharedObject);
+ public void testSdc() throws Exception {
+ // String createEmptySharedObject = createEmptySharedObject();
+ // System.out.println("value of emptySharedObject:" +
+ // createEmptySharedObject);
sampleJsonObject();
System.out.println(createTestEmptySharedObject());
}
@@ -83,8 +84,8 @@ public class PropJsonBuilderIT extends AbstractIT {
ArrayNode arrayNode = mapper.createArrayNode();
/**
- * Create three JSON Objects objectNode1, objectNode2, objectNode3
- * Add all these three objects in the array
+ * Create three JSON Objects objectNode1, objectNode2, objectNode3 Add
+ * all these three objects in the array
*/
ObjectNode objectNode1 = mapper.createObjectNode();
@@ -107,8 +108,8 @@ public class PropJsonBuilderIT extends AbstractIT {
arrayNode.add(objectNode3);
/**
- * We can directly write the JSON in the console.
- * But it wont be pretty JSON String
+ * We can directly write the JSON in the console. But it wont be pretty
+ * JSON String
*/
System.out.println(arrayNode.toString());
@@ -121,17 +122,8 @@ public class PropJsonBuilderIT extends AbstractIT {
private String createEmptySharedObject() throws JsonProcessingException {
/**
- * "": {
- "vf": {
- "": ""
- },
- "location": {
- "": ""
- },
- "alarmCondition": {
- "": ""
- }
- }
+ * "": { "vf": { "": "" }, "location": { "": "" }, "alarmCondition": {
+ * "": "" } }
*/
ObjectNode emptyObjectNode = mapper.createObjectNode();
emptyObjectNode.put("", "");
@@ -149,10 +141,7 @@ public class PropJsonBuilderIT extends AbstractIT {
emptyServiceObjectNode.putPOJO("", samArrayNode);
/**
- * "vf": {
- * " ": " ",
- * "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3"
- * }
+ * "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3" }
*
*/
ObjectNode vfObjectNode2 = mapper.createObjectNode();
@@ -164,11 +153,8 @@ public class PropJsonBuilderIT extends AbstractIT {
vfObjectNode2.putPOJO("vf", vfArrayNode);
/**
- * "location": {
- "SNDGCA64": "San Diego SAN3",
- "ALPRGAED": "Alpharetta PDK1",
- "LSLEILAA": "Lisle DPA3"
- },
+ * "location": { "SNDGCA64": "San Diego SAN3", "ALPRGAED":
+ * "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" },
*/
ObjectNode locationObjectNode2 = mapper.createObjectNode();
ObjectNode sandiegoLocationNode = mapper.createObjectNode();
@@ -182,9 +168,9 @@ public class PropJsonBuilderIT extends AbstractIT {
locationObjectNode2.putPOJO("location", locationArrayNode);
/**
- * "alarmCondition": {
- "A+Fallback+Operation+will+soon+be+started": "A Fallback Operation will soon be started",
- "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed",
+ * "alarmCondition": { "A+Fallback+Operation+will+soon+be+started":
+ * "A Fallback Operation will soon be started",
+ * "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed",
*/
ObjectNode alarmConditionObjectNode2 = mapper.createObjectNode();
ObjectNode alamrCondition1 = mapper.createObjectNode();
@@ -214,18 +200,8 @@ public class PropJsonBuilderIT extends AbstractIT {
byServiceBasicObjetNode.putPOJO("byService", byServiceBasicArrayNode);
/**
- * "byVf": {
- "": {
- "vfc": {
- "": ""
- },
- "03596c12-c7e3-44b7-8994-5cdfeda8afdd": {
- "vfc": {
- " ": " "
- }
- }
- }
- }
+ * "byVf": { "": { "vfc": { "": "" },
+ * "03596c12-c7e3-44b7-8994-5cdfeda8afdd": { "vfc": { " ": " " } } } }
*/
ObjectNode byVfCBasicNode = mapper.createObjectNode();
@@ -262,17 +238,8 @@ public class PropJsonBuilderIT extends AbstractIT {
ObjectNode locationJsonNode = (ObjectNode) mapper.readValue(locationStringValue, JsonNode.class);
ObjectNode alarmStringJsonNode = (ObjectNode) mapper.readValue(alarmStringValue, JsonNode.class);
/**
- * "": {
- "vf": {
- "": ""
- },
- "location": {
- "": ""
- },
- "alarmCondition": {
- "": ""
- }
- }
+ * "": { "vf": { "": "" }, "location": { "": "" }, "alarmCondition": {
+ * "": "" } }
*/
ObjectNode emptyObjectNode = mapper.createObjectNode();
emptyObjectNode.put("", "");
@@ -284,10 +251,7 @@ public class PropJsonBuilderIT extends AbstractIT {
emptyServiceObjectNode.putPOJO("", vfObjectNode);
/**
- * "vf": {
- * " ": " ",
- * "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3"
- * }
+ * "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3" }
*
*/
ObjectNode vfObjectNode2 = mapper.createObjectNode();
@@ -297,43 +261,32 @@ public class PropJsonBuilderIT extends AbstractIT {
vfObjectNode2.putPOJO("vf", dcaeClampDemo3Node);
/**
- * "location": {
- "SNDGCA64": "San Diego SAN3",
- "ALPRGAED": "Alpharetta PDK1",
- "LSLEILAA": "Lisle DPA3"
- },
+ * "location": { "SNDGCA64": "San Diego SAN3", "ALPRGAED":
+ * "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" },
*/
-// ObjectNode sandiegoLocationNode = mapper.createObjectNode();
-// sandiegoLocationNode.put("SNDGCA64","San Diego SAN3");
-// sandiegoLocationNode.put("ALPRGAED","Alpharetta PDK1");
+ // ObjectNode sandiegoLocationNode = mapper.createObjectNode();
+ // sandiegoLocationNode.put("SNDGCA64","San Diego SAN3");
+ // sandiegoLocationNode.put("ALPRGAED","Alpharetta PDK1");
vfObjectNode2.putPOJO("location", locationJsonNode);
/**
- * "alarmCondition": {
- "A+Fallback+Operation+will+soon+be+started": "A Fallback Operation will soon be started",
- "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed",
+ * "alarmCondition": { "A+Fallback+Operation+will+soon+be+started":
+ * "A Fallback Operation will soon be started",
+ * "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed",
*/
-// ObjectNode alamrCondition1 = mapper.createObjectNode();
-// alamrCondition1.put("A+Fallback+Operation+will+soon+be+started","A Fallback Operation will soon be started");
-// alamrCondition1.put("BRM%2C+Scheduled+Backup+Failed","BRM, Scheduled Backup Failed");
+ // ObjectNode alamrCondition1 = mapper.createObjectNode();
+ // alamrCondition1.put("A+Fallback+Operation+will+soon+be+started","A
+ // Fallback Operation will soon be started");
+ // alamrCondition1.put("BRM%2C+Scheduled+Backup+Failed","BRM, Scheduled
+ // Backup Failed");
vfObjectNode2.putPOJO("alarmCondition", alarmStringJsonNode);
emptyServiceObjectNode.putPOJO("c989a551-69f7-4b30-b10a-2e85bb227c30", vfObjectNode2);
ObjectNode byServiceBasicObjetNode = mapper.createObjectNode();
byServiceBasicObjetNode.putPOJO("byService", emptyServiceObjectNode);
/**
- * "byVf": {
- "": {
- "vfc": {
- "": ""
- },
- "03596c12-c7e3-44b7-8994-5cdfeda8afdd": {
- "vfc": {
- " ": " "
- }
- }
- }
- }
+ * "byVf": { "": { "vfc": { "": "" },
+ * "03596c12-c7e3-44b7-8994-5cdfeda8afdd": { "vfc": { " ": " " } } } }
*/
ObjectNode emptyvfcobjectNode = mapper.createObjectNode();
@@ -352,19 +305,10 @@ public class PropJsonBuilderIT extends AbstractIT {
return readTree.toString();
}
- private String createCldsSharedObject(CldsAsdcServiceDetail cldsAsdcServiceDetail) throws IOException {
+ private String createCldsSharedObject(CldsSdcServiceDetail CldsSdcServiceDetail) throws IOException {
/**
- * "": {
- "vf": {
- "": ""
- },
- "location": {
- "": ""
- },
- "alarmCondition": {
- "": ""
- }
- }
+ * "": { "vf": { "": "" }, "location": { "": "" }, "alarmCondition": {
+ * "": "" } }
*/
ObjectNode emptyObjectNode = mapper.createObjectNode();
emptyObjectNode.put("", "");
@@ -376,10 +320,7 @@ public class PropJsonBuilderIT extends AbstractIT {
emptyServiceObjectNode.putPOJO("", vfObjectNode);
/**
- * "vf": {
- * " ": " ",
- * "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3"
- * }
+ * "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3" }
*
*/
ObjectNode vfObjectNode2 = mapper.createObjectNode();
@@ -389,11 +330,8 @@ public class PropJsonBuilderIT extends AbstractIT {
vfObjectNode2.putPOJO("vf", dcaeClampDemo3Node);
/**
- * "location": {
- "SNDGCA64": "San Diego SAN3",
- "ALPRGAED": "Alpharetta PDK1",
- "LSLEILAA": "Lisle DPA3"
- },
+ * "location": { "SNDGCA64": "San Diego SAN3", "ALPRGAED":
+ * "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" },
*/
ObjectNode sandiegoLocationNode = mapper.createObjectNode();
sandiegoLocationNode.put("SNDGCA64", "San Diego SAN3");
@@ -401,9 +339,9 @@ public class PropJsonBuilderIT extends AbstractIT {
vfObjectNode2.putPOJO("location", sandiegoLocationNode);
/**
- * "alarmCondition": {
- "A+Fallback+Operation+will+soon+be+started": "A Fallback Operation will soon be started",
- "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed",
+ * "alarmCondition": { "A+Fallback+Operation+will+soon+be+started":
+ * "A Fallback Operation will soon be started",
+ * "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed",
*/
ObjectNode alamrCondition1 = mapper.createObjectNode();
alamrCondition1.put("A+Fallback+Operation+will+soon+be+started", "A Fallback Operation will soon be started");
@@ -414,18 +352,8 @@ public class PropJsonBuilderIT extends AbstractIT {
byServiceBasicObjetNode.putPOJO("byService", emptyServiceObjectNode);
/**
- * "byVf": {
- "": {
- "vfc": {
- "": ""
- },
- "03596c12-c7e3-44b7-8994-5cdfeda8afdd": {
- "vfc": {
- " ": " "
- }
- }
- }
- }
+ * "byVf": { "": { "vfc": { "": "" },
+ * "03596c12-c7e3-44b7-8994-5cdfeda8afdd": { "vfc": { " ": " " } } } }
*/
ObjectNode emptyvfcobjectNode = mapper.createObjectNode();
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
new file mode 100644
index 000000000..d0ba7455e
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.model.prop;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * A CustomModelElement to test the capability to add new elements on the fly.
+ */
+public class CustomModelElement extends ModelElement {
+
+ private static final String CUSTOM_TYPE = "customType";
+
+ /**
+ *
+ */
+ public CustomModelElement(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) {
+ super(CUSTOM_TYPE, modelProp, modelBpmn, modelJson);
+ topicPublishes = getValueByName("topicPublishes");
+ }
+
+ public static final String getType() {
+ return CUSTOM_TYPE;
+ }
+
+}
diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java
new file mode 100644
index 000000000..9c9cb4a73
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.model.prop;
+
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.clamp.clds.transform.TransformUtil;
+
+public class CustomModelElementTest {
+
+ public CustomModelElementTest() {
+ }
+
+ @Test
+ public void testNewElement() {
+
+ try {
+ String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnProp.json");
+ String modelProp = TransformUtil.getResourceAsString("example/modelProp.json");
+ String modName = "example-model-name";
+ String controlName = "example-control-name";
+
+ CustomModelElement customModelElement = null;
+
+ // Instantiate first, we should not have our CustomModelElement yet
+ ModelProperties prop = new ModelProperties(modName, controlName, null, true, modelBpmnProp, modelProp);
+
+ Assert.assertNotNull(prop);
+
+ customModelElement = prop.getType(CustomModelElement.class);
+
+ Assert.assertNull(customModelElement);
+
+ ModelProperties.registerModelElement(CustomModelElement.class, CustomModelElement.getType());
+
+ customModelElement = prop.getType(CustomModelElement.class);
+
+ Assert.assertNotNull(customModelElement);
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
index 54a7a4a72..1038e5de0 100644
--- a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
+++ b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
@@ -5,16 +5,16 @@
* 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.
+ * 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============================================
* ===================================================================
@@ -26,7 +26,7 @@ package org.onap.clamp.clds.model.prop;
import org.onap.clamp.clds.transform.TransformUtil;
import org.junit.Assert;
import org.junit.Test;
-
+import static org.junit.Assert.assertEquals;
import java.io.IOException;
/**
@@ -41,33 +41,54 @@ public class ModelPropertiesTest {
String modName = "example-model-name";
String controlName = "example-control-name";
- ModelProperties prop = new ModelProperties(modName, controlName, null, modelBpmnProp, modelProp);
+ ModelProperties prop = new ModelProperties(modName, controlName, null, true, modelBpmnProp, modelProp);
Assert.assertEquals(modName, prop.getModelName());
Assert.assertEquals(controlName, prop.getControlName());
Assert.assertEquals(null, prop.getActionCd());
Global g = prop.getGlobal();
- Assert.assertEquals("df6fcd2b-1932-429e-bb13-0cd0d32113cb", g.getService());
- Assert.assertEquals("[SNDGCA64, ALPRGAED]", g.getLocation().toString());
- Assert.assertEquals("[4b49acee-cf70-4b20-b956-a4fe0c1a8239]", g.getResourceVf().toString());
-
- Collector c = prop.getCollector();
- Assert.assertEquals("Collector_", c.getId());
- Assert.assertEquals("DCAE-COLLECTOR-UCSNMP", c.getTopicPublishes());
+ Assert.assertEquals("0f983e18-4603-4bb4-a98c-e29691fb16a1", g.getService());
+ Assert.assertEquals("[SNDGCA64]", g.getLocation().toString());
+ Assert.assertEquals("[6c7aaec2-59eb-41d9-8681-b7f976ab668d]", g.getResourceVf().toString());
- StringMatch sm = prop.getStringMatch();
+ StringMatch sm = prop.getType(StringMatch.class);
Assert.assertEquals("StringMatch_", sm.getId());
- Assert.assertEquals("DCAE-CL-EVENT", sm.getTopicPublishes());
- Policy p = prop.getPolicy();
+ Policy p = prop.getType(Policy.class);
Assert.assertEquals("Policy_", p.getId());
Assert.assertEquals(null, p.getTopicPublishes());
- Assert.assertEquals("DCAE-CL-EVENT", p.getTopicSubscribes());
- Assert.assertEquals(500, p.getTimeout().intValue());
-
- Tca t = prop.getTca();
+ Assert.assertEquals(null, p.getTopicSubscribes());
+
+ Tca t = prop.getType(Tca.class);
Assert.assertEquals("Narra", t.getTcaItems().get(0).getTcaName());
Assert.assertEquals(Integer.valueOf(4), t.getTcaItems().get(0).getTcaThreshholds().get(0).getThreshhold());
}
+ @Test
+ public void testPolicy() throws IOException {
+
+ String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnPropForPolicy.json");
+ System.out.println(modelBpmnProp);
+
+ String modelProp = TransformUtil.getResourceAsString("example/modelPropForPolicy.json");
+ System.out.println(modelProp);
+
+ ModelProperties prop = new ModelProperties("example-model-name", "example-control-name", null, true, modelBpmnProp, modelProp);
+ System.out.println("attempting prop.getGlobal()...");
+ Global g = prop.getGlobal();
+ System.out.println("attempting prop.getStringMatch()...");
+ StringMatch stringMatch = prop.getType(StringMatch.class);
+ if(stringMatch.isFound()){
+ System.out.println("stringMatch json object is present...");
+ assertEquals("1", stringMatch.getResourceGroups().get(0).getPolicyId());
+ }
+ System.out.println("attempting prop.getPolicy()...");
+ Policy policy = prop.getType(Policy.class);
+ if(policy.isFound()){
+ System.out.println("policy json object is present...");
+ assertEquals("1", policy.getPolicyChains().get(0).getPolicyId());
+ }
+ }
+
+
} \ No newline at end of file