Updates to models from scrum on 4/4 53/84253/5
authorJim Hahn <jrh3@att.com>
Thu, 4 Apr 2019 15:20:42 +0000 (11:20 -0400)
committerJim Hahn <jrh3@att.com>
Fri, 5 Apr 2019 02:43:05 +0000 (22:43 -0400)
Moved ToscaPolicyIdentXxx classes from models-pdp to models-tosca,
and added methods to retrieve them from a ToscaPolicy.

Removed version and instance fields from PdpStatus.

Chose to leave "description" field in the PAP/PDP messages.  The
PDPs can ignore them or leave them null.  In a PdpUpdate message,
the description will be the description associated with the PdpGroup.
In a PdpStatus message, the PDP could choose to provide a description
of the PDP, itself (or the type of PDP).
Added comments to that effect.

Moved name, group, and subgroup fields into PdpMessage.

Fixed typos in comments.
Updated licenses.
Change "long" to "Long" in PdpUpdate.
Use lombok @ToString instead of override.

Fixed merge conflict.

Change-Id: Icd928f9a7630b838ad4b0b5556e899dc21b7872b
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
25 files changed:
models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpDeployPolicies.java
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageUtils.java [new file with mode: 0644]
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpMessage.java [new file with mode: 0644]
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpStateChange.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpUpdate.java
models-pdp/src/test/java/org/onap/policy/models/persistence/provider/PdpProviderTest.java
models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java
models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifier.java [moved from models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifier.java with 96% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java [moved from models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifierOptVersion.java with 96% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java [moved from models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyTypeIdentifier.java with 96% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/TestPojos.java
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/TestToscaPolicy.java [new file with mode: 0644]
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/TestToscaPolicyIdentifier.java [moved from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestToscaPolicyIdentifier.java with 94% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/TestToscaPolicyIdentifierOptVersion.java [moved from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestToscaPolicyIdentifierOptVersion.java with 95% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/TestToscaPolicyTypeIdentifier.java [moved from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestToscaPolicyTypeIdentifier.java with 94% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaIdentifierTestBase.java [moved from models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ToscaIdentifierTestBase.java with 97% similarity]

index 0484cc3..7bc8892 100644 (file)
@@ -24,7 +24,7 @@ import java.util.List;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
-import org.onap.policy.models.pdp.concepts.ToscaPolicyIdentifierOptVersion;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
 
 /**
  * Request deploy or update a set of policies using the <i>simple</i> PDP Group deployment
index f7a47cc..b49bede 100644 (file)
@@ -29,6 +29,8 @@ import lombok.NonNull;
 
 import org.onap.policy.models.base.PfObjectFiler;
 import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 
 /**
  * Filter class for searches for {@link PdpGroup} instances.
index 6160027..a48724e 100644 (file)
@@ -29,7 +29,8 @@ import lombok.ToString;
 import org.onap.policy.models.pdp.enums.PdpMessageType;
 
 /**
- * Class to represent the base class for various messages that will ve exchanged between PAP and PDP.
+ * Class to represent the base class for various messages that will be exchanged between
+ * PAP and PDP.
  *
  * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
  */
@@ -49,6 +50,24 @@ public class PdpMessage {
      */
     private long timestampMs = System.currentTimeMillis();
 
+    /**
+     * PDP name, or {@code null} for state-change broadcast messages.
+     */
+    private String name;
+
+    /**
+     * Group associated with the PDP. For state-change messages, this may be {@code null},
+     * if the {@link #name} is provided.
+     */
+    private String pdpGroup;
+
+    /**
+     * Group associated with the PDP. For state-change messages, this may be {@code null},
+     * if the {@link #name} is provided.
+     */
+    private String pdpSubgroup;
+
+
     /**
      * Constructor for instantiating PdpMessage class with message name.
      *
@@ -57,4 +76,17 @@ public class PdpMessage {
     public PdpMessage(final PdpMessageType messageName) {
         this.messageName = messageName;
     }
+
+    /**
+     * Constructs the object, making a deep copy. Does <i>not</i> copy the request id or
+     * the time stamp.
+     *
+     * @param source source from which to copy
+     */
+    public PdpMessage(final PdpMessage source) {
+        this.messageName = source.messageName;
+        this.name = source.name;
+        this.pdpGroup = source.pdpGroup;
+        this.pdpSubgroup = source.pdpSubgroup;
+    }
 }
index d8f938b..fe953cb 100644 (file)
@@ -35,13 +35,10 @@ import org.onap.policy.models.pdp.enums.PdpState;
  */
 @Getter
 @Setter
-@ToString
+@ToString(callSuper = true)
 public class PdpStateChange extends PdpMessage {
 
-    private String name;
     private PdpState state;
-    private String pdpGroup;
-    private String pdpSubgroup;
 
     /**
      * Constructor for instantiating PdpStateChange class with message name.
@@ -57,11 +54,8 @@ public class PdpStateChange extends PdpMessage {
      * @param source source from which to copy
      */
     public PdpStateChange(PdpStateChange source) {
-        super(PdpMessageType.PDP_STATE_CHANGE);
+        super(source);
 
-        this.name = source.name;
         this.state = source.state;
-        this.pdpGroup = source.pdpGroup;
-        this.pdpSubgroup = source.pdpSubgroup;
     }
 }
index d0fef45..5858b6a 100644 (file)
 package org.onap.policy.models.pdp.concepts;
 
 import java.util.List;
-
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
-
 import org.onap.policy.models.pdp.enums.PdpHealthStatus;
 import org.onap.policy.models.pdp.enums.PdpMessageType;
 import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 
 /**
  * Class to represent the PDP_STATUS message that all the PDP's will send to PAP.
@@ -38,20 +38,20 @@ import org.onap.policy.models.pdp.enums.PdpState;
  */
 @Getter
 @Setter
-@ToString
+@ToString(callSuper = true)
 public class PdpStatus extends PdpMessage {
 
-    private String name;
-    private String version;
     private String pdpType;
     private PdpState state;
     private PdpHealthStatus healthy;
+
+    /**
+     * Description of the PDP or the PDP type.  May be left {@code null}.
+     */
     private String description;
-    private String pdpGroup;
-    private String pdpSubgroup;
+
     private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes;
     private List<ToscaPolicyIdentifier> policies;
-    private String instance;
     private String deploymentInstanceInfo;
     private String properties;
     private PdpStatistics statistics;
index b4f4693..4e58436 100644 (file)
@@ -31,6 +31,8 @@ import lombok.Setter;
 import lombok.ToString;
 
 import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 
 /**
  * Class to represent a group of all PDP's of the same pdp type running for a particular domain.
index 200515c..a28bd76 100644 (file)
@@ -36,14 +36,15 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
  */
 @Getter
 @Setter
-@ToString
+@ToString(callSuper = true)
 public class PdpUpdate extends PdpMessage {
 
-    private String name;
+    /**
+     * Description of the PDP group.
+     */
     private String description;
-    private String pdpGroup;
-    private String pdpSubgroup;
-    private long pdpHeartbeatIntervalMs;
+
+    private Long pdpHeartbeatIntervalMs;
     private List<ToscaPolicy> policies;
 
     /**
@@ -60,12 +61,9 @@ public class PdpUpdate extends PdpMessage {
      * @param source source from which to copy
      */
     public PdpUpdate(PdpUpdate source) {
-        super(PdpMessageType.PDP_UPDATE);
+        super(source);
 
-        this.name = source.name;
         this.description = source.description;
-        this.pdpGroup = source.pdpGroup;
-        this.pdpSubgroup = source.pdpSubgroup;
         this.pdpHeartbeatIntervalMs = source.pdpHeartbeatIntervalMs;
         this.policies = (source.policies == null ? null
                         : source.policies.stream().map(ToscaPolicy::new).collect(Collectors.toList()));
index 2a93439..1937cbf 100644 (file)
@@ -28,7 +28,6 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import javax.persistence.CollectionTable;
 import javax.persistence.Column;
 import javax.persistence.ElementCollection;
@@ -39,11 +38,9 @@ import javax.persistence.InheritanceType;
 import javax.persistence.JoinColumn;
 import javax.persistence.OneToMany;
 import javax.persistence.Table;
-
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NonNull;
-
 import org.onap.policy.common.utils.validation.Assertions;
 import org.onap.policy.common.utils.validation.ParameterValidationUtils;
 import org.onap.policy.models.base.PfAuthorative;
@@ -58,8 +55,8 @@ import org.onap.policy.models.base.PfValidationResult;
 import org.onap.policy.models.base.PfValidationResult.ValidationResult;
 import org.onap.policy.models.pdp.concepts.Pdp;
 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.pdp.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.pdp.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 
 /**
  * Class to represent a PDP subgroup in the database.
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageUtils.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageUtils.java
new file mode 100644 (file)
index 0000000..ee7e15b
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Models
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.pdp.concepts;
+
+/**
+ * Utility class for tests of PdpMessage subclasses.
+ */
+public class PdpMessageUtils {
+
+    public static String removeVariableFields(String text) {
+        return text.replaceAll("requestId=[^,]*", "requestId=xxx").replaceAll("timestampMs=[^,]*", "timestampMs=nnn");
+    }
+}
index 39aee6f..1813dde 100644 (file)
@@ -38,7 +38,7 @@ import org.onap.policy.common.utils.validation.ToStringTester;
 public class TestModels {
 
     @Test
-    public void testPapModels() {
+    public void testPdpModels() {
         final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester())
                 .with(new GetterTester()).build();
         validator.validate(TestModels.class.getPackage().getName(), new FilterPackageInfo());
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpMessage.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpMessage.java
new file mode 100644 (file)
index 0000000..515c483
--- /dev/null
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Models
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.policy.models.pdp.concepts;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.policy.models.pdp.enums.PdpMessageType;
+
+/**
+ * Test the copy constructor, as {@link TestModels} tests the other methods.
+ */
+public class TestPdpMessage {
+
+    @Test
+    public void testCopyConstructor() {
+        assertThatThrownBy(() -> new PdpMessage((PdpMessage) null)).isInstanceOf(NullPointerException.class);
+
+        PdpMessage orig = new PdpMessage(PdpMessageType.PDP_STATE_CHANGE);
+
+        // verify with null values
+        PdpMessage newmsg = new PdpMessage(orig);
+        newmsg.setRequestId(orig.getRequestId());
+        newmsg.setTimestampMs(orig.getTimestampMs());
+        assertEquals(orig.toString(), newmsg.toString());
+
+        // verify with all values
+        orig.setName("my-name");
+        orig.setPdpGroup("my-group");
+        orig.setPdpSubgroup("my-subgroup");
+
+        newmsg = new PdpMessage(orig);
+        newmsg.setRequestId(orig.getRequestId());
+        newmsg.setTimestampMs(orig.getTimestampMs());
+        assertEquals(orig.toString(), newmsg.toString());
+    }
+}
index 8c843a1..55eaedc 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.policy.models.pdp.concepts;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
+import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields;
 
 import org.junit.Test;
 import org.onap.policy.models.pdp.enums.PdpState;
@@ -39,8 +40,7 @@ public class TestPdpStateChange {
         PdpStateChange orig = new PdpStateChange();
 
         // verify with null values
-        assertEquals("PdpStateChange(name=null, state=null, pdpGroup=null, pdpSubgroup=null)",
-                        new PdpStateChange(orig).toString());
+        assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpStateChange(orig).toString()));
 
         // verify with all values
         orig.setName("my-name");
@@ -48,7 +48,6 @@ public class TestPdpStateChange {
         orig.setPdpSubgroup("my-subgroup");
         orig.setState(PdpState.SAFE);
 
-        assertEquals("PdpStateChange(name=my-name, state=SAFE, pdpGroup=my-group, pdpSubgroup=my-subgroup)",
-                        new PdpStateChange(orig).toString());
+        assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpStateChange(orig).toString()));
     }
 }
index 2580ca8..c80745d 100644 (file)
@@ -29,6 +29,8 @@ import java.util.Map;
 import java.util.TreeMap;
 
 import org.junit.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 
 /**
  * Test the copy constructor, as {@link TestModels} tests the other methods.
index d2b571f..b366088 100644 (file)
@@ -24,6 +24,7 @@ package org.onap.policy.models.pdp.concepts;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields;
 
 import java.util.Arrays;
 import java.util.List;
@@ -42,15 +43,14 @@ public class TestPdpUpdate {
         PdpUpdate orig = new PdpUpdate();
 
         // verify with null values
-        assertEquals("PdpUpdate(name=null, description=null, pdpGroup=null, pdpSubgroup=null, "
-                        + "pdpHeartbeatIntervalMs=0, policies=null)", new PdpUpdate(orig).toString());
+        assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpUpdate(orig).toString()));
 
         // verify with all values
         orig.setDescription("my-description");
         orig.setName("my-name");
         orig.setPdpGroup("my-group");
         orig.setPdpSubgroup("my-subgroup");
-        orig.setPdpHeartbeatIntervalMs(30000);
+        orig.setPdpHeartbeatIntervalMs(30000L);
 
         ToscaPolicy policy1 = new ToscaPolicy();
         policy1.setName("policy-a");
@@ -65,13 +65,7 @@ public class TestPdpUpdate {
 
         PdpUpdate other = new PdpUpdate(orig);
 
-        assertEquals("PdpUpdate(name=my-name, description=my-description, "
-                        + "pdpGroup=my-group, pdpSubgroup=my-subgroup, pdpHeartbeatIntervalMs=30000, policies=["
-                        + "ToscaPolicy(super=ToscaEntity(name=policy-a, version=1.2.3, derivedFrom=null, "
-                        + "metadata=null, description=null), type=null, typeVersion=null, properties=null), "
-                        + "ToscaPolicy(super=ToscaEntity(name=policy-b, version=4.5.6, derivedFrom=null, "
-                        + "metadata=null, description=null), type=null, typeVersion=null, properties=null)])",
-                        other.toString());
+        assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
 
         // ensure list and items are not the same object
         assertTrue(other.getPolicies() != policies);
index fcb9062..6f20882 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.
@@ -24,10 +25,6 @@ import static org.junit.Assert.assertEquals;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -37,15 +34,9 @@ import org.onap.policy.models.dao.DaoParameters;
 import org.onap.policy.models.dao.PfDao;
 import org.onap.policy.models.dao.PfDaoFactory;
 import org.onap.policy.models.dao.impl.DefaultPfDao;
-import org.onap.policy.models.pdp.concepts.Pdp;
-import org.onap.policy.models.pdp.concepts.PdpGroup;
 import org.onap.policy.models.pdp.concepts.PdpGroups;
-import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.pdp.concepts.ToscaPolicyTypeIdentifier;
-import org.onap.policy.models.pdp.enums.PdpHealthStatus;
-import org.onap.policy.models.pdp.enums.PdpState;
 import org.onap.policy.models.pdp.persistence.provider.PdpProvider;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider;
 
 /**
  * Test the {@link SimpleToscaProvider} class.
@@ -110,7 +101,6 @@ public class PdpProviderTest {
 
         String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json");
 
-        @SuppressWarnings("unchecked")
         PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class);
 
         PdpGroups createdPdpGroups0 = new PdpGroups();
index 6463abc..9c6a375 100644 (file)
@@ -66,4 +66,22 @@ public class ToscaPolicy extends ToscaEntity {
             }
         }
     }
+
+    /**
+     * Gets the identifier for this policy.
+     *
+     * @return this policy's identifier
+     */
+    public ToscaPolicyIdentifier getIdentifier() {
+        return new ToscaPolicyIdentifier(getName(), getVersion());
+    }
+
+    /**
+     * Gets the type identifier for this policy.
+     *
+     * @return this policy's type identifier
+     */
+    public ToscaPolicyTypeIdentifier getTypeIdentifier() {
+        return new ToscaPolicyTypeIdentifier(getType(), getTypeVersion());
+    }
 }
index 96d82e7..1524066 100644 (file)
@@ -59,7 +59,9 @@ public class TestPojos {
                 new FilterClassName(
                         org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter.class.getName()),
                 new FilterClassName(
-                        org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter.class.getName())
+                        org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter.class.getName()),
+                new FilterClassName(
+                        ToscaIdentifierTestBase.class.getName())
         );
         // @formatter:on
     }
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/TestToscaPolicy.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/TestToscaPolicy.java
new file mode 100644 (file)
index 0000000..881a69d
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Models
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.authorative.concepts;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * Tests methods not tested by {@link TestPojos}.
+ */
+public class TestToscaPolicy {
+
+    @Test
+    public void testGetIdentifier_testGetTypeIdentifier() {
+        ToscaPolicy policy = new ToscaPolicy();
+
+        policy.setName("my_name");
+        policy.setVersion("1.2.3");
+        policy.setType("my_type");
+        policy.setTypeVersion("3.2.1");
+
+        ToscaPolicyIdentifier ident = policy.getIdentifier();
+        assertEquals("my_name", ident.getName());
+        assertEquals("1.2.3", ident.getVersion());
+
+        ToscaPolicyTypeIdentifier type = policy.getTypeIdentifier();
+        assertEquals("my_type", type.getName());
+        assertEquals("3.2.1", type.getVersion());
+    }
+}
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.pdp.concepts;
+package org.onap.policy.models.tosca.authorative.concepts;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals;
 import org.junit.Test;
 
 /**
- * Test the other constructors, as {@link TestModels} tests the other methods.
+ * Test the other constructors, as {@link TestPojos} tests the other methods.
  */
 public class TestToscaPolicyIdentifier extends ToscaIdentifierTestBase<ToscaPolicyIdentifier> {
     private static final String NAME = "my-name";
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.pdp.concepts;
+package org.onap.policy.models.tosca.authorative.concepts;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
@@ -28,7 +28,7 @@ import static org.junit.Assert.assertTrue;
 import org.junit.Test;
 
 /**
- * Test the other constructors, as {@link TestModels} tests the other methods.
+ * Test the other constructors, as {@link TestPojos} tests the other methods.
  */
 public class TestToscaPolicyIdentifierOptVersion extends ToscaIdentifierTestBase<ToscaPolicyIdentifierOptVersion> {
     private static final String NAME = "my-name";
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.pdp.concepts;
+package org.onap.policy.models.tosca.authorative.concepts;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals;
 import org.junit.Test;
 
 /**
- * Test the other constructors, as {@link TestModels} tests the other methods.
+ * Test the other constructors, as {@link TestPojos} tests the other methods.
  */
 public class TestToscaPolicyTypeIdentifier extends ToscaIdentifierTestBase<ToscaPolicyTypeIdentifier> {
     private static final String NAME = "my-name";
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.pdp.concepts;
+package org.onap.policy.models.tosca.authorative.concepts;
 
 import org.onap.policy.common.utils.coder.Coder;
 import org.onap.policy.common.utils.coder.CoderException;