aboutsummaryrefslogtreecommitdiffstats
path: root/models-base/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-03-21 09:54:30 -0400
committerJim Hahn <jrh3@att.com>2019-03-22 12:19:37 -0400
commita4b62b8f4da98eefe530e0fc11f6dafabe0019c2 (patch)
tree96f6acb9c49b9e4aa0d3c33dc805cf37b264f659 /models-base/src/test
parent834851e6c460ef8a28f356a64fe7b85d8bbf9a55 (diff)
Add models-pdp to models repo
Also changed supportedPolicyTypes to PfConceptKey. Updated licenses. Removed trailing whitespace from pom. Provide default request id. Rebased to fix merge conflict. Added SupportedPolicyType class. Renamed SupportedPolicyType to PolicyTypeIdent, and moved it to models-base. Also updated models-pap to use it. Deleted models-pdp Policy and replaced it with ToscaPolicy. Updated test method name. Change-Id: Id65f769c2f308c6b56e79978bd50b84f2e0b3d02 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-base/src/test')
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/keys/TestModels.java46
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/keys/TestPolicyTypeIdent.java60
2 files changed, 106 insertions, 0 deletions
diff --git a/models-base/src/test/java/org/onap/policy/models/base/keys/TestModels.java b/models-base/src/test/java/org/onap/policy/models/base/keys/TestModels.java
new file mode 100644
index 000000000..a1bf3be68
--- /dev/null
+++ b/models-base/src/test/java/org/onap/policy/models/base/keys/TestModels.java
@@ -0,0 +1,46 @@
+/*-
+ * ============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.
+ * 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.base.keys;
+
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+import org.junit.Test;
+import org.onap.policy.common.utils.validation.ToStringTester;
+
+/**
+ * Class to perform unit testing of models.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
+ */
+public class TestModels {
+
+ @Test
+ public void testModels() {
+ 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-base/src/test/java/org/onap/policy/models/base/keys/TestPolicyTypeIdent.java b/models-base/src/test/java/org/onap/policy/models/base/keys/TestPolicyTypeIdent.java
new file mode 100644
index 000000000..1638a87da
--- /dev/null
+++ b/models-base/src/test/java/org/onap/policy/models/base/keys/TestPolicyTypeIdent.java
@@ -0,0 +1,60 @@
+/*
+ * ============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.base.keys;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.policy.models.base.keys.PolicyTypeIdent;
+import org.onap.policy.models.base.keys.TestModels;
+
+/**
+ * Test the other constructors, as {@link TestModels} tests the other methods.
+ */
+public class TestPolicyTypeIdent {
+ private static final String NAME = "my-name";
+ private static final String VERSION = "1.2.3";
+
+ @Test
+ public void testAllArgsConstructor() {
+ assertThatThrownBy(() -> new PolicyTypeIdent(null, VERSION)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new PolicyTypeIdent(NAME, null)).isInstanceOf(NullPointerException.class);
+
+ PolicyTypeIdent orig = new PolicyTypeIdent(NAME, VERSION);
+ assertEquals(NAME, orig.getName());
+ assertEquals(VERSION, orig.getVersion());
+ }
+
+ @Test
+ public void testCopyConstructor() {
+ assertThatThrownBy(() -> new PolicyTypeIdent(null)).isInstanceOf(NullPointerException.class);
+
+ PolicyTypeIdent orig = new PolicyTypeIdent();
+
+ // verify with null values
+ assertEquals(orig.toString(), new PolicyTypeIdent(orig).toString());
+
+ // verify with all values
+ orig = new PolicyTypeIdent(NAME, VERSION);
+ assertEquals(orig.toString(), new PolicyTypeIdent(orig).toString());
+ }
+}