-<!--
+<!--
============LICENSE_START=======================================================
org.onap.aai
================================================================================
<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>
public class POAServiceInstanceEntity\r
{\r
private static final String ATTR_SERVICE_INST_ID = "serviceInstanceId";\r
- private static final String ATTR_SERVICE_TYPE = "serviceType";\r
private static final String ATTR_MODEL_VERSION_ID = "modelVersionId";\r
private static final String ATTR_MODEL_INVARIANT_ID = "modelInvariantId";\r
- private static final String ATTR_CUSTOMER_ID = "customerId";\r
\r
private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();\r
\r
private String xFromAppId;\r
private String xTransactionId;\r
private String serviceInstanceId;\r
- private String serviceType;\r
private String modelVersionId;\r
private String modelInvariantId;\r
- private String customerId;\r
\r
private static Logger logger = LoggerFactory.getInstance().getLogger(POAServiceInstanceEntity.class.getName());\r
\r
this.serviceInstanceId = serviceInstanceId;\r
}\r
\r
- public String getServiceType() {\r
- return serviceType;\r
- }\r
-\r
- public void setServiceType(String serviceType) {\r
- this.serviceType = serviceType;\r
- }\r
-\r
public String getModelVersionId() {\r
return modelVersionId;\r
}\r
this.modelInvariantId = modelInvariantId;\r
}\r
\r
- public String getCustomerId() {\r
- return customerId;\r
- }\r
-\r
- public void setCustomerId(String customerId) {\r
- this.customerId = customerId;\r
- }\r
-\r
-\r
public String toJson() {\r
return gson.toJson(this);\r
}\r
throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
}\r
\r
- if(serviceType == null || serviceType.isEmpty()) {\r
- String error = "Missing attribute: " + ATTR_SERVICE_TYPE;\r
- throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
- }\r
-\r
if(modelVersionId == null || modelVersionId.isEmpty()) {\r
String error = "Missing attribute: " + ATTR_MODEL_VERSION_ID;\r
throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
}\r
\r
- if(customerId == null || customerId.isEmpty()) {\r
- String error = "Missing attribute: " + ATTR_CUSTOMER_ID;\r
- throw new POAAuditException(error, Status.BAD_REQUEST, DataRouterMsgs.BAD_REST_REQUEST, error);\r
- }\r
}\r
\r
\r
@Override\r
public String toString() {\r
return "ServiceInstance [xFromAppId=" + xFromAppId + ", xTransactionId=" + xTransactionId\r
- + ", serviceInstanceId=" + serviceInstanceId + ", serviceType=" + serviceType + ", modelVersionId="\r
- + modelVersionId + ", modelInvariantId=" + modelInvariantId + ", customerId=" + customerId + "]";\r
+ + ", serviceInstanceId=" + serviceInstanceId + ", modelVersionId="\r
+ + modelVersionId + ", modelInvariantId=" + modelInvariantId + "]";\r
}\r
}\r
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
- String customerId = "global-customer-01";\r
- String serviceType = "vFW";\r
String xFromAppId ="REST-client";\r
String xTransactionId = "aaa111cccc4444";\r
\r
svcEntity.setServiceInstanceId(svcInstanceId);\r
svcEntity.setModelVersionId(modelVersionId);\r
svcEntity.setModelInvariantId(modelInvariantId);\r
- svcEntity.setCustomerId(customerId);\r
- svcEntity.setServiceType(serviceType);\r
svcEntity.setxFromAppId(xFromAppId);\r
svcEntity.setxTransactionId(xTransactionId);\r
\r
Assert.assertEquals(modelVersionId, svcEntity.getModelVersionId());\r
Assert.assertEquals(modelInvariantId, svcEntity.getModelInvariantId());\r
\r
- Assert.assertEquals(customerId, svcEntity.getCustomerId());\r
- Assert.assertEquals(serviceType, svcEntity.getServiceType());\r
Assert.assertEquals(xFromAppId, svcEntity.getxFromAppId());\r
Assert.assertEquals(xTransactionId, svcEntity.getxTransactionId());\r
\r
public void testNullServiceInstanceId() throws POAAuditException {\r
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
- String customerId = "global-customer-01";\r
- String serviceType = "vFW";\r
\r
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
svcEntity.setServiceInstanceId(null);\r
svcEntity.setModelVersionId(modelVersionId);\r
svcEntity.setModelInvariantId(modelInvariantId);\r
- svcEntity.setCustomerId(customerId);\r
- svcEntity.setServiceType(serviceType);\r
\r
try {\r
svcEntity.validate();\r
public void testEmptyServiceInstanceId() throws POAAuditException {\r
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
- String customerId = "global-customer-01";\r
- String serviceType = "vFW";\r
\r
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
svcEntity.setServiceInstanceId("");\r
svcEntity.setModelVersionId(modelVersionId);\r
svcEntity.setModelInvariantId(modelInvariantId);\r
- svcEntity.setCustomerId(customerId);\r
- svcEntity.setServiceType(serviceType);\r
\r
try {\r
svcEntity.validate();\r
public void testNullModelVersionId() throws POAAuditException {\r
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
- String customerId = "global-customer-01";\r
- String serviceType = "vFW";\r
\r
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
svcEntity.setServiceInstanceId(svcInstanceId);\r
svcEntity.setModelVersionId(null);\r
svcEntity.setModelInvariantId(modelInvariantId);\r
- svcEntity.setCustomerId(customerId);\r
- svcEntity.setServiceType(serviceType);\r
-\r
try {\r
svcEntity.validate();\r
} catch (POAAuditException e) {\r
public void testEmptyModelVersionId() throws POAAuditException {\r
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
- String customerId = "global-customer-01";\r
- String serviceType = "vFW";\r
\r
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
svcEntity.setServiceInstanceId(svcInstanceId);\r
svcEntity.setModelVersionId("");\r
svcEntity.setModelInvariantId(modelInvariantId);\r
- svcEntity.setCustomerId(customerId);\r
- svcEntity.setServiceType(serviceType);\r
\r
try {\r
svcEntity.validate();\r
public void testNullModelInvariantId() throws POAAuditException {\r
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
- String customerId = "global-customer-01";\r
- String serviceType = "vFW";\r
\r
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
svcEntity.setServiceInstanceId(svcInstanceId);\r
svcEntity.setModelVersionId(modelVersionId);\r
svcEntity.setModelInvariantId(null);\r
- svcEntity.setCustomerId(customerId);\r
- svcEntity.setServiceType(serviceType);\r
\r
try {\r
svcEntity.validate();\r
public void testEmptyModelInvariantId() throws POAAuditException {\r
String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
- String customerId = "global-customer-01";\r
- String serviceType = "vFW";\r
\r
POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
svcEntity.setServiceInstanceId(svcInstanceId);\r
svcEntity.setModelVersionId(modelVersionId);\r
svcEntity.setModelInvariantId("");\r
- svcEntity.setCustomerId(customerId);\r
- svcEntity.setServiceType(serviceType);\r
-\r
- try {\r
- svcEntity.validate();\r
- } catch (POAAuditException e) {\r
- assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
- }\r
- }\r
-\r
- @Test\r
- public void testNullServiceType() throws POAAuditException {\r
- String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
- String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
- String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
- String customerId = "global-customer-01";\r
-\r
-\r
- POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
- svcEntity.setServiceInstanceId(svcInstanceId);\r
- svcEntity.setModelVersionId(modelVersionId);\r
- svcEntity.setModelInvariantId(modelInvariantId);\r
- svcEntity.setCustomerId(customerId);\r
- svcEntity.setServiceType(null);\r
-\r
- try {\r
- svcEntity.validate();\r
- } catch (POAAuditException e) {\r
- assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
- }\r
- }\r
-\r
-\r
- @Test\r
- public void testEmptyServiceType() throws POAAuditException {\r
- String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
- String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
- String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
- String customerId = "global-customer-01";\r
-\r
-\r
- POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
- svcEntity.setServiceInstanceId(svcInstanceId);\r
- svcEntity.setModelVersionId(modelVersionId);\r
- svcEntity.setModelInvariantId(modelInvariantId);\r
- svcEntity.setCustomerId(customerId);\r
- svcEntity.setServiceType("");\r
-\r
- try {\r
- svcEntity.validate();\r
- } catch (POAAuditException e) {\r
- assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
- }\r
- }\r
-\r
-\r
- @Test\r
- public void testNullCustomerId() throws POAAuditException {\r
- String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
- String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
- String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
- String serviceType = "vFW";\r
-\r
- POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
- svcEntity.setServiceInstanceId(svcInstanceId);\r
- svcEntity.setModelVersionId(modelVersionId);\r
- svcEntity.setModelInvariantId(modelInvariantId);\r
- svcEntity.setCustomerId(null);\r
- svcEntity.setServiceType(serviceType);\r
-\r
- try {\r
- svcEntity.validate();\r
- } catch (POAAuditException e) {\r
- assertEquals(Status.BAD_REQUEST, e.getHttpStatus());\r
- }\r
- }\r
-\r
-\r
- @Test\r
- public void testEmptyCustomerId() throws POAAuditException {\r
- String svcInstanceId = "24602405-7714-4c64-81da-9e182a3eba59";\r
- String modelVersionId = "2f836857-d399-4de3-a6f8-e4a09d3017eb";\r
- String modelInvariantId = "8c383ba3-20c3-4196-b092-c8c007ef7ddc";\r
- String serviceType = "vFW";\r
-\r
- POAServiceInstanceEntity svcEntity= new POAServiceInstanceEntity();\r
- svcEntity.setServiceInstanceId(svcInstanceId);\r
- svcEntity.setModelVersionId(modelVersionId);\r
- svcEntity.setModelInvariantId(modelInvariantId);\r
- svcEntity.setCustomerId("");\r
- svcEntity.setServiceType(serviceType);\r
-\r
try {\r
svcEntity.validate();\r
} catch (POAAuditException e) {\r