summaryrefslogtreecommitdiffstats
path: root/ms/neng
diff options
context:
space:
mode:
Diffstat (limited to 'ms/neng')
-rw-r--r--ms/neng/.classpath21
-rw-r--r--ms/neng/pom.xml152
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java13
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java14
-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/persistence/entity/TestExternalInterface.java97
6 files changed, 255 insertions, 85 deletions
diff --git a/ms/neng/.classpath b/ms/neng/.classpath
index 1272921b..760fe4ae 100644
--- a/ms/neng/.classpath
+++ b/ms/neng/.classpath
@@ -6,22 +6,12 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
- <classpathentry kind="src" output="target-ide/classes" path="opt/etc/config">
+ <classpathentry excluding="**" kind="src" output="target-ide/classes" path="opt/etc/config">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
- <classpathentry kind="src" output="target-ide/classes" path="opt/etc/keystore">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="src" output="target-ide/classes" path="opt/etc/truststore">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="src" output="target-ide/classes" path="src/main/resources">
+ <classpathentry excluding="**" kind="src" output="target-ide/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@@ -32,12 +22,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
- <classpathentry kind="src" output="target-ide/test-classes" path="src/test/resources">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="src" output="target-ide/classes" path="opt/aai/keystore">
+ <classpathentry excluding="**" kind="src" output="target-ide/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
diff --git a/ms/neng/pom.xml b/ms/neng/pom.xml
index 8390350a..87ac192e 100644
--- a/ms/neng/pom.xml
+++ b/ms/neng/pom.xml
@@ -54,6 +54,10 @@
<serviceArtifactName>ms-networkelementnamegen</serviceArtifactName>
<project.version>0.3.0</project.version>
<ccsdk.distribution.version>0.2.4</ccsdk.distribution.version>
+ <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy>
+ <docker.push.phase>deploy</docker.push.phase>
+ <docker.verbose>true</docker.verbose>
+ <ccsdk.project.version>${project.version}</ccsdk.project.version>
</properties>
<profiles>
@@ -109,6 +113,63 @@
</build>
</profile>
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.4.11</version>
+ <configuration>
+ <imageName>onap/ccsdk-apps-ms-neng:${project.version}</imageName>
+ <dockerDirectory>src/main/docker</dockerDirectory>
+ <serverId>docker-hub</serverId>
+ <registryUrl>https://${docker.registry}</registryUrl>
+ <imageTags>
+ <imageTag>${project.version}</imageTag>
+ <imageTag>${project.version}-STAGING-${maven.build.timestamp}</imageTag>
+ <imageTag>${project.docker.latesttag.version}</imageTag>
+ </imageTags>
+ <forceTags>true</forceTags>
+ <resources>
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${project.build.directory}</directory>
+ <include>${project.build.finalName}.jar</include>
+ </resource>
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${project.build.directory}</directory>
+ <include>opt/etc/config/*</include>
+ </resource>
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${project.build.directory}</directory>
+ <include>opt/etc/keystore/*</include>
+ </resource>
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${project.build.directory}</directory>
+ <include>opt/etc/truststore/*</include>
+ </resource>
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${project.build.directory}</directory>
+ <include>opt/aai/keystore/*</include>
+ </resource>
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${project.build.directory}</directory>
+ <include>etc/*</include>
+ </resource>
+ </resources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
</profiles>
<developers>
@@ -199,11 +260,11 @@
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
- <dependency>
- <groupId>org.wisdom-framework</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.34_1</version>
- </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>${mariadb.connector.version}</version>
+ </dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@@ -260,6 +321,37 @@
<finalName>NetworkElementNameGen</finalName>
<plugins>
<plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>
+ println project.properties['ccsdk.project.version'];
+ def versionArray;
+ if (project.properties['ccsdk.project.version'] != null ) {
+ versionArray = project.properties['ccsdk.project.version'].split('\\.');
+ }
+
+ if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT"))
+ {
+ project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest";
+ } else {
+ project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest";
+ }
+
+ println 'New Tag for docker:' + project.properties['project.docker.latesttag.version'];
+ </source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
@@ -433,54 +525,7 @@
</plugin>
-->
- <plugin>
- <groupId>com.spotify</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>0.4.11</version>
- <configuration>
- <imageName>onap/ccsdk-apps-ms-neng:${project.version}</imageName>
- <dockerDirectory>src/main/docker</dockerDirectory>
- <serverId>docker-hub</serverId>
- <registryUrl>https://${docker.registry}</registryUrl>
- <imageTags>
- <imageTag>${project.version}</imageTag>
- <imageTag>latest</imageTag>
- </imageTags>
- <forceTags>true</forceTags>
- <resources>
- <resource>
- <targetPath>/</targetPath>
- <directory>${project.build.directory}</directory>
- <include>${project.build.finalName}.jar</include>
- </resource>
- <resource>
- <targetPath>/</targetPath>
- <directory>${project.build.directory}</directory>
- <include>opt/etc/config/*</include>
- </resource>
- <resource>
- <targetPath>/</targetPath>
- <directory>${project.build.directory}</directory>
- <include>opt/etc/keystore/*</include>
- </resource>
- <resource>
- <targetPath>/</targetPath>
- <directory>${project.build.directory}</directory>
- <include>opt/etc/truststore/*</include>
- </resource>
- <resource>
- <targetPath>/</targetPath>
- <directory>${project.build.directory}</directory>
- <include>opt/aai/keystore/*</include>
- </resource>
- <resource>
- <targetPath>/</targetPath>
- <directory>${project.build.directory}</directory>
- <include>etc/*</include>
- </resource>
- </resources>
- </configuration>
- </plugin>
+
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -593,5 +638,6 @@
</plugins>
</pluginManagement>
</build>
+
</project>
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java
index 4905e6eb..ead6a1b4 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java
@@ -40,6 +40,13 @@ import org.springframework.stereotype.Component;
@Component
@ApplicationPath("/")
public class JerseyConfiguration extends ResourceConfig {
+
+ @Autowired
+ public JerseyConfiguration() {
+ register(RestServiceImpl.class);
+ property(ServletProperties.FILTER_FORWARD_ON_404, true);
+ }
+
/**
* Builds the bean configuring Jackson for JSON serialization.
*/
@@ -53,10 +60,4 @@ public class JerseyConfiguration extends ResourceConfig {
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
return objectMapper;
}
-
- @Autowired
- public JerseyConfiguration() {
- register(RestServiceImpl.class);
- property(ServletProperties.FILTER_FORWARD_ON_404, true);
- }
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
index 79e46575..daf8f574 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.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
@@ -94,12 +96,12 @@ public class SpringServiceImpl implements SpringService {
@Transactional(rollbackOn = Exception.class)
public NameGenResponse genNetworkElementName(NameGenRequest request) throws Exception {
try {
- Map<String, Map<String, String>> earlierNames = new HashMap<String, Map<String, String>>();
- List<Map<String, String>> allElements = new ArrayList<Map<String, String>>();
- Map<String, Map<String, ?>> policyCache = new HashMap<String, Map<String, ?>>();
- List<Map<String, String>> generatedNames = new ArrayList<Map<String, String>>();
+ Map<String, Map<String, String>> earlierNames = new HashMap<>();
+ List<Map<String, String>> allElements = new ArrayList<>();
+ Map<String, Map<String, ?>> policyCache = new HashMap<>();
+ List<Map<String, String>> generatedNames = new ArrayList<>();
validateRequest(request);
- if (request.getElements() != null && request.getElements().size() > 0) {
+ if (!request.getElements().isEmpty()) {
allElements.addAll(request.getElements());
}
PolicyFinder policyFinderImpl = findPolicyFinderImpl(request);
@@ -194,7 +196,7 @@ public class SpringServiceImpl implements SpringService {
void validateRequest(NameGenRequest request) throws Exception {
List<Map<String, String>> elems = request.getElements();
- if (elems != null && elems.size() > 0) {
+ if (!elems.isEmpty()) {
boolean error = false;
Set<String> externalKeySet = elems.stream().map(s -> s.get("external-key")).collect(Collectors.toSet());
if (externalKeySet.size() != request.getElements().size()) {
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/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());
+ }
+}