aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-REST/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-11-07 10:38:07 +0000
committerliamfallon <liam.fallon@est.tech>2019-11-07 10:51:33 +0000
commite4ac1ef3c51fc9afe44849ada5bea8c3d6057897 (patch)
tree51100e9b91cd1c2db2c6238625eedacab92c1aca /ONAP-REST/src/test
parentf4ec47c009cdc385a7efed02dda5d26f2ec31b57 (diff)
JUnit/SONAR/Checkstyle in ONAP-REST
Second batch of JPA pojos (B-D), with JUnit added and SONAR/Checkstyle issues addressed. In cases where a class name change caused an update in another package, the license header on files for those knock on changes are not updated. Issue-ID: POLICY-2131 Change-Id: I9466f27ffa606001209ed978be592ae95d1b32c4 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'ONAP-REST/src/test')
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java52
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BrmsDictionaryJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java)59
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java46
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java)89
4 files changed, 202 insertions, 44 deletions
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java
index b2c3a77c1..047053a83 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java
@@ -8,9 +8,9 @@
* 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.
@@ -21,8 +21,13 @@
package org.onap.policy.rest.jpa;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import com.att.research.xacml.api.Identifier;
+
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
@@ -39,7 +44,7 @@ public class ActionDictionaryJpaTest {
/**
* Set up the test.
- *
+ *
* @throws Exception on test errors
*/
@Before
@@ -141,7 +146,6 @@ public class ActionDictionaryJpaTest {
data.removeAttribute(new Attribute());
data.isStandard();
data.isCustom();
- Category.extractGrouping("urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject");
data.getIdentifer();
data.toString();
assertTrue(data.getAttributes() != null);
@@ -153,6 +157,33 @@ public class ActionDictionaryJpaTest {
assertTrue("Test".equals(data.getShortName()));
data.setXacmlId("Test");
assertTrue("Test".equals(data.getXacmlId()));
+
+ data.setIsStandard(Category.STANDARD);
+ assertEquals(Category.STANDARD, data.getIsStandard());
+ assertTrue(data.isStandard());
+ assertFalse(data.isCustom());
+
+ data.setIsStandard(Category.CUSTOM);
+ assertEquals(Category.CUSTOM, data.getIsStandard());
+ assertFalse(data.isStandard());
+ assertTrue(data.isCustom());
+
+ Identifier categoryIdentifier = new DummyIdentifier();
+ Category data2 = new Category(categoryIdentifier,
+ "urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject", Category.STANDARD);
+ assertEquals(DummyIdentifier.class.getName(), data2.getIdentifer().stringValue());
+
+ Category data3 = new Category(categoryIdentifier,
+ "urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject");
+ assertEquals(DummyIdentifier.class.getName(), data3.getIdentifer().stringValue());
+
+ assertEquals("subject",
+ Category.extractGrouping("urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject"));
+ assertNull(Category.extractGrouping(null));
+ assertNull(Category.extractGrouping("some random string"));
+ assertNull(Category.extractGrouping(""));
+ assertEquals("intermediary-attribute", Category
+ .extractGrouping("urn:oasis:names:tc:xacml:1.0:attribute-category:intermediary-attribute"));
}
@Test
@@ -283,6 +314,19 @@ public class ActionDictionaryJpaTest {
assertTrue(data.isStandard());
data.setIsStandard(Datatype.CUSTOM);
assertTrue(data.isCustom());
+
+ data.setIsStandard(Category.STANDARD);
+ assertEquals(Category.STANDARD, data.getIsStandard());
+ assertTrue(data.isStandard());
+ assertFalse(data.isCustom());
+
+ data.setIsStandard(Category.CUSTOM);
+ assertEquals(Category.CUSTOM, data.getIsStandard());
+ assertFalse(data.isStandard());
+ assertTrue(data.isCustom());
+
+ Datatype data2 = new Datatype(new DummyIdentifier(), Datatype.STANDARD);
+ assertEquals(DummyIdentifier.class.getName(), data2.getIdentifer().stringValue());
}
@Test
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BrmsDictionaryJpaTest.java
index 9012cca28..abfef0c35 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BrmsDictionaryJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 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.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertTrue;
@@ -28,11 +30,19 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class BRMSDictionaryJPATest {
+/**
+ * The Class BrmsDictionaryJpaTest.
+ */
+public class BrmsDictionaryJpaTest {
- private static Logger logger = FlexLogger.getLogger(BRMSDictionaryJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(BrmsDictionaryJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -42,9 +52,12 @@ public class BRMSDictionaryJPATest {
logger.info("setUp: exit");
}
+ /**
+ * Test BRMS param template.
+ */
@Test
- public void testBRMSParamTemplate(){
- BRMSParamTemplate data = new BRMSParamTemplate();
+ public void testBrmsParamTemplate() {
+ BrmsParamTemplate data = new BrmsParamTemplate();
data.prePersist();
data.setId(1);
assertTrue(1 == data.getId());
@@ -55,14 +68,17 @@ public class BRMSDictionaryJPATest {
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
}
+ /**
+ * Test BRMS controller.
+ */
@Test
- public void testBRMSController(){
- BRMSController data = new BRMSController();
+ public void testBrmsController() {
+ BrmsController data = new BrmsController();
data.preUpdate();
data.prePersist();
data.setId(1);
@@ -74,18 +90,21 @@ public class BRMSDictionaryJPATest {
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test BRMS dependency.
+ */
@Test
- public void testBRMSDependency(){
- BRMSDependency data = new BRMSDependency();
+ public void testrmsDependency() {
+ BrmsDependency data = new BrmsDependency();
data.preUpdate();
data.prePersist();
data.setId(1);
@@ -97,13 +116,13 @@ public class BRMSDictionaryJPATest {
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java
new file mode 100644
index 000000000..bd88db29a
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.jpa;
+
+import com.att.research.xacml.api.Identifier;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Dummy category identifier class.
+ */
+public class DummyIdentifier implements Identifier {
+
+ @Override
+ public String stringValue() {
+ return this.getClass().getName();
+ }
+
+ @Override
+ public URI getUri() {
+ try {
+ return new URI(this.getClass().getName());
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java
index 548e3fc84..5ea92fd13 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 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.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertTrue;
@@ -26,11 +28,19 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class MicroServiceDictionaryJPATest {
+/**
+ * The Class MicroServiceDictionaryJpaTest.
+ */
+public class MicroServiceDictionaryJpaTest {
- private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -40,9 +50,12 @@ public class MicroServiceDictionaryJPATest {
logger.info("setUp: exit");
}
+ /**
+ * Test DCAE users.
+ */
@Test
- public void testDCAEUsers(){
- DCAEUsers data = new DCAEUsers();
+ public void testDcaeUsers() {
+ DcaeUsers data = new DcaeUsers();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
@@ -51,9 +64,12 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescriptionValue()));
}
+ /**
+ * Test DCA euuid.
+ */
@Test
- public void testDCAEuuid(){
- DCAEuuid data = new DCAEuuid();
+ public void testDcaeUuid() {
+ DcaeUuid data = new DcaeUuid();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
@@ -62,8 +78,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test MS config name.
+ */
@Test
- public void testMSConfigName(){
+ public void testMsConfigName() {
MicroServiceConfigName data = new MicroServiceConfigName();
data.setId(1);
assertTrue(1 == data.getId());
@@ -73,8 +92,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescriptionValue()));
}
+ /**
+ * Test MS config location.
+ */
@Test
- public void testMSConfigLocation(){
+ public void testMsConfigLocation() {
MicroServiceLocation data = new MicroServiceLocation();
data.setId(1);
assertTrue(1 == data.getId());
@@ -84,8 +106,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescriptionValue()));
}
+ /**
+ * Test MS models.
+ */
@Test
- public void testMSModels(){
+ public void testMsModels() {
MicroServiceModels data = new MicroServiceModels();
data.setId(1);
assertTrue(1 == data.getId());
@@ -104,15 +129,18 @@ public class MicroServiceDictionaryJPATest {
data.setRef_attributes("Test");
assertTrue("Test".equals(data.getRef_attributes()));
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setSub_attributes("Test");
assertTrue("Test".equals(data.getSub_attributes()));
data.setVersion("Test");
assertTrue("Test".equals(data.getVersion()));
}
+ /**
+ * Test MS attribute dictionary.
+ */
@Test
- public void testMSAttributeDictionary(){
+ public void testMsAttributeDictionary() {
MicroServiceAttribute data = new MicroServiceAttribute();
data.setId(1);
assertTrue(1 == data.getId());
@@ -124,8 +152,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getModelName()));
}
+ /**
+ * Test policy scope service.
+ */
@Test
- public void testPolicyScopeService(){
+ public void testPolicyScopeService() {
PolicyScopeService data = new PolicyScopeService();
data.setId(1);
assertTrue(1 == data.getId());
@@ -135,8 +166,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescriptionValue()));
}
+ /**
+ * Test policy scope resource.
+ */
@Test
- public void testPolicyScopeResource(){
+ public void testPolicyScopeResource() {
PolicyScopeResource data = new PolicyScopeResource();
data.setId(1);
assertTrue(1 == data.getId());
@@ -146,8 +180,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescriptionValue()));
}
+ /**
+ * Test policy scope type.
+ */
@Test
- public void testPolicyScopeType(){
+ public void testPolicyScopeType() {
PolicyScopeType data = new PolicyScopeType();
data.setId(1);
assertTrue(1 == data.getId());
@@ -157,8 +194,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescriptionValue()));
}
+ /**
+ * Test policy scope closed loop.
+ */
@Test
- public void testPolicyScopeClosedLoop(){
+ public void testPolicyScopeClosedLoop() {
PolicyScopeClosedLoop data = new PolicyScopeClosedLoop();
data.setId(1);
assertTrue(1 == data.getId());
@@ -168,8 +208,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescriptionValue()));
}
+ /**
+ * Test policy scope group policy scope list.
+ */
@Test
- public void testPolicyScopeGroupPolicyScopeList(){
+ public void testPolicyScopeGroupPolicyScopeList() {
GroupPolicyScopeList data = new GroupPolicyScopeList();
data.setId(1);
assertTrue(1 == data.getId());
@@ -181,8 +224,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getGroupList()));
}
+ /**
+ * Test closed loops.
+ */
@Test
- public void testClosedLoops(){
+ public void testClosedLoops() {
ClosedLoops data = new ClosedLoops();
data.setId(1);
assertTrue(1 == data.getId());
@@ -194,8 +240,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getYaml()));
}
+ /**
+ * Test VM type.
+ */
@Test
- public void testVMType(){
+ public void testVmType() {
VMType data = new VMType();
data.setId(1);
assertTrue(1 == data.getId());