diff options
author | 2018-09-16 21:30:20 -0600 | |
---|---|---|
committer | 2018-09-17 12:35:14 -0400 | |
commit | 9783a8b7515eaaec310e404650d0dd9092eb90a8 (patch) | |
tree | 90101018aa23a5e91c0d9f85aec0fa5ff407e184 /ms/neng/src/test/java | |
parent | 4f44000fef9608150811e0b9f9b140c580f5822b (diff) |
naming micro-service updates.
More tests, changes for maria DB, support for UUID and timestamp etc.
Change-Id: I17bdf3acbe970ef4104f2ec0d59d5777c0a9928e
Issue-ID: CCSDK-342
Signed-off-by: BT2983 <BT2983@att.com>
Diffstat (limited to 'ms/neng/src/test/java')
5 files changed, 134 insertions, 15 deletions
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/SequenceFormatterTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/SequenceFormatterTest.java index 5a161319..86f418ac 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/SequenceFormatterTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/SequenceFormatterTest.java @@ -33,8 +33,7 @@ public class SequenceFormatterTest { private PolicySequence poly; @Before - public void setUp() - { + public void setUp() { poly = new PolicySequence(); } @@ -60,31 +59,27 @@ public class SequenceFormatterTest { } @Test - public void testGetSetIncrement() - { + public void testGetSetIncrement() { poly.setIncrement(1L); assertEquals(1L, poly.getIncrement()); } @Test - public void testGetSetMaxValue() - { + public void testGetSetMaxValue() { poly.setMaxValue(1L); assertEquals(1L, poly.getMaxValue()); } @Test - public void testGetSetKey() - { + public void testGetSetKey() { poly.setKey("testKey"); assertEquals("testKey", poly.getKey()); } @Test - public void testGetSetLastReleaseSeqNumTried() - { + public void testGetSetLastReleaseSeqNumTried() { poly.setLastReleaseSeqNumTried(1L); - Long expected=1L; + Long expected = 1L; assertEquals(expected, poly.getLastReleaseSeqNumTried()); } } diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReaderTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReaderTest.java index 30fc6e45..b439c610 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReaderTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReaderTest.java @@ -21,9 +21,15 @@ package org.onap.ccsdk.apps.ms.neng.core.policy; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.onap.ccsdk.apps.ms.neng.core.policy.PolicyReader.namingModels; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; import java.util.Map; + import org.junit.Test; public class PolicyReaderTest { @@ -41,4 +47,57 @@ public class PolicyReaderTest { assertEquals("VNF", PolicyReader.relaxedNamingType("vnf-name")); assertEquals("VNF", PolicyReader.relaxedNamingType("vnf_name")); } + + @Test + public void testNamingProperty() throws Exception { + List<Map<String, ?>> namingModels = PolicyReader.namingModels(buildPolicyResponse_withoutContent()); + assertNotNull(namingModels); + assertNull(PolicyReader.namingProperty(namingModels.get(0), "TEST")); + namingModels = PolicyReader.namingModels(buildPolicyResponse_withoutContent()); + assertNull(PolicyReader.namingProperty(namingModels.get(0), "TEST")); + } + + @Test + public void testNamingModelRelaxed() throws Exception { + List<Map<String, ?>> namingModels = PolicyReader.namingModels(buildPolicyResponse_withoutContent()); + assertNotNull(PolicyReader.namingModelRelaxed(namingModels, "VNF")); + } + + @Test + public void testDependentNamingModel() throws Exception { + List<Map<String, ?>> namingModels = PolicyReader.namingModels(buildPolicyResponse_withoutContent()); + assertNotNull(PolicyReader.dependentNamingModel(namingModels, "VNF")); + assertNotNull(PolicyReader.dependentNamingModel(namingModels, "VNF_NAME")); + assertNull(PolicyReader.dependentNamingModel(namingModels, "VNFC_NAME")); + } + + @Test + public void testNumber() throws Exception { + assertEquals(100, PolicyReader.number("10G", 100L)); + } + + private Map<String, ?> buildPolicyResponse_withoutContent() { + Map<String, Object> policyDataMap = new HashMap<>(); + policyDataMap.put("policy-instance-name", "SDNC_Policy.Config_MS_VNFCNamingPolicy"); + + Map<String, Object> namingModelMap = new HashMap<>(); + namingModelMap.put("nf-role", "vPE"); + namingModelMap.put("naming-type", "VNF"); + namingModelMap.put("naming-recipe", "COMPLEX|NF-NAMING-CODE|Field2|Field3|Field4"); + + Map<String, Object> namingPropertyMap = new HashMap<>(); + Map<String, Object> propertyMap1 = new HashMap<>(); + propertyMap1.put("property-name", "COMPLEX"); + Map<String, Object> propertyMap2 = new HashMap<>(); + propertyMap2.put("property-name", "NF-NAMING-CODE"); + namingPropertyMap.put("", Arrays.asList(new Object[] {propertyMap1, propertyMap2})); + + namingModelMap.put("naming-properties", Arrays.asList(new Object[] {propertyMap1, propertyMap2})); + + policyDataMap.put("naming-models", Arrays.asList(new Object[] {namingModelMap})); + + Map<String, Object> configMap = new HashMap<>(); + configMap.put("config", policyDataMap); + return configMap; + } } diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequenceTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequenceTest.java new file mode 100644 index 00000000..9a0bbbd3 --- /dev/null +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequenceTest.java @@ -0,0 +1,43 @@ +package org.onap.ccsdk.apps.ms.neng.core.policy; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class PolicySequenceTest { + + @Test + public void testGetMaxValue() throws Exception { + PolicySequence seq = new PolicySequence(); + seq.setMaxValueString("0AB"); + seq.setType(PolicySequence.Type.ALPHA); + assertEquals(371L, seq.getMaxValue()); + } + + @Test + public void testGetMaxValue_Exp() throws Exception { + PolicySequence seq = new PolicySequence(); + seq.setMaxValueString("0AB"); + seq.setType(PolicySequence.Type.NUMERIC); + assertEquals(999, seq.getMaxValue()); + } + + @Test + public void testGetMaxValue_Numeric() throws Exception { + PolicySequence seq = new PolicySequence(); + seq.setMaxValueString("011"); + seq.setType(PolicySequence.Type.NUMERIC); + assertEquals(11, seq.getMaxValue()); + } + + @Test + public void testGetMaxValue_null_maxvalue() throws Exception { + PolicySequence seq = new PolicySequence(); + seq.setLength(3); + seq.setType(PolicySequence.Type.NUMERIC); + assertEquals(999, seq.getMaxValue()); + } +} diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java index c3815f43..aca0a533 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java @@ -20,6 +20,7 @@ package org.onap.ccsdk.apps.ms.neng.core.service; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; @@ -44,8 +45,10 @@ import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; import org.onap.ccsdk.apps.ms.neng.core.resource.model.NameGenRequest; import org.onap.ccsdk.apps.ms.neng.core.resource.model.NameGenResponse; import org.onap.ccsdk.apps.ms.neng.core.service.rs.RestServiceImpl; +import org.onap.ccsdk.apps.ms.neng.persistence.entity.ExternalInterface; import org.onap.ccsdk.apps.ms.neng.persistence.entity.GeneratedName; import org.onap.ccsdk.apps.ms.neng.persistence.entity.PolicyDetails; +import org.onap.ccsdk.apps.ms.neng.persistence.repository.ExternalInterfaceRespository; import org.onap.ccsdk.apps.ms.neng.persistence.repository.PolicyDetailsRepository; import org.onap.ccsdk.apps.ms.neng.persistence.repository.ServiceParameterRepository; import org.onap.ccsdk.apps.ms.neng.service.extinf.impl.AaiServiceImpl; @@ -85,6 +88,8 @@ public class SpringServiceIntTest { AaiServiceImpl aaiServiceImpl; @Autowired RestServiceImpl restServiceImpl; + @Autowired + ExternalInterfaceRespository extIntRepo; @Before public void setup() { @@ -215,4 +220,23 @@ public class SpringServiceIntTest { doThrow(new NengException("")).when(springService).addPolicy(policy); restServiceImpl.addPolicyToDb(policy); } + + @Test + public void testExternalInterfaceRepo() throws Exception { + ExternalInterface extInt = new ExternalInterface(); + extInt.setCreatedBy("user"); + extInt.setCreatedTime(null); + extInt.setExternalInteraceId(100); + extInt.setLastUpdatedBy("user"); + extInt.setParam("VNF"); + extInt.setSystem("AAI"); + extInt.setUrlSuffix("nodes/generic-vnfs?vnf-name="); + + extIntRepo.save(extInt); + ExternalInterface extIntDb = extIntRepo.findOne(100); + + assertNotNull(extIntDb); + assertEquals("nodes/generic-vnfs?vnf-name=",extIntDb.getUrlSuffix()); + } + } diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java index b4821a21..7ea63e61 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java @@ -110,14 +110,12 @@ public class SpringServiceTest { } @Test - public void testGetQuickHello() - { + public void testGetQuickHello() { Assert.assertTrue(springserviceImpl.getQuickHello("testMessage") instanceof HelloWorld); } @Test - public void testGetQuickHelloForNullMessage() - { + public void testGetQuickHelloForNullMessage() { Assert.assertTrue(springserviceImpl.getQuickHello("") instanceof HelloWorld); } } |