Fill in legacy JSON models 27/82427/2
authorPamela Dragosh <pdragosh@research.att.com>
Fri, 15 Mar 2019 14:27:24 +0000 (10:27 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Fri, 15 Mar 2019 15:04:25 +0000 (11:04 -0400)
Fill in the bodies of the guard and operational
JSON models.

Issue-ID: POLICY-1195
Change-Id: If15dd8fa89e7a2b9d823eab51ac0b0f8819dd9d4
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicy.java
models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicy.java
models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java [new file with mode: 0644]
models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java [new file with mode: 0644]
pom.xml

index a365696..30e62eb 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
 
 package org.onap.policy.models.tosca.serialization.legacy;
 
+import java.util.List;
+import java.util.Map;
+
+import lombok.Data;
+
 /**
  * Definition of a legacy guard policy stored as a TOSCA policy.
  *
  * @author Liam Fallon (liam.fallon@est.tech)
  */
+@Data
 public class LegacyGuardPolicy {
 
+    private String policyId;
+
+    private String policyVersion;
+
+    private List<Map<String, String>> content;
+
 }
index 0b63f2d..358d702 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
 
 package org.onap.policy.models.tosca.serialization.legacy;
 
+import lombok.Data;
+
 /**
  * Definition of a legacy operational policy stored as a TOSCA policy.
  *
  * @author Liam Fallon (liam.fallon@est.tech)
  */
+@Data
 public class LegacyOperationalPolicy {
 
-}
+    private String policyId;
+
+    private String policyVersion;
+
+    private String content;
+
+}
\ No newline at end of file
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java
new file mode 100644 (file)
index 0000000..fa08233
--- /dev/null
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.serialization.legacy;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class LegacyGuardPolicyTest {
+
+    @Test
+    public void test() {
+        LegacyGuardPolicy guard = new LegacyGuardPolicy();
+        assertNotNull(guard);
+        guard.setPolicyId("guard.frequency");
+        assertEquals("guard.frequency", guard.getPolicyId());
+        guard.setPolicyVersion("1");
+        assertEquals("1", guard.getPolicyVersion());
+        Map<String, String> body = new HashMap<>();
+        body.put("actor", "SO");
+        List<Map<String, String>> content = new ArrayList<>();
+        content.add(body);
+        guard.setContent(content);
+        assertEquals(1, guard.getContent().size());
+    }
+
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java
new file mode 100644 (file)
index 0000000..13da632
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.serialization.legacy;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class LegacyOperationalPolicyTest {
+
+    @Test
+    public void test() {
+        LegacyOperationalPolicy policy = new LegacyOperationalPolicy();
+        assertNotNull(policy);
+        policy.setPolicyId("onap.scaleout");
+        assertEquals("onap.scaleout", policy.getPolicyId());
+        policy.setPolicyVersion("1");
+        assertEquals("1", policy.getPolicyVersion());
+        policy.setContent("controlLoop%3A%0A%20%20");
+        assertTrue(policy.getContent().length() > 0);
+    }
+
+}
diff --git a/pom.xml b/pom.xml
index 245dfc9..5a22b52 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,7 @@
         <groupId>org.onap.policy.parent</groupId>
         <artifactId>integration</artifactId>
         <version>2.1.0-SNAPSHOT</version>
+        <relativePath />
     </parent>
 
     <groupId>org.onap.policy.models</groupId>