summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhillip Leigh <phillip.leigh@amdocs.com>2018-09-11 11:02:53 -0400
committerPhillip Leigh <phillip.leigh@amdocs.com>2018-09-13 13:59:44 -0400
commit7c28777349b02dc8c39deb9bf40cfdaf1e84cc3d (patch)
tree411800630a52a768cf6a52db7f9d654f726d7099
parent5bae67e63a12d544c5e1e5104c448bae32ceb469 (diff)
Update Data Router to support API V1
Issue-ID: LOG-428 Change-Id: I6cf971539880f19ffb3e0e9cee5535d34c7b71df Signed-off-by: Phillip Leigh <phillip.leigh@amdocs.com>
-rw-r--r--pom.xml68
-rw-r--r--src/main/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntity.java34
-rw-r--r--src/test/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntityTest.java121
3 files changed, 69 insertions, 154 deletions
diff --git a/pom.xml b/pom.xml
index 3249966..546e378 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<!--
+<!--
============LICENSE_START=======================================================
org.onap.aai
================================================================================
@@ -237,6 +237,72 @@ limitations under the License.
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
+ <!-- jacoco-maven-plugin provides the basic report creation during unit testing, such as code-coverage, sonar, etc. -->
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <executions>
+ <!-- Prepares the property pointing to the JaCoCo runtime agent which
+ is passed as VM argument when Maven the Surefire plugin is executed. -->
+ <execution>
+ <id>pre-unit-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <!-- Sets the path to the file which contains the execution data. -->
+ <destFile>${sonar.jacoco.reportPath}</destFile>
+ <propertyName>surefireArgLine</propertyName>
+ </configuration>
+ </execution>
+ <!-- Ensures that the code coverage report for unit tests is created
+ after unit tests have been run. -->
+ <execution>
+ <id>post-unit-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <!-- Sets the path to the file which contains the execution data. -->
+ <dataFile>${sonar.jacoco.reportPath}</dataFile>
+ <!-- Sets the output directory for the code coverage report. -->
+ <outputDirectory>${jacoco.path}</outputDirectory>
+ </configuration>
+ </execution>
+ <!-- Prepares the property pointing to the JaCoCo runtime agent which
+ is passed as VM argument when Maven the Failsafe plugin is executed. -->
+ <execution>
+ <id>pre-integration-test</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <!-- Sets the path to the file which contains the execution data. -->
+ <destFile>${sonar.jacoco.itReportPath}</destFile>
+ <!-- Sets the name of the property containing the settings for JaCoCo
+ runtime agent. -->
+ <propertyName>failsafeArgLine</propertyName>
+ </configuration>
+ </execution>
+ <!-- Ensures that the code coverage report for integration tests after
+ integration tests have been run. -->
+ <execution>
+ <id>post-integration-test</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <!-- Sets the path to the file which contains the execution data. -->
+ <dataFile>${sonar.jacoco.itReportPath}/</dataFile>
+ <!-- Sets the output directory for the code coverage report. -->
+ <outputDirectory>${jacoco.itPath}</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
<!-- Checkstyle plugin - used to report on compliance with -->
<!-- the Google style guide. -->
<plugin>
diff --git a/src/main/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntity.java b/src/main/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntity.java
index 419db87..810255c 100644
--- a/src/main/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntity.java
+++ b/src/main/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntity.java
@@ -36,20 +36,16 @@ import org.onap.aai.datarouter.service.AuditService;
public class POAServiceInstanceEntity
{
private static final String ATTR_SERVICE_INST_ID = "serviceInstanceId";
- private static final String ATTR_SERVICE_TYPE = "serviceType";
private static final String ATTR_MODEL_VERSION_ID = "modelVersionId";
private static final String ATTR_MODEL_INVARIANT_ID = "modelInvariantId";
- private static final String ATTR_CUSTOMER_ID = "customerId";
private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
private String xFromAppId;
private String xTransactionId;
private String serviceInstanceId;
- private String serviceType;
private String modelVersionId;
private String modelInvariantId;
- private String customerId;
private static Logger logger = LoggerFactory.getInstance().getLogger(POAServiceInstanceEntity.class.getName());
@@ -78,14 +74,6 @@ public class POAServiceInstanceEntity
this.serviceInstanceId = serviceInstanceId;
}
- public String getServiceType() {
- return serviceType;
- }
-
- public void setServiceType(String serviceType) {
- this.serviceType = serviceType;
- }
-
public String getModelVersionId() {
return modelVersionId;
}
@@ -102,15 +90,6 @@ public class POAServiceInstanceEntity
this.modelInvariantId = modelInvariantId;
}
- public String getCustomerId() {
- return customerId;
- }
-
- public void setCustomerId(String customerId) {
- this.customerId = customerId;
- }
-
-
public String toJson() {
return gson.toJson(this);
}
@@ -142,11 +121,6 @@ public class POAServiceInstanceEntity
throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);
}
- if(serviceType == null || serviceType.isEmpty()) {
- String error = "Missing attribute: " + ATTR_SERVICE_TYPE;
- throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);
- }
-
if(modelVersionId == null || modelVersionId.isEmpty()) {
String error = "Missing attribute: " + ATTR_MODEL_VERSION_ID;
throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);
@@ -157,17 +131,13 @@ public class POAServiceInstanceEntity
throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);
}
- if(customerId == null || customerId.isEmpty()) {
- String error = "Missing attribute: " + ATTR_CUSTOMER_ID;
- throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);
- }
}
@Override
public String toString() {
return "ServiceInstance [xFromAppId=" + xFromAppId + ", xTransactionId=" + xTransactionId
- + ", serviceInstanceId=" + serviceInstanceId + ", serviceType=" + serviceType + ", modelVersionId="
- + modelVersionId + ", modelInvariantId=" + modelInvariantId + ", customerId=" + customerId + "]";
+ + ", serviceInstanceId=" + serviceInstanceId + ", modelVersionId="
+ + modelVersionId + ", modelInvariantId=" + modelInvariantId + "]";
}
}
diff --git a/src/test/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntityTest.java b/src/test/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntityTest.java
index 1f3db97..4f9142c 100644
--- a/src/test/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntityTest.java
+++ b/src/test/java/org/onap/aai/datarouter/entity/POAServiceInstanceEntityTest.java
@@ -34,8 +34,6 @@ public class POAServiceInstanceEntityTest {
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";
- String customerId = "global-customer-01";
- String serviceType = "vFW";
String xFromAppId ="REST-client";
String xTransactionId = "aaa111cccc4444";
@@ -43,8 +41,6 @@ public class POAServiceInstanceEntityTest {
svcEntity.setServiceInstanceId(svcInstanceId);
svcEntity.setModelVersionId(modelVersionId);
svcEntity.setModelInvariantId(modelInvariantId);
- svcEntity.setCustomerId(customerId);
- svcEntity.setServiceType(serviceType);
svcEntity.setxFromAppId(xFromAppId);
svcEntity.setxTransactionId(xTransactionId);
@@ -52,8 +48,6 @@ public class POAServiceInstanceEntityTest {
Assert.assertEquals(modelVersionId, svcEntity.getModelVersionId());
Assert.assertEquals(modelInvariantId, svcEntity.getModelInvariantId());
- Assert.assertEquals(customerId, svcEntity.getCustomerId());
- Assert.assertEquals(serviceType, svcEntity.getServiceType());
Assert.assertEquals(xFromAppId, svcEntity.getxFromAppId());
Assert.assertEquals(xTransactionId, svcEntity.getxTransactionId());
@@ -63,15 +57,11 @@ public class POAServiceInstanceEntityTest {
public void testNullServiceInstanceId() throws POAAuditException {
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";
- String customerId = "global-customer-01";
- String serviceType = "vFW";
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
svcEntity.setServiceInstanceId(null);
svcEntity.setModelVersionId(modelVersionId);
svcEntity.setModelInvariantId(modelInvariantId);
- svcEntity.setCustomerId(customerId);
- svcEntity.setServiceType(serviceType);
try {
svcEntity.validate();
@@ -85,15 +75,11 @@ public class POAServiceInstanceEntityTest {
public void testEmptyServiceInstanceId() throws POAAuditException {
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";
- String customerId = "global-customer-01";
- String serviceType = "vFW";
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
svcEntity.setServiceInstanceId("");
svcEntity.setModelVersionId(modelVersionId);
svcEntity.setModelInvariantId(modelInvariantId);
- svcEntity.setCustomerId(customerId);
- svcEntity.setServiceType(serviceType);
try {
svcEntity.validate();
@@ -107,16 +93,11 @@ public class POAServiceInstanceEntityTest {
public void testNullModelVersionId() throws POAAuditException {
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";
- String customerId = "global-customer-01";
- String serviceType = "vFW";
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
svcEntity.setServiceInstanceId(svcInstanceId);
svcEntity.setModelVersionId(null);
svcEntity.setModelInvariantId(modelInvariantId);
- svcEntity.setCustomerId(customerId);
- svcEntity.setServiceType(serviceType);
-
try {
svcEntity.validate();
} catch (POAAuditException e) {
@@ -128,15 +109,11 @@ public class POAServiceInstanceEntityTest {
public void testEmptyModelVersionId() throws POAAuditException {
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";
- String customerId = "global-customer-01";
- String serviceType = "vFW";
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
svcEntity.setServiceInstanceId(svcInstanceId);
svcEntity.setModelVersionId("");
svcEntity.setModelInvariantId(modelInvariantId);
- svcEntity.setCustomerId(customerId);
- svcEntity.setServiceType(serviceType);
try {
svcEntity.validate();
@@ -150,15 +127,11 @@ public class POAServiceInstanceEntityTest {
public void testNullModelInvariantId() throws POAAuditException {
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";
- String customerId = "global-customer-01";
- String serviceType = "vFW";
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
svcEntity.setServiceInstanceId(svcInstanceId);
svcEntity.setModelVersionId(modelVersionId);
svcEntity.setModelInvariantId(null);
- svcEntity.setCustomerId(customerId);
- svcEntity.setServiceType(serviceType);
try {
svcEntity.validate();
@@ -172,105 +145,11 @@ public class POAServiceInstanceEntityTest {
public void testEmptyModelInvariantId() throws POAAuditException {
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";
- String customerId = "global-customer-01";
- String serviceType = "vFW";
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
svcEntity.setServiceInstanceId(svcInstanceId);
svcEntity.setModelVersionId(modelVersionId);
svcEntity.setModelInvariantId("");
- svcEntity.setCustomerId(customerId);
- svcEntity.setServiceType(serviceType);
-
- try {
- svcEntity.validate();
- } catch (POAAuditException e) {
- assertEquals(Status.BAD_REQUEST, e.getHttpStatus());
- }
- }
-
- @Test
- public void testNullServiceType() throws POAAuditException {
- String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";
- String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";
- String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";
- String customerId = "global-customer-01";
-
-
- POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
- svcEntity.setServiceInstanceId(svcInstanceId);
- svcEntity.setModelVersionId(modelVersionId);
- svcEntity.setModelInvariantId(modelInvariantId);
- svcEntity.setCustomerId(customerId);
- svcEntity.setServiceType(null);
-
- try {
- svcEntity.validate();
- } catch (POAAuditException e) {
- assertEquals(Status.BAD_REQUEST, e.getHttpStatus());
- }
- }
-
-
- @Test
- public void testEmptyServiceType() throws POAAuditException {
- String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";
- String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";
- String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";
- String customerId = "global-customer-01";
-
-
- POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
- svcEntity.setServiceInstanceId(svcInstanceId);
- svcEntity.setModelVersionId(modelVersionId);
- svcEntity.setModelInvariantId(modelInvariantId);
- svcEntity.setCustomerId(customerId);
- svcEntity.setServiceType("");
-
- try {
- svcEntity.validate();
- } catch (POAAuditException e) {
- assertEquals(Status.BAD_REQUEST, e.getHttpStatus());
- }
- }
-
-
- @Test
- public void testNullCustomerId() throws POAAuditException {
- String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";
- String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";
- String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";
- String serviceType = "vFW";
-
- POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
- svcEntity.setServiceInstanceId(svcInstanceId);
- svcEntity.setModelVersionId(modelVersionId);
- svcEntity.setModelInvariantId(modelInvariantId);
- svcEntity.setCustomerId(null);
- svcEntity.setServiceType(serviceType);
-
- try {
- svcEntity.validate();
- } catch (POAAuditException e) {
- assertEquals(Status.BAD_REQUEST, e.getHttpStatus());
- }
- }
-
-
- @Test
- public void testEmptyCustomerId() throws POAAuditException {
- String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";
- String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";
- String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";
- String serviceType = "vFW";
-
- POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();
- svcEntity.setServiceInstanceId(svcInstanceId);
- svcEntity.setModelVersionId(modelVersionId);
- svcEntity.setModelInvariantId(modelInvariantId);
- svcEntity.setCustomerId("");
- svcEntity.setServiceType(serviceType);
-
try {
svcEntity.validate();
} catch (POAAuditException e) {