summaryrefslogtreecommitdiffstats
path: root/ms/neng/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'ms/neng/src/test/java')
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/SequenceFormatterTest.java43
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java9
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java15
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java97
4 files changed, 162 insertions, 2 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 df28ccce..5a161319 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
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* 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
@@ -22,13 +24,22 @@ package org.onap.ccsdk.apps.ms.neng.core.gen;
import static org.junit.Assert.assertEquals;
+import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.apps.ms.neng.core.policy.PolicySequence;
public class SequenceFormatterTest {
+
+ private PolicySequence poly;
+
+ @Before
+ public void setUp()
+ {
+ poly = new PolicySequence();
+ }
+
@Test
public void formatSequence() throws Exception {
- PolicySequence poly = new PolicySequence();
poly.setLength(3);;
assertEquals("001", SequenceFormatter.formatSequence(1, poly));
poly.setLength(2);;
@@ -39,7 +50,6 @@ public class SequenceFormatterTest {
@Test
public void formatSequenceAlpha() throws Exception {
- PolicySequence poly = new PolicySequence();
poly.setLength(3);;
poly.setType(PolicySequence.Type.ALPHA);
assertEquals("001", SequenceFormatter.formatSequence(1, poly));
@@ -48,4 +58,33 @@ public class SequenceFormatterTest {
poly.setLength(4);;
assertEquals("000b", SequenceFormatter.formatSequence(11, poly));
}
+
+ @Test
+ public void testGetSetIncrement()
+ {
+ poly.setIncrement(1L);
+ assertEquals(1L, poly.getIncrement());
+ }
+
+ @Test
+ public void testGetSetMaxValue()
+ {
+ poly.setMaxValue(1L);
+ assertEquals(1L, poly.getMaxValue());
+ }
+
+ @Test
+ public void testGetSetKey()
+ {
+ poly.setKey("testKey");
+ assertEquals("testKey", poly.getKey());
+ }
+
+ @Test
+ public void testGetSetLastReleaseSeqNumTried()
+ {
+ poly.setLastReleaseSeqNumTried(1L);
+ Long expected=1L;
+ assertEquals(expected, poly.getLastReleaseSeqNumTried());
+ }
}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java
index 9d6c3f92..38d44f18 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* 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
@@ -21,6 +23,7 @@
package org.onap.ccsdk.apps.ms.neng.core.policy;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -72,6 +75,12 @@ public class PropertyOperatorTest {
PropertyOperator op = new PropertyOperator();
assertEquals("ASDF", op.apply("asdf", props, params));
}
+
+ @Test
+ public void testApply() throws Exception {
+ PropertyOperator op = new PropertyOperator();
+ assertNull("ASDF", op.apply("asdf", "", params));
+ }
@Test
public void applySubstr() throws Exception {
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 303692c5..b4821a21 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
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* 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
@@ -31,6 +33,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.HelloWorld;
import org.onap.ccsdk.apps.ms.neng.core.resource.model.NameGenRequest;
import org.onap.ccsdk.apps.ms.neng.core.validator.ExternalKeyValidator;
import org.onap.ccsdk.apps.ms.neng.persistence.entity.GeneratedName;
@@ -105,4 +108,16 @@ public class SpringServiceTest {
Mockito.when(generatedNameRepository.findByExternalId(req.get("external-key"))).thenReturn(generatedNameList);
Assert.assertNotNull(springserviceImpl.releaseNetworkElementName(request));
}
+
+ @Test
+ public void testGetQuickHello()
+ {
+ Assert.assertTrue(springserviceImpl.getQuickHello("testMessage") instanceof HelloWorld);
+ }
+
+ @Test
+ public void testGetQuickHelloForNullMessage()
+ {
+ Assert.assertTrue(springserviceImpl.getQuickHello("") instanceof HelloWorld);
+ }
}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java
new file mode 100644
index 00000000..26d2ef0e
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 IBM. 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.ccsdk.apps.ms.neng.persistence.entity;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestExternalInterface {
+ private ExternalInterface externalInterface;
+
+ @Before
+ public void setUp() {
+ externalInterface = new ExternalInterface();
+ }
+
+ @Test
+ public void testGetSetExternalInteraceId() {
+ externalInterface.setExternalInteraceId(1);
+ Integer expected = 1;
+ Assert.assertEquals(expected, externalInterface.getExternalInteraceId());
+ }
+
+ @Test
+ public void testGetSetSystem() {
+ externalInterface.setSystem("testSystem");
+ Assert.assertEquals("testSystem", externalInterface.getSystem());
+ }
+
+ @Test
+ public void testGetSetParam() {
+ externalInterface.setParam("testParam");
+ Assert.assertEquals("testParam", externalInterface.getParam());
+ }
+
+ @Test
+ public void testGetSetUrlSuffix() {
+ externalInterface.setUrlSuffix("testUrlSuffix");
+ Assert.assertEquals("testUrlSuffix", externalInterface.getUrlSuffix());
+ }
+
+ @Test
+ public void testGetSetTimeStamp() throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateFormat.parse("23/09/2007");
+ long time = date.getTime();
+ Timestamp timeStamp = new Timestamp(time);
+ externalInterface.setCreatedTime(timeStamp);
+ Assert.assertEquals(timeStamp, externalInterface.getCreatedTime());
+ }
+
+ @Test
+ public void testGetSetCreatedBy() {
+ externalInterface.setCreatedBy("testUser");
+ Assert.assertEquals("testUser", externalInterface.getCreatedBy());
+ }
+
+ @Test
+ public void testGetSetLastUpdatedTime() throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateFormat.parse("23/09/2007");
+ long time = date.getTime();
+ Timestamp timeStamp = new Timestamp(time);
+ externalInterface.setLastUpdatedTime(timeStamp);
+ Assert.assertEquals(timeStamp, externalInterface.getLastUpdatedTime());
+ }
+
+ @Test
+ public void testGetSetLastUpdatedBy() {
+ externalInterface.setLastUpdatedBy("testUser");
+ Assert.assertEquals("testUser", externalInterface.getLastUpdatedBy());
+ }
+}