summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md9
-rw-r--r--LICENSE.txt6
-rw-r--r--docs/API.md10
-rw-r--r--pom.xml70
-rw-r--r--src/gen/java/io/swagger/api/DcaeServicesApi.java12
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceComponent.java4
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceComponentRequest.java4
-rw-r--r--src/main/java/io/swagger/api/Bootstrap.java5
-rw-r--r--src/main/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactory.java8
-rw-r--r--src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java14
-rw-r--r--src/main/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactory.java8
-rw-r--r--src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java32
-rw-r--r--src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java85
-rw-r--r--src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java6
-rw-r--r--src/main/java/org/onap/dcae/inventory/InventoryApplication.java (renamed from src/main/java/org/openecomp/dcae/inventory/InventoryApplication.java)62
-rw-r--r--src/main/java/org/onap/dcae/inventory/InventoryConfiguration.java (renamed from src/main/java/org/openecomp/dcae/inventory/InventoryConfiguration.java)61
-rw-r--r--src/main/java/org/onap/dcae/inventory/LinkSerializer.java (renamed from src/main/java/org/openecomp/dcae/inventory/LinkSerializer.java)3
-rw-r--r--src/main/java/org/onap/dcae/inventory/clients/DatabusControllerClient.java (renamed from src/main/java/org/openecomp/dcae/inventory/clients/DatabusControllerClient.java)8
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/DCAEServiceComponentsDAO.java (renamed from src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceComponentsDAO.java)8
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTransactionDAO.java (renamed from src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java)13
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java (renamed from src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTypesDAO.java)8
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java (renamed from src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java)4
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/DCAEServicesDAO.java (renamed from src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesDAO.java)10
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/InventoryDAO.java (renamed from src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAO.java)2
-rw-r--r--src/main/java/org/onap/dcae/inventory/daos/InventoryDAOManager.java (renamed from src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAOManager.java)32
-rw-r--r--src/main/java/org/onap/dcae/inventory/dbthings/StringListArgument.java (renamed from src/main/java/org/openecomp/dcae/inventory/dbthings/StringListArgument.java)19
-rw-r--r--src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java (renamed from src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java)4
-rw-r--r--src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java (renamed from src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java)4
-rw-r--r--src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java (renamed from src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java)4
-rw-r--r--src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java (renamed from src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java)2
-rw-r--r--src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObject.java (renamed from src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObject.java)4
-rw-r--r--src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java (renamed from src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java)2
-rw-r--r--src/main/java/org/onap/dcae/inventory/exceptions/DatabusControllerClientException.java (renamed from src/main/java/org/openecomp/dcae/inventory/exceptions/DatabusControllerClientException.java)2
-rw-r--r--src/main/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java (renamed from src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java)16
-rw-r--r--src/main/java/org/onap/dcae/inventory/providers/NotFoundExceptionMapper.java (renamed from src/main/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapper.java)2
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/clients/DCAEControllerClient.java222
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java37
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java41
-rw-r--r--src/main/resources/config.json8
-rw-r--r--src/main/resources/config.yml8
-rw-r--r--src/main/resources/logback.xml74
-rw-r--r--src/test/java/io/swagger/api/BootstrapTest.java (renamed from src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java)28
-rw-r--r--src/test/java/io/swagger/api/Util.java (renamed from src/test/java/Util.java)4
-rw-r--r--src/test/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactoryTest.java (renamed from src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerConnectionException.java)25
-rw-r--r--src/test/java/io/swagger/api/factories/DcaeServicesApiServiceFactoryTest.java (renamed from src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerTimeoutException.java)25
-rw-r--r--src/test/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactoryTest.java37
-rw-r--r--src/test/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImplTests.java (renamed from src/test/java/DcaeServiceTypesApiServiceImplTests.java)15
-rw-r--r--src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplH2Tests.java132
-rw-r--r--src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplTests.java (renamed from src/test/java/DcaeServicesApiServiceImplTests.java)50
-rw-r--r--src/test/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImplTests.java (renamed from src/test/java/DcaeServicesGroupbyApiServiceImplTests.java)14
-rw-r--r--src/test/java/org/onap/dcae/inventory/InventoryConfigurationTest.java61
-rw-r--r--src/test/java/org/onap/dcae/inventory/LinkSerializerTest.java97
-rw-r--r--src/test/java/org/onap/dcae/inventory/clients/DatabusControllerClientTest.java146
-rw-r--r--src/test/java/org/onap/dcae/inventory/daos/DCAEServicesDAOTest.java84
-rw-r--r--src/test/java/org/onap/dcae/inventory/daos/InventoryDAOManagerTests.java (renamed from src/test/java/org/openecomp/dcae/inventory/daos/InventoryDAOManagerTests.java)4
-rw-r--r--src/test/java/org/onap/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java (renamed from src/test/java/org/openecomp/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java)10
-rw-r--r--src/test/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java (renamed from src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java)2
-rw-r--r--src/test/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java (renamed from src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java)2
-rw-r--r--src/test/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java (renamed from src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java)5
-rw-r--r--src/test/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceComponentObjectTests.java (renamed from src/test/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObjectTests.java)2
-rw-r--r--src/test/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObjectTests.java (renamed from src/test/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObjectTests.java)2
-rw-r--r--src/test/java/org/onap/dcae/inventory/exceptions/DatabusControllerClientExceptionTest.java (renamed from src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerClientException.java)24
-rw-r--r--src/test/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapperTests.java (renamed from src/test/java/org/openecomp/dcae/inventory/exception/mappers/DBIExceptionMapperTests.java)6
-rw-r--r--src/test/java/org/onap/dcae/inventory/providers/NotFoundExceptionMapperTests.java (renamed from src/test/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapperTests.java)2
-rw-r--r--src/test/resources/config-databus.yaml4
-rw-r--r--src/test/resources/config-inventory.yaml88
-rw-r--r--swagger_inventory.yaml36
-rw-r--r--version.properties4
68 files changed, 1105 insertions, 737 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ddc7ee2..1c27804 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
The version in the brackets represents the version of DCAE inventory and not the ONAP DCAE version.
+## [3.0.1]
+
+* Explicitly use 5.3.6.Final for hibernate-validator and 9.4.6 for jetty-util to address security issues
+
+## [3.0.0]
+
+* Remove the dcae controller code (housekeeping)
+* Upgrade org.apache.httpcomponents/httpclient to 4.5.5
+
## [2.4.0]
ONAP version: 1.1.0
diff --git a/LICENSE.txt b/LICENSE.txt
index 69d5fc1..9536f0b 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,11 +1,11 @@
/*
* ============LICENSE_START==========================================
* ===================================================================
-* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+* Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
-* under the Apache License, Version 2.0 (the “License”);
+* under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -20,7 +20,7 @@
*
*
* Unless otherwise specified, all documentation contained herein is licensed
-* under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
diff --git a/docs/API.md b/docs/API.md
index a6f0472..ec0ff89 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -10,7 +10,7 @@ DCAE Inventory is a web service that provides the following:
### Version information
-*Version* : 2.1.0
+*Version* : 3.0.0
### Contact information
@@ -189,8 +189,6 @@ Get a list of `DCAEService` objects.
|HTTP Code|Description|Schema|
|---|---|---|
|**200**|List of `DCAEService` objects|[InlineResponse2001](#inlineresponse2001)|
-|**502**|Bad response from DCAE controller|[ApiResponseMessage](#apiresponsemessage)|
-|**504**|Failed to connect with DCAE controller|[ApiResponseMessage](#apiresponsemessage)|
#### Consumes
@@ -258,8 +256,6 @@ Get a `DCAEService` object.
|---|---|---|
|**200**|Single `DCAEService` object|[DCAEService](#dcaeservice)|
|**404**|DCAE service not found|[ApiResponseMessage](#apiresponsemessage)|
-|**502**|Bad response from DCAE controller|[ApiResponseMessage](#apiresponsemessage)|
-|**504**|Failed to connect with DCAE controller|[ApiResponseMessage](#apiresponsemessage)|
#### Consumes
@@ -383,7 +379,7 @@ Remove an existing `DCAEService` object.
|---|---|---|
|**componentId** <br>*required*|The id format is unique to the source|string|
|**componentLink** <br>*required*|Link to the underlying resource of this component|[Link](#link)|
-|**componentSource** <br>*required*|Specifies the name of the underying source service that is responsible for this components|enum (DCAEController, DMaaPController)|
+|**componentSource** <br>*required*|Specifies the name of the underying source service that is responsible for this components|enum (DMaaPController)|
|**componentType** <br>*required*||string|
|**created** <br>*required*||string(date-time)|
|**location** <br>*optional*|Location information of the component|string|
@@ -398,7 +394,7 @@ Remove an existing `DCAEService` object.
|Name|Description|Schema|
|---|---|---|
|**componentId** <br>*required*|The id format is unique to the source|string|
-|**componentSource** <br>*required*|Specifies the name of the underying source service that is responsible for this components|enum (DCAEController, DMaaPController)|
+|**componentSource** <br>*required*|Specifies the name of the underying source service that is responsible for this components|enum (DMaaPController)|
|**componentType** <br>*required*||string|
|**shareable** <br>*required*|Used to determine if this component can be shared amongst different DCAE services|integer(int32)|
diff --git a/pom.xml b/pom.xml
index 0aa1771..eb99140 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,17 +1,36 @@
+<!--
+================================================================================
+Copyright (c) 2017-2018 AT&T Intellectual Property. 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=========================================================
+
+ECOMP is a trademark and service mark of AT&T Intellectual Property.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0</version>
</parent>
<groupId>org.onap.dcaegen2.platform</groupId>
<artifactId>inventory-api</artifactId>
- <version>1.2.0</version>
+ <version>3.0.2</version>
<name>dcaegen2-platform-inventory-api</name>
- <!--internal <version>2.4.0</version>-->
+ <!--internal <version>3.0.0</version>-->
<properties>
<dropwizard.version>1.1.1</dropwizard.version>
@@ -21,7 +40,7 @@
<ecomp.inceptionYear>2017</ecomp.inceptionYear>
<ecomp.organizationName>AT&amp;T Intellectual Property. All rights reserved.</ecomp.organizationName>
- <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<snapshots.path>content/repositories/snapshots/</snapshots.path>
<releases.path>content/repositories/releases/</releases.path>
@@ -49,6 +68,16 @@
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>${dropwizard.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
@@ -65,7 +94,21 @@
is malformed in the internal Maven central. -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.5.2</version>
+ <version>4.5.5</version>
+ </dependency>
+ <dependency>
+ <!-- To address security issue - CVE-2017-7536 -->
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>5.3.6.Final</version>
+ </dependency>
+ <dependency>
+ <!-- To address security issue - CVE-2017-9735
+ REVIEW: Only updated jetty-util which may introduce runtime issues because
+ other jetty libraries are on 9.4.2 still -->
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>9.4.6.v20170531</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
@@ -171,6 +214,18 @@
<version>1.6.5</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-testing</artifactId>
+ <version>${dropwizard.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.4.197</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -258,7 +313,7 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.openecomp.dcae.inventory.InventoryApplication</mainClass>
+ <mainClass>org.onap.dcae.inventory.InventoryApplication</mainClass>
</transformer>
</transformers>
</configuration>
@@ -285,7 +340,8 @@
<expose>8080</expose>
</exposes>
<imageTags>
- <imageTag>${project.version}-${maven.build.timestamp}</imageTag>
+ <imageTag>${project.version}-SNAPSHOT-${maven.build.timestamp}Z</imageTag>
+ <imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<serverId>${onap.nexus.dockerregistry.daily}</serverId>
diff --git a/src/gen/java/io/swagger/api/DcaeServicesApi.java b/src/gen/java/io/swagger/api/DcaeServicesApi.java
index 55d79f3..4c08cda 100644
--- a/src/gen/java/io/swagger/api/DcaeServicesApi.java
+++ b/src/gen/java/io/swagger/api/DcaeServicesApi.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -99,9 +99,8 @@ public class DcaeServicesApi {
@Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
@io.swagger.annotations.ApiOperation(value = "", notes = "Get a list of `DCAEService` objects.", response = InlineResponse2001.class, tags = {})
@io.swagger.annotations.ApiResponses(value = {
- @io.swagger.annotations.ApiResponse(code = 200, message = "List of `DCAEService` objects", response = InlineResponse2001.class),
- @io.swagger.annotations.ApiResponse(code = 502, message = "Bad response from DCAE controller", response = ApiResponseMessage.class),
- @io.swagger.annotations.ApiResponse(code = 504, message = "Failed to connect with DCAE controller", response = ApiResponseMessage.class)})
+ @io.swagger.annotations.ApiResponse(code = 200, message = "List of `DCAEService` objects", response = InlineResponse2001.class)
+ })
public Response dcaeServicesGet(
@ApiParam(value = "DCAE service type name") @QueryParam("typeId") String typeId,
@ApiParam(value = "") @QueryParam("vnfId") String vnfId,
@@ -135,9 +134,8 @@ public class DcaeServicesApi {
@io.swagger.annotations.ApiOperation(value = "", notes = "Get a `DCAEService` object.", response = DCAEService.class, tags = {})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "Single `DCAEService` object", response = DCAEService.class),
- @io.swagger.annotations.ApiResponse(code = 404, message = "DCAE service not found", response = ApiResponseMessage.class),
- @io.swagger.annotations.ApiResponse(code = 502, message = "Bad response from DCAE controller", response = ApiResponseMessage.class),
- @io.swagger.annotations.ApiResponse(code = 504, message = "Failed to connect with DCAE controller", response = ApiResponseMessage.class)})
+ @io.swagger.annotations.ApiResponse(code = 404, message = "DCAE service not found", response = ApiResponseMessage.class)
+ })
public Response dcaeServicesServiceIdGet(
@ApiParam(value = "", required = true) @PathParam("serviceId") String serviceId,
@Context SecurityContext securityContext)
diff --git a/src/gen/java/io/swagger/model/DCAEServiceComponent.java b/src/gen/java/io/swagger/model/DCAEServiceComponent.java
index 6550c76..86d10ae 100644
--- a/src/gen/java/io/swagger/model/DCAEServiceComponent.java
+++ b/src/gen/java/io/swagger/model/DCAEServiceComponent.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -131,7 +131,7 @@ public class DCAEServiceComponent {
@ApiModelProperty(value = "Specifies the name of the underying source service that is responsible for this components", required = true,
- allowableValues = "DCAEController, DMaaPController")
+ allowableValues = "DMaaPController")
@JsonProperty("componentSource")
public String getComponentSource() {
return componentSource;
diff --git a/src/gen/java/io/swagger/model/DCAEServiceComponentRequest.java b/src/gen/java/io/swagger/model/DCAEServiceComponentRequest.java
index f65bf38..64d4127 100644
--- a/src/gen/java/io/swagger/model/DCAEServiceComponentRequest.java
+++ b/src/gen/java/io/swagger/model/DCAEServiceComponentRequest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -77,7 +77,7 @@ public class DCAEServiceComponentRequest {
@ApiModelProperty(value = "Specifies the name of the underying source service that is responsible for this components", required = true,
- allowableValues = "DCAEController, DMaaPController")
+ allowableValues = "DMaaPController")
@JsonProperty("componentSource")
public String getComponentSource() {
return componentSource;
diff --git a/src/main/java/io/swagger/api/Bootstrap.java b/src/main/java/io/swagger/api/Bootstrap.java
index 5050ed3..24f4583 100644
--- a/src/main/java/io/swagger/api/Bootstrap.java
+++ b/src/main/java/io/swagger/api/Bootstrap.java
@@ -26,7 +26,6 @@ import io.swagger.models.*;
import io.swagger.models.auth.*;
import javax.servlet.http.HttpServlet;
-import javax.servlet.ServletContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -38,12 +37,12 @@ public class Bootstrap extends HttpServlet {
.description("DCAE Inventory is a web service that provides the following:\n\n1. Real-time data on all DCAE services and their components\n2. Comprehensive details on available DCAE service types\n")
.termsOfService("")
.contact(new Contact()
- .email("dcae@lists.openecomp.org"))
+ .email("dcae@lists.onap.org"))
.license(new License()
.name("")
.url(""));
- ServletContext context = config.getServletContext();
+
Swagger swagger = new Swagger().info(info);
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
diff --git a/src/main/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactory.java b/src/main/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactory.java
index fecd8fe..61d7638 100644
--- a/src/main/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactory.java
+++ b/src/main/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactory.java
@@ -24,9 +24,13 @@ import io.swagger.api.DcaeServiceTypesApiService;
import io.swagger.api.impl.DcaeServiceTypesApiServiceImpl;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
-public class DcaeServiceTypesApiServiceFactory {
+public final class DcaeServiceTypesApiServiceFactory {
- private final static DcaeServiceTypesApiService service = new DcaeServiceTypesApiServiceImpl();
+ private static final DcaeServiceTypesApiService service = new DcaeServiceTypesApiServiceImpl();
+
+ //Utility classes, which are a collection of static members, are not meant to be instantiated.
+ private DcaeServiceTypesApiServiceFactory(){
+ }
public static DcaeServiceTypesApiService getDcaeServiceTypesApi()
{
diff --git a/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java b/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java
index 47f213d..ba27ada 100644
--- a/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java
+++ b/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -20,20 +20,18 @@
package io.swagger.api.factories;
-import org.openecomp.dcae.inventory.clients.DCAEControllerClient;
-import org.openecomp.dcae.inventory.clients.DatabusControllerClient;
+import org.onap.dcae.inventory.clients.DatabusControllerClient;
import io.swagger.api.DcaeServicesApiService;
import io.swagger.api.impl.DcaeServicesApiServiceImpl;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
-public class DcaeServicesApiServiceFactory {
+public final class DcaeServicesApiServiceFactory {
// Yes I agree this code is not great and I blame for Swagger for putting me in this spot.
- private static DCAEControllerClient dcaeControllerClient;
private static DatabusControllerClient databusControllerClient;
- public static void setDcaeControllerClient(DCAEControllerClient dcaeControllerClient) {
- DcaeServicesApiServiceFactory.dcaeControllerClient = dcaeControllerClient;
+ //Utility classes, which are a collection of static members, are not meant to be instantiated.
+ private DcaeServicesApiServiceFactory(){
}
public static void setDatabusControllerClient(DatabusControllerClient databusControllerClient) {
@@ -41,7 +39,7 @@ public class DcaeServicesApiServiceFactory {
}
public static DcaeServicesApiService getDcaeServicesApi() {
- return new DcaeServicesApiServiceImpl(dcaeControllerClient, databusControllerClient);
+ return new DcaeServicesApiServiceImpl(databusControllerClient);
}
}
diff --git a/src/main/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactory.java b/src/main/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactory.java
index 041fbaf..509ac2a 100644
--- a/src/main/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactory.java
+++ b/src/main/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactory.java
@@ -24,9 +24,13 @@ import io.swagger.api.DcaeServicesGroupbyApiService;
import io.swagger.api.impl.DcaeServicesGroupbyApiServiceImpl;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
-public class DcaeServicesGroupbyApiServiceFactory {
+public final class DcaeServicesGroupbyApiServiceFactory {
- private final static DcaeServicesGroupbyApiService service = new DcaeServicesGroupbyApiServiceImpl();
+ private static final DcaeServicesGroupbyApiService service = new DcaeServicesGroupbyApiServiceImpl();
+
+ //Utility classes, which are a collection of static members, are not meant to be instantiated.
+ private DcaeServicesGroupbyApiServiceFactory(){
+ }
public static DcaeServicesGroupbyApiService getDcaeServicesGroupbyApi()
{
diff --git a/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java
index 34d8a4b..0cb108c 100644
--- a/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java
+++ b/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java
@@ -20,12 +20,12 @@
package io.swagger.api.impl;
-import org.openecomp.dcae.inventory.daos.DCAEServiceTypesDAO;
-import org.openecomp.dcae.inventory.daos.DCAEServicesDAO;
-import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
-import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceTypeObjectMapper;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
+import org.onap.dcae.inventory.daos.DCAEServiceTypesDAO;
+import org.onap.dcae.inventory.daos.DCAEServicesDAO;
+import org.onap.dcae.inventory.daos.InventoryDAOManager;
+import org.onap.dcae.inventory.dbthings.mappers.DCAEServiceTypeObjectMapper;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
import io.swagger.api.*;
import io.swagger.model.*;
@@ -42,13 +42,13 @@ import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;
import java.util.ArrayList;
import java.util.List;
-import java.util.Locale;
import java.util.UUID;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
- private final static Logger LOG = LoggerFactory.getLogger(DcaeServiceTypesApiServiceImpl.class);
+ private static final Logger metricsLogger = LoggerFactory.getLogger("metricsLogger");
+ private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");
private static int PAGINATION_PAGE_SIZE = 25;
private DCAEServiceType createDCAEServiceType(DCAEServiceTypeObject serviceTypeObject, UriInfo uriInfo) {
@@ -93,7 +93,7 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
sb.append("dcae_service_types");
}
- List<String> whereClauses = new ArrayList<String>();
+ List<String> whereClauses = new ArrayList<>();
if (typeName != null) {
whereClauses.add(":typeName = type_name");
@@ -112,7 +112,7 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
}
if (asdcServiceId != null) {
- if ("NONE".equals(asdcServiceId.toUpperCase(Locale.ENGLISH))) {
+ if (asdcServiceId.equalsIgnoreCase("NONE")) {
whereClauses.add("asdc_service_id is null");
} else {
whereClauses.add(":asdcServiceId = asdc_service_id");
@@ -120,7 +120,7 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
}
if (asdcResourceId != null) {
- if ("NONE".equals(asdcResourceId.toUpperCase(Locale.ENGLISH))) {
+ if (asdcResourceId.equalsIgnoreCase("NONE")) {
whereClauses.add("asdc_resource_id is null");
} else {
whereClauses.add(":asdcResourceId = asdc_resource_id");
@@ -140,6 +140,8 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
// Sort by created timestamp - always descending.
sb.append(" order by created desc");
+
+ metricsLogger.info("Query created as: {}." + sb.toString());
Query<DCAEServiceTypeObject> query = jdbiHandle.createQuery(sb.toString()).map(new DCAEServiceTypeObjectMapper());
@@ -159,11 +161,11 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
query.bind("serviceLocation", serviceLocation);
}
- if (asdcServiceId != null && !"NONE".equals(asdcServiceId.toUpperCase(Locale.ENGLISH))) {
+ if (asdcServiceId != null && !"NONE".equalsIgnoreCase(asdcServiceId)) {
query.bind("asdcServiceId", asdcServiceId);
}
- if (asdcResourceId != null && !"NONE".equals(asdcResourceId.toUpperCase(Locale.ENGLISH))) {
+ if (asdcResourceId != null && !"NONE".equalsIgnoreCase(asdcResourceId)) {
query.bind("asdcResourceId", asdcResourceId);
}
@@ -209,6 +211,8 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
response.setLinks(navigationLinks);
+ debugLogger.debug("Response: {}." + response.toString());
+
return Response.ok().entity(response).build();
}
@@ -279,7 +283,7 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
DCAEServicesDAO servicesDAO = InventoryDAOManager.getInstance().getDCAEServicesDAO();
Integer count = servicesDAO.countByType(DCAEServiceObject.DCAEServiceStatus.RUNNING, typeId);
- LOG.info(String.format("Checked num DCAE services running: %s, %d", typeId, count));
+ metricsLogger.info(String.format("Checked num DCAE services running: %s, %d", typeId, count));
// Allow the updating of an existing DCAE service type IFF there are no running DCAE services for this type
diff --git a/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java
index d1e790c..7f08501 100644
--- a/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java
+++ b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -20,17 +20,15 @@
package io.swagger.api.impl;
-import org.openecomp.dcae.inventory.clients.DCAEControllerClient;
-import org.openecomp.dcae.inventory.clients.DatabusControllerClient;
-import org.openecomp.dcae.inventory.daos.DCAEServiceComponentsDAO;
-import org.openecomp.dcae.inventory.daos.DCAEServiceTransactionDAO;
-import org.openecomp.dcae.inventory.daos.DCAEServicesDAO;
-import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
-import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceObjectMapper;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
-import org.openecomp.dcae.inventory.exceptions.DCAEControllerClientException;
-import org.openecomp.dcae.inventory.exceptions.DatabusControllerClientException;
+import org.onap.dcae.inventory.clients.DatabusControllerClient;
+import org.onap.dcae.inventory.daos.DCAEServiceComponentsDAO;
+import org.onap.dcae.inventory.daos.DCAEServiceTransactionDAO;
+import org.onap.dcae.inventory.daos.DCAEServicesDAO;
+import org.onap.dcae.inventory.daos.InventoryDAOManager;
+import org.onap.dcae.inventory.dbthings.mappers.DCAEServiceObjectMapper;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.onap.dcae.inventory.exceptions.DatabusControllerClientException;
import io.swagger.api.*;
import io.swagger.model.*;
@@ -49,14 +47,17 @@ import java.util.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
- private final static Logger LOG = LoggerFactory.getLogger(DcaeServicesApiServiceImpl.class);
- private static int PAGINATION_PAGE_SIZE = 25;
- private static String COMPONENT_SOURCE_DCAE_CONTROLLER = "DCAECONTROLLER";
- private static String COMPONENT_SOURCE_DATA_BUS_CONTROLLER = "DMAAPCONTROLLER";
+ private static final Logger metricsLogger = LoggerFactory.getLogger("metricsLogger");
+ private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");
+ private static final int PAGINATION_PAGE_SIZE = 25;
+ private static final String COMPONENT_SOURCE_DATA_BUS_CONTROLLER = "DMAAPCONTROLLER";
- private final DCAEControllerClient dcaeControllerClient;
private final DatabusControllerClient databusControllerClient;
+ public DcaeServicesApiServiceImpl(DatabusControllerClient databusControllerClient) {
+ this.databusControllerClient = databusControllerClient;
+ }
+
private DCAEService createDCAEService(DCAEServiceObject serviceObject, Collection<DCAEServiceComponentObject> componentObjects,
UriInfo uriInfo) {
// TODO: Complete links: come back and do links for vnf
@@ -67,12 +68,11 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
service.setCreated(serviceObject.getCreated().toDate());
service.setModified(serviceObject.getModified().toDate());
service.setVnfId(serviceObject.getVnfId());
- //service.setVnfLink(vnfLink);
service.setVnfType(serviceObject.getVnfType());
service.setVnfLocation(serviceObject.getVnfLocation());
service.setDeploymentRef(serviceObject.getDeploymentRef());
- List<DCAEServiceComponent> serviceComponents = new ArrayList<DCAEServiceComponent>();
+ List<DCAEServiceComponent> serviceComponents = new ArrayList<>();
for (DCAEServiceComponentObject sco : componentObjects) {
DCAEServiceComponent component = new DCAEServiceComponent();
@@ -86,22 +86,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
// TODO: When putting together the components fail. Should this be a 500 case?
// For now, this is just logged as a warning.
- if (COMPONENT_SOURCE_DCAE_CONTROLLER.equals(sco.getComponentSource().toUpperCase(Locale.ENGLISH))) {
- if (this.dcaeControllerClient != null) {
- try {
- DCAEControllerClient.ServiceInstance serviceInstance
- = this.dcaeControllerClient.getServiceInstance(component.getComponentId());
- component.setStatus(serviceInstance.getStatus());
- // There's no specific location rather its inferred from the AIC tenant
- component.setLocation(this.dcaeControllerClient.getLocation(serviceInstance));
- Link componentLink = Link.fromUri(this.dcaeControllerClient.constructResourceURI(sco.getComponentId()))
- .rel("component").title(component.getComponentId()).build();
- component.setComponentLink(componentLink);
- } catch (DCAEControllerClientException e) {
- LOG.warn(String.format("%s, %s", e.getMessage(), sco.toString()));
- }
- }
- } else if (COMPONENT_SOURCE_DATA_BUS_CONTROLLER.equals(sco.getComponentSource().toUpperCase(Locale.ENGLISH))) {
+ if (COMPONENT_SOURCE_DATA_BUS_CONTROLLER.equalsIgnoreCase(sco.getComponentSource())) {
if (this.databusControllerClient != null) {
try {
if (this.databusControllerClient.isExists(sco.getComponentId())) {
@@ -109,14 +94,14 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
.rel("component").title(component.getComponentId()).build();
component.setComponentLink(componentLink);
} else {
- LOG.warn(String.format("Feed/topic does not exist: %s", sco.getComponentId()));
+ debugLogger.warn(String.format("Feed/topic does not exist: %s", sco.getComponentId()));
}
} catch (DatabusControllerClientException e) {
- LOG.warn(String.format("%s, %s", e.getMessage(), sco.toString()));
+ debugLogger.warn(String.format("%s, %s", e.getMessage(), sco.toString()), e);
}
}
} else {
- LOG.warn(String.format("Handling unknown component source: %s", sco.getComponentSource()));
+ debugLogger.warn(String.format("Handling unknown component source: %s", sco.getComponentSource()));
}
serviceComponents.add(component);
@@ -132,13 +117,13 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
String componentType, Boolean shareable, DateTime created, Integer offset,
UriInfo uriInfo, SecurityContext securityContext) {
List<DCAEServiceObject> serviceObjects = new ArrayList<>();
- DateTime createdCutoff = (created == null ? DateTime.now(DateTimeZone.UTC) : created);
+ DateTime createdCutoff = created == null ? DateTime.now(DateTimeZone.UTC) : created;
- LOG.info(String.format("Create time upper bound cutoff: %s", createdCutoff.toString()));
+ metricsLogger.info(String.format("Create time upper bound cutoff: %s", createdCutoff.toString()));
// Offset is zero-based index
offset = (offset == null) ? 0 : offset;
- LOG.info(String.format("Query offset: %d", offset));
+ metricsLogger.info(String.format("Query offset: %d", offset));
try (Handle jdbiHandle = InventoryDAOManager.getInstance().getHandle()) {
// WATCH! There is the use of "distinct" here.
@@ -146,7 +131,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
sb.append(" join dcae_services_components_maps m on ds.service_id = m.service_id ");
sb.append(" join dcae_service_components dsc on m.component_id = dsc.component_id");
- List<String> whereClauses = new ArrayList<String>();
+ List<String> whereClauses = new ArrayList<>();
if (typeId != null) {
whereClauses.add("ds.type_id = :typeId");
@@ -207,7 +192,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
if (shareable != null) {
// NOTE: That the shareable field in the database is actually an integer.
- query.bind("shareable", (shareable ? 1 : 0));
+ query.bind("shareable", shareable ? 1 : 0);
}
query.bind("createdCutoff", createdCutoff);
@@ -225,7 +210,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
List<DCAEServiceObject> serviceObjectsSliced = serviceObjects.subList(offset, endpoint);
DCAEServiceComponentsDAO componentsDAO = InventoryDAOManager.getInstance().getDCAEServiceComponentsDAO();
- List<DCAEService> services = new ArrayList<DCAEService>();
+ List<DCAEService> services = new ArrayList<>();
for (DCAEServiceObject so : serviceObjectsSliced) {
List<DCAEServiceComponentObject> components = componentsDAO.getByServiceId(so.getServiceId());
@@ -298,7 +283,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
// Watch! We have to query for services regardless of status because we need to account for "removed" instances
// that get resurrected.
final DCAEServiceObject serviceObjectFromStore = servicesDAO.getByServiceId(serviceId);
- final Map<String, DCAEServiceComponentObject> componentObjectsFromStore = new HashMap<String, DCAEServiceComponentObject>();
+ final Map<String, DCAEServiceComponentObject> componentObjectsFromStore = new HashMap<>();
for (DCAEServiceComponentObject componentObject : componentsDAO.getByServiceId(serviceId)) {
componentObjectsFromStore.put(componentObject.getComponentId(), componentObject);
@@ -318,7 +303,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
serviceObjectToSendBack.setModified(modified);
transactionContext.setServiceObjectToInsert(serviceObjectToSendBack);
} else {
- LOG.info(String.format("DCAEServiceObject already exists - updating: %s, %s",
+ metricsLogger.info(String.format("DCAEServiceObject already exists - updating: %s, %s",
serviceObjectFromStore.getCreated().toString(),
serviceObjectFromStore.getModified().toString()));
@@ -329,7 +314,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
// 2) Insert/update DCAEServiceComponentObjects. Components exist independent of the associated DCAE service.
- Map<String, DCAEServiceComponentObject> componentObjectsToSendBack = new HashMap<String, DCAEServiceComponentObject>();
+ Map<String, DCAEServiceComponentObject> componentObjectsToSendBack = new HashMap<>();
for (DCAEServiceComponentRequest requestComponent : request.getComponents()) {
// Have to query the database rather than checking the result of getting by service id because of the
@@ -380,6 +365,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
return Response.ok().entity(service).build();
}
+ @Override
public Response dcaeServicesServiceIdDelete(String serviceId, SecurityContext securityContext) throws NotFoundException {
DCAEServicesDAO servicesDAO = InventoryDAOManager.getInstance().getDCAEServicesDAO();
@@ -393,9 +379,4 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
return Response.ok().build();
}
- public DcaeServicesApiServiceImpl(DCAEControllerClient dcaeControllerClient, DatabusControllerClient databusControllerClient) {
- this.dcaeControllerClient = dcaeControllerClient;
- this.databusControllerClient = databusControllerClient;
- }
-
}
diff --git a/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java
index 09d3143..34fba7d 100644
--- a/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java
+++ b/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java
@@ -20,8 +20,8 @@
package io.swagger.api.impl;
-import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.onap.dcae.inventory.daos.InventoryDAOManager;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
import io.swagger.api.*;
import io.swagger.model.DCAEServiceGroupByResults;
import io.swagger.model.DCAEServiceGroupByResultsPropertyValues;
@@ -39,7 +39,7 @@ public class DcaeServicesGroupbyApiServiceImpl extends DcaeServicesGroupbyApiSer
@Override
public Response dcaeServicesGroupbyPropertyNameGet(String propertyName, UriInfo uriInfo, SecurityContext securityContext) {
- String columnName = "";
+ String columnName;
switch (propertyName) {
case "type":
diff --git a/src/main/java/org/openecomp/dcae/inventory/InventoryApplication.java b/src/main/java/org/onap/dcae/inventory/InventoryApplication.java
index 9e78506..259ce93 100644
--- a/src/main/java/org/openecomp/dcae/inventory/InventoryApplication.java
+++ b/src/main/java/org/onap/dcae/inventory/InventoryApplication.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -18,22 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory;
+package org.onap.dcae.inventory;
import com.fasterxml.jackson.databind.ObjectMapper;
-import io.dropwizard.cli.Cli;
import io.dropwizard.configuration.ConfigurationFactory;
import io.dropwizard.configuration.ConfigurationFactoryFactory;
import io.dropwizard.configuration.JsonConfigurationFactory;
import io.dropwizard.configuration.UrlConfigurationSourceProvider;
-import io.dropwizard.util.JarLocation;
-import org.openecomp.dcae.inventory.clients.DCAEControllerClient;
-import org.openecomp.dcae.inventory.clients.DatabusControllerClient;
-import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
-import org.openecomp.dcae.inventory.exceptions.mappers.DBIExceptionMapper;
-import org.openecomp.dcae.inventory.exceptions.mappers.DCAEControllerConnectionExceptionMapper;
-import org.openecomp.dcae.inventory.exceptions.mappers.DCAEControllerTimeoutExceptionMapper;
-import org.openecomp.dcae.inventory.providers.NotFoundExceptionMapper;
+import org.onap.dcae.inventory.clients.DatabusControllerClient;
+import org.onap.dcae.inventory.exceptions.mappers.DBIExceptionMapper;
+import org.onap.dcae.inventory.providers.NotFoundExceptionMapper;
+import org.onap.dcae.inventory.daos.InventoryDAOManager;
import com.fasterxml.jackson.databind.module.SimpleModule;
import io.dropwizard.Application;
import io.dropwizard.client.JerseyClientBuilder;
@@ -52,6 +47,8 @@ import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.util.ContextInitializer;
import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
@@ -67,10 +64,12 @@ import java.util.Locale;
*/
public class InventoryApplication extends Application<InventoryConfiguration> {
- static final Logger LOG = LoggerFactory.getLogger(InventoryApplication.class);
+ static final Logger metricsLogger = LoggerFactory.getLogger("metricsLogger");
+ static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");
static boolean shouldRemoteFetchConfig = false;
public static void main(String[] args) throws Exception {
+ metricsLogger.info("DCAE inventory application main Startup");
// This is here to try to fix a "high" issue caught by Fortify. Did this **plus** setting locale for each of the
// string comparisons that use `toUpper` because of this StackOverflow post:
// http://stackoverflow.com/questions/38308777/fixed-fortify-scan-locale-changes-are-reappearing
@@ -90,6 +89,15 @@ public class InventoryApplication extends Application<InventoryConfiguration> {
// You are here because you want to use the default way of configuring inventory - YAML file.
new InventoryApplication().run(args);
}
+ // revert to using logback.xml:
+ LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
+ context.reset();
+ ContextInitializer initializer = new ContextInitializer(context);
+ initializer.autoConfig();
+
+ metricsLogger.info("Starting DCAE inventory application...");
+ debugLogger.debug(String.format("Starting DCAE inventory application... args[0]: %s", args[0]));
+
}
@Override
@@ -108,9 +116,9 @@ public class InventoryApplication extends Application<InventoryConfiguration> {
public void initialize(Bootstrap<InventoryConfiguration> bootstrap) {
// This Info object was lifted from the Swagger generated io.swagger.api.Bootstrap file. Although it was not generated
// correctly.
- Info info = new Info().title("DCAE Inventory API").version("0.8.0")
+ Info info = new Info().title("DCAE Inventory API").version("0.8.1")
.description("DCAE Inventory is a web service that provides the following:\n\n1. Real-time data on all DCAE services and their components\n2. Comprehensive details on available DCAE service types\n")
- .contact(new Contact().email("dcae@lists.openecomp.org"));
+ .contact(new Contact().email("dcae@lists.onap.org"));
// Swagger/servlet/jax-rs magic!
BeanConfig beanConfig = new BeanConfig();
beanConfig.setInfo(info);
@@ -126,8 +134,8 @@ public class InventoryApplication extends Application<InventoryConfiguration> {
@Override
public void run(InventoryConfiguration configuration, Environment environment) {
- LOG.info("Starting DCAE inventory application");
- LOG.info(String.format("DB driver properties: %s", configuration.getDataSourceFactory().getProperties().toString()));
+ debugLogger.info("Starting DCAE inventory application");
+ debugLogger.info(String.format("DB driver properties: %s", configuration.getDataSourceFactory().getProperties().toString()));
InventoryDAOManager.getInstance().setup(environment, configuration);
InventoryDAOManager.getInstance().initialize();
@@ -146,21 +154,6 @@ public class InventoryApplication extends Application<InventoryConfiguration> {
simpleModule.addSerializer(Link.class, new LinkSerializer());
environment.getObjectMapper().registerModule(simpleModule);
- // Setup DCAE controller client
- // Used by the dcae-services API
- if (configuration.getDcaeControllerConnection().getRequired()) {
- final Client clientDCAEController = new JerseyClientBuilder(environment).using(configuration.getJerseyClientConfiguration())
- .build("DCAEControllerClient");
- HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder().build();
- clientDCAEController.register(feature);
- final DCAEControllerClient dcaeControllerClient = new DCAEControllerClient(clientDCAEController, configuration.getDcaeControllerConnection());
- DcaeServicesApiServiceFactory.setDcaeControllerClient(dcaeControllerClient);
-
- LOG.info("Use of DCAE controller client is required. Turned on.");
- } else {
- LOG.warn("Use of DCAE controller client is *not* required. Turned off.");
- }
-
// Setup Databus controller client
// Used by the dcae-services API
if (configuration.getDatabusControllerConnection().getRequired()) {
@@ -172,15 +165,12 @@ public class InventoryApplication extends Application<InventoryConfiguration> {
final DatabusControllerClient databusControllerClient = new DatabusControllerClient(clientDatabusController,
configuration.getDatabusControllerConnection());
DcaeServicesApiServiceFactory.setDatabusControllerClient(databusControllerClient);
-
- LOG.info("Use of databus controller client is required. Turned on.");
+ debugLogger.info("Use of DCAE controller client is required. Turned on.");
} else {
- LOG.warn("Use of databus controller client is *not* required. Turned off.");
+ debugLogger.warn("Use of DCAE controller client is *not* required. Turned off.");
}
environment.jersey().register(NotFoundExceptionMapper.class);
- environment.jersey().register(DCAEControllerConnectionExceptionMapper.class);
- environment.jersey().register(DCAEControllerTimeoutExceptionMapper.class);
environment.jersey().register(DBIExceptionMapper.UnableToObtainConnectionExceptionMapper.class);
environment.jersey().register(DBIExceptionMapper.UnableToExecuteStatementExceptionMapper.class);
environment.jersey().register(DBIExceptionMapper.UnableToCreateStatementExceptionMapper.class);
diff --git a/src/main/java/org/openecomp/dcae/inventory/InventoryConfiguration.java b/src/main/java/org/onap/dcae/inventory/InventoryConfiguration.java
index 55bcca2..76a525a 100644
--- a/src/main/java/org/openecomp/dcae/inventory/InventoryConfiguration.java
+++ b/src/main/java/org/onap/dcae/inventory/InventoryConfiguration.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory;
+package org.onap.dcae.inventory;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
@@ -34,55 +34,6 @@ import javax.validation.constraints.NotNull;
*/
public class InventoryConfiguration extends Configuration {
- public static class DCAEControllerConnectionConfiguration {
- @NotEmpty
- @JsonProperty
- private String host;
-
- @NotNull
- @JsonProperty
- private Integer port;
-
- @NotEmpty
- @JsonProperty
- private String basePath;
-
- @NotEmpty
- @JsonProperty
- private String user;
-
- @NotEmpty
- @JsonProperty
- private String password;
-
- @JsonProperty
- private Boolean required = true;
-
- public String getHost() {
- return this.host;
- }
-
- public Integer getPort() {
- return this.port;
- }
-
- public String getBasePath() {
- return this.basePath;
- }
-
- public String getUser() {
- return this.user;
- }
-
- public String getPassword() {
- return this.password;
- }
-
- public Boolean getRequired() {
- return this.required;
- }
- }
-
public static class DatabusControllerConnectionConfiguration {
@NotEmpty
@JsonProperty
@@ -134,10 +85,6 @@ public class InventoryConfiguration extends Configuration {
@NotNull
@JsonProperty
- private DCAEControllerConnectionConfiguration dcaeControllerConnection = new DCAEControllerConnectionConfiguration();
-
- @NotNull
- @JsonProperty
private DatabusControllerConnectionConfiguration databusControllerConnection = new DatabusControllerConnectionConfiguration();
@NotNull
@@ -158,10 +105,6 @@ public class InventoryConfiguration extends Configuration {
return this.database;
}
- public DCAEControllerConnectionConfiguration getDcaeControllerConnection() {
- return this.dcaeControllerConnection;
- }
-
public DatabusControllerConnectionConfiguration getDatabusControllerConnection() {
return databusControllerConnection;
}
diff --git a/src/main/java/org/openecomp/dcae/inventory/LinkSerializer.java b/src/main/java/org/onap/dcae/inventory/LinkSerializer.java
index b83697f..c7abc99 100644
--- a/src/main/java/org/openecomp/dcae/inventory/LinkSerializer.java
+++ b/src/main/java/org/onap/dcae/inventory/LinkSerializer.java
@@ -18,10 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory;
+package org.onap.dcae.inventory;
import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
diff --git a/src/main/java/org/openecomp/dcae/inventory/clients/DatabusControllerClient.java b/src/main/java/org/onap/dcae/inventory/clients/DatabusControllerClient.java
index 9df11d5..b2429d9 100644
--- a/src/main/java/org/openecomp/dcae/inventory/clients/DatabusControllerClient.java
+++ b/src/main/java/org/onap/dcae/inventory/clients/DatabusControllerClient.java
@@ -18,10 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.clients;
+package org.onap.dcae.inventory.clients;
-import org.openecomp.dcae.inventory.InventoryConfiguration;
-import org.openecomp.dcae.inventory.exceptions.DatabusControllerClientException;
+import org.onap.dcae.inventory.InventoryConfiguration;
+import org.onap.dcae.inventory.exceptions.DatabusControllerClientException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -48,7 +48,7 @@ public class DatabusControllerClient {
resourcePath = (new StringBuilder("/")).append(resourcePath).toString();
}
- return UriBuilder.fromPath(resourcePath.toString()).scheme("https").host(this.connectionConfiguration.getHost())
+ return UriBuilder.fromPath(resourcePath).scheme("https").host(this.connectionConfiguration.getHost())
.port(this.connectionConfiguration.getPort()).build();
}
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceComponentsDAO.java b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceComponentsDAO.java
index 9a674c9..dff68df 100644
--- a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceComponentsDAO.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceComponentsDAO.java
@@ -18,10 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.daos;
+package org.onap.dcae.inventory.daos;
-import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceComponentObjectMapper;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
+import org.onap.dcae.inventory.dbthings.mappers.DCAEServiceComponentObjectMapper;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.BindBean;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
@@ -35,9 +35,11 @@ import java.util.List;
*/
public interface DCAEServiceComponentsDAO extends InventoryDAO {
+ @Override
@SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_service_components\')")
Boolean checkIfTableExists();
+ @Override
@SqlUpdate("create table dcae_service_components (component_id varchar not null primary key, component_type varchar not null, " +
"component_source varchar not null, shareable integer default 0, created timestamp not null, modified timestamp not null)")
void createTable();
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTransactionDAO.java
index c9d6dc8..a4571cd 100644
--- a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTransactionDAO.java
@@ -1,4 +1,5 @@
/*-
+
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
@@ -18,10 +19,10 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.daos;
+package org.onap.dcae.inventory.daos;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
import org.joda.time.DateTime;
import org.skife.jdbi.v2.sqlobject.CreateSqlObject;
import org.skife.jdbi.v2.sqlobject.Transaction;
@@ -120,13 +121,13 @@ public abstract class DCAEServiceTransactionDAO {
}
@CreateSqlObject
- abstract public DCAEServicesDAO getServicesDAO();
+ public abstract DCAEServicesDAO getServicesDAO();
@CreateSqlObject
- abstract public DCAEServicesComponentsMapsDAO getServicesComponentsMappingDAO();
+ public abstract DCAEServicesComponentsMapsDAO getServicesComponentsMappingDAO();
@CreateSqlObject
- abstract public DCAEServiceComponentsDAO getComponentsDAO();
+ public abstract DCAEServiceComponentsDAO getComponentsDAO();
@Transaction
public void insert(DCAEServiceTransactionContext context) {
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTypesDAO.java b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java
index 50b79b2..aa242a4 100644
--- a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTypesDAO.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.daos;
+package org.onap.dcae.inventory.daos;
-import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceTypeObjectMapper;
+import org.onap.dcae.inventory.dbthings.mappers.DCAEServiceTypeObjectMapper;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
import io.swagger.model.DCAEServiceTypeRequest;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.BindBean;
@@ -40,6 +40,7 @@ import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
public interface DCAEServiceTypesDAO extends InventoryDAO {
@SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_service_types\')")
+ @Override
Boolean checkIfTableExists();
/**
@@ -51,6 +52,7 @@ public interface DCAEServiceTypesDAO extends InventoryDAO {
"vnf_types varchar[] not null, service_ids varchar[], service_locations varchar[], " +
"asdc_service_id varchar, asdc_resource_id varchar, " +
"created timestamp not null, deactivated timestamp, constraint pk_type_created primary key (type_id))")
+ @Override
void createTable();
// REVIEW: asdcServiceId and asdcResourceId is implicitly part of the unique key and thus shouldn't be updated.
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java b/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java
index 5bfd3cd..270d638 100644
--- a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.daos;
+package org.onap.dcae.inventory.daos;
import org.joda.time.DateTime;
import org.skife.jdbi.v2.sqlobject.Bind;
@@ -34,8 +34,10 @@ import org.skife.jdbi.v2.sqlobject.SqlUpdate;
public interface DCAEServicesComponentsMapsDAO extends InventoryDAO {
@SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_services_components_maps\')")
+ @Override
Boolean checkIfTableExists();
+ @Override
@SqlUpdate("create table dcae_services_components_maps (service_id varchar not null references dcae_services (service_id), " +
"component_id varchar not null references dcae_service_components (component_id), " +
"created timestamp not null, primary key (service_id, component_id))")
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesDAO.java b/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesDAO.java
index 9200677..0595a9a 100644
--- a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesDAO.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesDAO.java
@@ -18,10 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.daos;
+package org.onap.dcae.inventory.daos;
-import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceObjectMapper;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.onap.dcae.inventory.dbthings.mappers.DCAEServiceObjectMapper;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
import org.joda.time.DateTime;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.BindBean;
@@ -36,12 +36,14 @@ import org.skife.jdbi.v2.util.IntegerMapper;
*/
public interface DCAEServicesDAO extends InventoryDAO {
+ @Override
@SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_services\')")
Boolean checkIfTableExists();
@SqlUpdate("create table dcae_services (service_id varchar not null primary key, type_id varchar not null, " +
"vnf_id varchar not null, vnf_type varchar not null, vnf_location varchar not null, deployment_ref varchar, " +
- "created timestamp not null, modified timestamp not null, status varchar not null)")
+ "created timestamp not null, modified timestamp not null, status varchar not null)")
+ @Override
void createTable();
@SqlUpdate("insert into dcae_services(service_id, type_id, vnf_id, vnf_type, vnf_location, deployment_ref, " +
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAO.java b/src/main/java/org/onap/dcae/inventory/daos/InventoryDAO.java
index ef2fb8d..a369cb1 100644
--- a/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAO.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/InventoryDAO.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.daos;
+package org.onap.dcae.inventory.daos;
/**
* Created by mhwang on 4/19/16.
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAOManager.java b/src/main/java/org/onap/dcae/inventory/daos/InventoryDAOManager.java
index 77611b5..af1b3e9 100644
--- a/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAOManager.java
+++ b/src/main/java/org/onap/dcae/inventory/daos/InventoryDAOManager.java
@@ -18,10 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.daos;
+package org.onap.dcae.inventory.daos;
-import org.openecomp.dcae.inventory.InventoryConfiguration;
-import org.openecomp.dcae.inventory.dbthings.StringListArgument;
+import org.onap.dcae.inventory.InventoryConfiguration;
+import org.onap.dcae.inventory.dbthings.StringListArgument;
import io.dropwizard.jdbi.DBIFactory;
import io.dropwizard.setup.Environment;
import org.skife.jdbi.v2.DBI;
@@ -60,9 +60,9 @@ public final class InventoryDAOManager {
}
- private final static Logger LOG = LoggerFactory.getLogger(InventoryDAOManager.class);
+ private final static Logger debugLogger = LoggerFactory.getLogger("debugLogger");
// WATCH! Table creation order matters where mapping tables refer to other tables for foreign keys.
- private final static List<Class> DAO_CLASSES = Arrays.asList(DCAEServiceTypesDAO.class, DCAEServicesDAO.class,
+ private static final List<Class> DAO_CLASSES = Arrays.asList(DCAEServiceTypesDAO.class, DCAEServicesDAO.class,
DCAEServiceComponentsDAO.class, DCAEServicesComponentsMapsDAO.class);
private DBI jdbi;
@@ -98,29 +98,29 @@ public final class InventoryDAOManager {
*/
public void initialize() {
final DBIFactory factory = new DBIFactory();
- final DBI jdbi = factory.build(this.environment, this.configuration.getDataSourceFactory(), "dcae-database");
- jdbi.registerArgumentFactory(new StringListArgument());
+ final DBI jdbi_local = factory.build(this.environment, this.configuration.getDataSourceFactory(), "dcae-database");
+ jdbi_local.registerArgumentFactory(new StringListArgument());
for (Class<? extends InventoryDAO> daoClass : DAO_CLASSES) {
- final InventoryDAO dao = jdbi.onDemand(daoClass);
+ final InventoryDAO dao = jdbi_local.onDemand(daoClass);
if (dao.checkIfTableExists()) {
- LOG.info(String.format("Sql table exists: %s", daoClass.getSimpleName()));
+ debugLogger.info(String.format("Sql table exists: %s", daoClass.getSimpleName()));
} else {
dao.createTable();
- LOG.info(String.format("Sql table created: %s", daoClass.getSimpleName()));
+ debugLogger.info(String.format("Sql table created: %s", daoClass.getSimpleName()));
}
}
// CREATE VIEWS
// TODO: This doesn't belong here and is not consistent with the above approach. Make it better.
- try (Handle jdbiHandle = jdbi.open()) {
+ try (Handle jdbiHandle = jdbi_local.open()) {
String viewName = "dcae_service_types_latest";
String checkQuery = String.format("select exists (select * from information_schema.tables where table_name = '%s')",
viewName);
if (jdbiHandle.createQuery(checkQuery).map(BooleanMapper.FIRST).first()) {
- LOG.info(String.format("Sql view exists: %s", viewName));
+ debugLogger.info(String.format("Sql view exists: %s", viewName));
} else {
StringBuilder sb = new StringBuilder(String.format("create view %s as ", viewName));
sb.append("select s.* from dcae_service_types s ");
@@ -128,19 +128,19 @@ public final class InventoryDAOManager {
sb.append("on s.type_name = f.type_name and s.type_version = f.max_version");
jdbiHandle.execute(sb.toString());
- LOG.info(String.format("Sql view created: %s", viewName));
+ debugLogger.info(String.format("Sql view created: %s", viewName));
}
} catch (Exception e) {
- throw new RuntimeException("", e);
+ throw new InventoryDAOManagerSetupException("view does not exist, " + e);
}
// Do this assignment at the end after performing table checks to ensure that connection is good
- this.jdbi = jdbi;
+ this.jdbi = jdbi_local;
}
private InventoryDAO getDAO(Class<? extends InventoryDAO> klass) {
if (jdbi == null) {
- throw new RuntimeException("InventoryDAOManager has not been initialized!");
+ throw new InventoryDAOManagerSetupException("InventoryDAOManager has not been initialized!");
}
// Using this approach to constructing the DAO, the client is not responsible for closing the handle.
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/StringListArgument.java b/src/main/java/org/onap/dcae/inventory/dbthings/StringListArgument.java
index afd0e78..4482139 100644
--- a/src/main/java/org/openecomp/dcae/inventory/dbthings/StringListArgument.java
+++ b/src/main/java/org/onap/dcae/inventory/dbthings/StringListArgument.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings;
+package org.onap.dcae.inventory.dbthings;
import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.Argument;
@@ -26,7 +26,6 @@ import org.skife.jdbi.v2.tweak.ArgumentFactory;
import java.sql.Array;
import java.sql.PreparedStatement;
-import java.sql.SQLException;
import java.util.List;
/**
@@ -44,14 +43,12 @@ public class StringListArgument implements ArgumentFactory<List<String>> {
}
@Override
- public Argument build(Class<?> expectedType, List<String> value, StatementContext statementContext) {
- return new Argument() {
- @Override
- public void apply(int position, PreparedStatement statement, StatementContext ctx) throws SQLException {
- Array values = statement.getConnection().createArrayOf("varchar", value.toArray());
- statement.setArray(position, values);
- }
- };
- }
+ public Argument build(Class<?> expectedType, List<String> value, StatementContext statementContext) {
+ return (int position, PreparedStatement statement, StatementContext ctx) -> {
+ Array values = statement.getConnection().createArrayOf("varchar", value.toArray());
+ statement.setArray(position, values);
+ };
+
+ }
}
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java b/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java
index 23b42b1..f214839 100644
--- a/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java
+++ b/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.mappers;
+package org.onap.dcae.inventory.dbthings.mappers;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
import org.joda.time.DateTime;
import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java b/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java
index 27cb22f..f60be7b 100644
--- a/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java
+++ b/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.mappers;
+package org.onap.dcae.inventory.dbthings.mappers;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
import org.joda.time.DateTime;
import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java b/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java
index dc64423..bda4423 100644
--- a/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java
+++ b/src/main/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.mappers;
+package org.onap.dcae.inventory.dbthings.mappers;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
import org.joda.time.DateTime;
import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java
index 0ec9c19..b262fc0 100644
--- a/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java
+++ b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.models;
+package org.onap.dcae.inventory.dbthings.models;
import io.swagger.model.DCAEServiceComponentRequest;
import org.joda.time.DateTime;
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObject.java b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObject.java
index 4374acd..232c18a 100644
--- a/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObject.java
+++ b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObject.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.models;
+package org.onap.dcae.inventory.dbthings.models;
import io.swagger.model.DCAEServiceRequest;
import org.joda.time.DateTime;
@@ -29,7 +29,7 @@ import org.joda.time.DateTimeZone;
*/
public class DCAEServiceObject {
- public static enum DCAEServiceStatus {
+ public enum DCAEServiceStatus {
RUNNING,
REMOVED
}
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java
index b57a28f..f264c99 100644
--- a/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java
+++ b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.models;
+package org.onap.dcae.inventory.dbthings.models;
import org.joda.time.DateTime;
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/DatabusControllerClientException.java b/src/main/java/org/onap/dcae/inventory/exceptions/DatabusControllerClientException.java
index 6209521..14855a8 100644
--- a/src/main/java/org/openecomp/dcae/inventory/exceptions/DatabusControllerClientException.java
+++ b/src/main/java/org/onap/dcae/inventory/exceptions/DatabusControllerClientException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.exceptions;
+package org.onap.dcae.inventory.exceptions;
/**
* Created by mhwang on 5/25/16.
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java b/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java
index 5dce2dd..3292d60 100644
--- a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java
+++ b/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.exceptions.mappers;
+package org.onap.dcae.inventory.exceptions.mappers;
-import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
+import org.onap.dcae.inventory.daos.InventoryDAOManager;
import io.swagger.api.ApiResponseMessage;
import org.skife.jdbi.v2.exceptions.DBIException;
import org.skife.jdbi.v2.exceptions.UnableToCreateStatementException;
@@ -42,7 +42,7 @@ import javax.ws.rs.ext.ExceptionMapper;
*/
public class DBIExceptionMapper<T extends DBIException> implements ExceptionMapper<T> {
- private final static Logger LOG = LoggerFactory.getLogger(DBIExceptionMapper.class);
+ private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");
/**
* Upon a DBIException, this handler will attempt to re-initialize the Inventory's database connection
@@ -53,14 +53,14 @@ public class DBIExceptionMapper<T extends DBIException> implements ExceptionMapp
*/
@Override
public Response toResponse(T exception) {
- LOG.error("", exception);
+ errorLogger.error("", exception);
StringBuilder clientMessage = new StringBuilder("There is a database issue.");
try {
InventoryDAOManager.getInstance().initialize();
clientMessage.append(" Connection has been successfully reset. Please try again.");
} catch(Exception e) {
- LOG.error(String.format("Failed to re-initialize database connection: %s", e.getMessage()));
+ errorLogger.error(String.format("Failed to re-initialize database connection: %s", e));
clientMessage.append(" Connection reset attempt has failed. Please try again soon.");
}
@@ -70,13 +70,13 @@ public class DBIExceptionMapper<T extends DBIException> implements ExceptionMapp
// Here are the handlers for specific derived DBIException
- public final static class UnableToObtainConnectionExceptionMapper extends DBIExceptionMapper<UnableToObtainConnectionException> {
+ public static final class UnableToObtainConnectionExceptionMapper extends DBIExceptionMapper<UnableToObtainConnectionException> {
}
- public final static class UnableToCreateStatementExceptionMapper extends DBIExceptionMapper<UnableToCreateStatementException> {
+ public static final class UnableToCreateStatementExceptionMapper extends DBIExceptionMapper<UnableToCreateStatementException> {
}
- public final static class UnableToExecuteStatementExceptionMapper extends DBIExceptionMapper<UnableToExecuteStatementException> {
+ public static final class UnableToExecuteStatementExceptionMapper extends DBIExceptionMapper<UnableToExecuteStatementException> {
}
}
diff --git a/src/main/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapper.java b/src/main/java/org/onap/dcae/inventory/providers/NotFoundExceptionMapper.java
index 0f54b46..7967470 100644
--- a/src/main/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapper.java
+++ b/src/main/java/org/onap/dcae/inventory/providers/NotFoundExceptionMapper.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.providers;
+package org.onap.dcae.inventory.providers;
import io.swagger.api.ApiResponseMessage;
import io.swagger.api.NotFoundException;
diff --git a/src/main/java/org/openecomp/dcae/inventory/clients/DCAEControllerClient.java b/src/main/java/org/openecomp/dcae/inventory/clients/DCAEControllerClient.java
deleted file mode 100644
index adbe8b7..0000000
--- a/src/main/java/org/openecomp/dcae/inventory/clients/DCAEControllerClient.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * dcae-inventory
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.dcae.inventory.clients;
-
-import org.openecomp.dcae.inventory.InventoryConfiguration;
-import org.openecomp.dcae.inventory.exceptions.DCAEControllerClientException;
-import org.openecomp.dcae.inventory.exceptions.DCAEControllerConnectionException;
-import org.openecomp.dcae.inventory.exceptions.DCAEControllerTimeoutException;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-
-import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.*;
-
-/**
- * Created by mhwang on 5/12/16.
- */
-public class DCAEControllerClient {
-
- /**
- * Used for JSON objects of the form:
- * "hostService": {"$ref": "/services/vm-docker-host-2/instances/mtl2"}
- */
- public static class Reference {
-
- @JsonProperty("$ref")
- private String ref;
-
- public String getRef() {
- return ref;
- }
-
- public void setRef(String ref) {
- this.ref = ref;
- }
-
- }
-
- /**
- * Used for the JSON objects returned from /services/{service id}/instances/{instance id}
- * calls.
- */
- @JsonIgnoreProperties(ignoreUnknown = true)
- public static class ServiceInstance {
-
- @JsonProperty("status")
- private String status;
-
- /**
- * Property points to the Docker host this Docker container runs on.
- * This service instance is an application to be run as a Docker container if this value is not null.
- */
- @JsonProperty("hostService")
- @JsonInclude(JsonInclude.Include.NON_ABSENT)
- private Reference hostService;
-
- /**
- * Property points to the CDAP cluster this CDAP application is deployed on.
- * This service instance is a CDAP application if this value is not null.
- */
- @JsonProperty("clusterService")
- @JsonInclude(JsonInclude.Include.NON_ABSENT)
- private Reference clusterService;
-
- /**
- * Property points to the location resource that this instance is associated with.
- * This property is not null when the service instance is a "pure" VM.
- */
- @JsonProperty("location")
- @JsonInclude(JsonInclude.Include.NON_ABSENT)
- private Reference location;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public Reference getHostService() {
- return hostService;
- }
-
- public void setHostService(Reference hostService) {
- this.hostService = hostService;
- }
-
- public Reference getClusterService() {
- return clusterService;
- }
-
- public void setClusterService(Reference clusterService) {
- this.clusterService = clusterService;
- }
-
- public Reference getLocation() {
- return location;
- }
-
- public void setLocation(Reference location) {
- this.location = location;
- }
-
- }
-
- private final static Logger LOG = LoggerFactory.getLogger(DCAEControllerClient.class);
-
- private final Client client;
- private final InventoryConfiguration.DCAEControllerConnectionConfiguration connectionConfiguration;
-
- public URI constructResourceURI(String resourcePath) {
- // TODO: Better way to construct this?
-
- // Make sure that the resource path has a "/" because the UriBuilder sucks and doesn't do it for us.
- if (resourcePath.charAt(0) != '/') {
- resourcePath = (new StringBuilder("/")).append(resourcePath).toString();
- }
-
- StringBuilder actualPath = new StringBuilder("/");
- actualPath.append(this.connectionConfiguration.getBasePath());
- actualPath.append(resourcePath);
-
- return UriBuilder.fromPath(actualPath.toString()).scheme("http").host(this.connectionConfiguration.getHost())
- .port(this.connectionConfiguration.getPort()).build();
- }
-
- public ServiceInstance getServiceInstance(String componentId) throws DCAEControllerClientException {
- URI uri = constructResourceURI(componentId);
- Response response = null;
-
- try {
- response = client.target(uri).request(MediaType.APPLICATION_JSON_TYPE)
- .header("Content-Type", "application/json")
- .property(HTTP_AUTHENTICATION_BASIC_USERNAME, connectionConfiguration.getUser())
- .property(HTTP_AUTHENTICATION_BASIC_PASSWORD, connectionConfiguration.getPassword()).get();
- } catch (ProcessingException e) {
- // Apparently the exceptions are wrapped which is not ideal because many different types of errors are embedded
- // in single exception. TODO: May want to come back to split up the errors.
- // Example:
- // javax.ws.rs.ProcessingException: org.apache.http.conn.ConnectTimeoutException: Connect to <dcae controller domain name>:9998
- String message = "Connecting with DCAE controller probably timed out";
- LOG.error(message, e);
- String exceptionMessage = String.format("%s: %s", message, e.getMessage());
- throw new DCAEControllerTimeoutException(exceptionMessage);
- } catch (Exception e) {
- String message = "Unexpected connection issue with DCAE controller";
- LOG.error(message, e);
- String exceptionMessage = String.format("%s: %s", message, e.getMessage());
- throw new DCAEControllerConnectionException(exceptionMessage);
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(String.format("Received response from DCAE controller: %d", response.getStatus()));
- }
-
- if (response.getStatus() == 200) {
- ObjectMapper om = new ObjectMapper();
-
- try {
- return om.readValue((InputStream) response.getEntity(), ServiceInstance.class);
- } catch (IOException e) {
- throw new DCAEControllerClientException(e);
- }
- }
-
- throw new DCAEControllerClientException(String.format("Unexpected error from DCAE controller: %d", response.getStatus()));
- }
-
- public String getLocation(ServiceInstance serviceInstance) {
- if (serviceInstance.getLocation() != null) {
- return serviceInstance.getLocation().getRef();
- } else if (serviceInstance.getClusterService() != null) {
- // Drill down: Location is on the underlying CDAP cluster service instance
- String cdapClusterRef = serviceInstance.getClusterService().getRef();
- return getLocation(getServiceInstance(cdapClusterRef));
- } else if (serviceInstance.getHostService() != null) {
- // Drill down: Location is on the underlying Docker host service instance
- String dockerHostRef = serviceInstance.getHostService().getRef();
- return getLocation(getServiceInstance(dockerHostRef));
- } else {
- throw new DCAEControllerClientException("No valid location for service instance");
- }
- }
-
- public DCAEControllerClient(Client client,
- InventoryConfiguration.DCAEControllerConnectionConfiguration connectionConfiguration) {
- this.client = client;
- this.connectionConfiguration = connectionConfiguration;
- }
-
-}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java
deleted file mode 100644
index 76936e0..0000000
--- a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * dcae-inventory
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.dcae.inventory.exceptions.mappers;
-
-import org.openecomp.dcae.inventory.exceptions.DCAEControllerConnectionException;
-
-import javax.ws.rs.core.Response;
-
-/**
- * Created by mhwang on 8/23/16.
- */
-public class DCAEControllerConnectionExceptionMapper extends DCAEControllerExceptionMapper<DCAEControllerConnectionException> {
-
- @Override
- protected Response.Status getStatus() {
- return Response.Status.BAD_GATEWAY;
- }
-
-}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java
deleted file mode 100644
index b9ffda0..0000000
--- a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * dcae-inventory
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.dcae.inventory.exceptions.mappers;
-
-import io.swagger.api.ApiResponseMessage;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-
-/**
- * Created by mhwang on 8/23/16.
- */
-public abstract class DCAEControllerExceptionMapper<T extends RuntimeException> implements ExceptionMapper<T> {
-
- abstract protected Response.Status getStatus();
-
- @Override
- public Response toResponse(T e) {
- ApiResponseMessage response = new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage());
- return Response.status(this.getStatus()).entity(response).build();
- }
-
-}
diff --git a/src/main/resources/config.json b/src/main/resources/config.json
index 436a181..89d887a 100644
--- a/src/main/resources/config.json
+++ b/src/main/resources/config.json
@@ -16,14 +16,6 @@
"evictionInterval": "10s",
"minIdleTime": "1 minute"
},
- "dcaeControllerConnection": {
- "host": "dcae-controller-hostname",
- "port": 9998,
- "basePath": "resources",
- "user": null,
- "password": null,
- "required": false
- },
"databusControllerConnection": {
"host": "databus-controller-hostname",
"port": 8443,
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 505eea5..e882be0 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -40,14 +40,6 @@ database:
# the minimum amount of time an connection must sit idle in the pool before it is eligible for eviction
minIdleTime: 1 minute
-dcaeControllerConnection:
- host: dcae-controller-hostname
- port: 9998
- # Apparently this is variable parameter amongst DCAE controller instances
- basePath: resources
- user:
- password:
-
databusControllerConnection:
host: databus-controller-hostname
port: 8443
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index aa16762..0c63c48 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -19,16 +19,78 @@
============LICENSE_END=========================================================
-->
-<configuration>
+<configuration scan="true" scanPeriod="30 seconds">
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
+
+ <property name="LOG_DIR" value="/opt/logs" />
+
+ <appender name="metricsAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${LOG_DIR}/metrics.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <!-- rollover daily -->
+ <fileNamePattern>${LOG_DIR}/metrics-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
+ <!-- each file should be at most 100MB, keep 2 days worth of history, but at most 200MB -->
+ <maxFileSize>100MB</maxFileSize>
+ <maxHistory>2</maxHistory>
+ <totalSizeCap>200MB</totalSizeCap>
+ </rollingPolicy>
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00}|%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00}|NULL|UNKNOWN|%thread||inventory||||COMPLETE|0|OK||%-5level||||||||||||||%class{36}:%M:%L: %m%n</pattern>
+ </layout>
+ </appender>
+
+ <appender name="debugAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${LOG_DIR}/debug.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <!-- rollover daily -->
+ <fileNamePattern>${LOG_DIR}/debug-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
+ <!-- each file should be at most 100MB, keep 2 days worth of history, but at most 200MB -->
+ <maxFileSize>100MB</maxFileSize>
+ <maxHistory>2</maxHistory>
+ <totalSizeCap>200MB</totalSizeCap>
+ </rollingPolicy>
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00}|NULL|%-5level:%class{36}:%M:%L: %m%n</pattern>
+ </layout>
+ </appender>
+
+ <appender name="errorAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${LOG_DIR}/error.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <!-- rollover daily -->
+ <fileNamePattern>${LOG_DIR}/error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
+ <!-- each file should be at most 100MB, keep 2 days worth of history, but at most 200MB -->
+ <maxFileSize>100MB</maxFileSize>
+ <maxHistory>2</maxHistory>
+ <totalSizeCap>200MB</totalSizeCap>
+ </rollingPolicy>
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00}|NULL|%thread|inventory||||ERROR|0|ERROR:|%class{36}:%M:%L: %m%n</pattern>
+ </layout>
+ </appender>
+
+ <logger name="metricsLogger" level="info" additivity="false">
+ <appender-ref ref="metricsAppender" />
+ </logger>
+
+ <logger name="debugLogger" level="debug" additivity="false">
+ <appender-ref ref="debugAppender" />
+ </logger>
+
+ <logger name="errorLogger" level="debug" additivity="false">
+ <appender-ref ref="errorAppender" />
+ </logger>
- <logger name="com" level="INFO"/>
+ <!--<logger name="com" level="INFO"/> -->
- <root level="debug">
- <appender-ref ref="STDOUT" />
- </root>
-</configuration>
+ <root level="info">
+ <!-- <appender-ref ref="STDOUT" /> -->
+ <appender-ref ref="debugAppender" />
+ </root>
+
+</configuration> \ No newline at end of file
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java b/src/test/java/io/swagger/api/BootstrapTest.java
index 9939aee..7c86d8c 100644
--- a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java
+++ b/src/test/java/io/swagger/api/BootstrapTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. 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.
@@ -18,20 +18,26 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.exceptions.mappers;
+package io.swagger.api;
-import org.openecomp.dcae.inventory.exceptions.DCAEControllerTimeoutException;
+import org.junit.Test;
-import javax.ws.rs.core.Response;
+import javax.servlet.ServletException;
+
+import static org.junit.Assert.fail;
/**
- * Created by mhwang on 8/23/16.
+ * Created by mhwang on 3/22/18.
*/
-public class DCAEControllerTimeoutExceptionMapper extends DCAEControllerExceptionMapper<DCAEControllerTimeoutException> {
+public class BootstrapTest {
- @Override
- protected Response.Status getStatus() {
- return Response.Status.GATEWAY_TIMEOUT;
+ @Test
+ public void testNoServletConfig() {
+ try {
+ (new Bootstrap()).init(null);
+ } catch(ServletException e) {
+ fail("This might be a valid failure. Should investigate.");
+ }
}
}
diff --git a/src/test/java/Util.java b/src/test/java/io/swagger/api/Util.java
index 9607148..8f9e09f 100644
--- a/src/test/java/Util.java
+++ b/src/test/java/io/swagger/api/Util.java
@@ -1,8 +1,8 @@
-/*-
+package io.swagger.api;/*-
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerConnectionException.java b/src/test/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactoryTest.java
index 2b9e6e7..6b385df 100644
--- a/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerConnectionException.java
+++ b/src/test/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactoryTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. 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.
@@ -18,19 +18,20 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.exceptions;
+package io.swagger.api.factories;
+
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertNotNull;
/**
- * Created by mhwang on 8/23/16.
+ * Created by mhwang on 3/22/18.
*/
-public class DCAEControllerConnectionException extends RuntimeException {
-
- public DCAEControllerConnectionException(String message) {
- super(message);
- }
+public class DcaeServiceTypesApiServiceFactoryTest {
- public DCAEControllerConnectionException(Throwable e) {
- super(e);
+ @Test
+ public void testGetDcaeServiceTypesApi() {
+ assertNotNull(DcaeServiceTypesApiServiceFactory.getDcaeServiceTypesApi());
}
}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerTimeoutException.java b/src/test/java/io/swagger/api/factories/DcaeServicesApiServiceFactoryTest.java
index 8aa9255..d9c6808 100644
--- a/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerTimeoutException.java
+++ b/src/test/java/io/swagger/api/factories/DcaeServicesApiServiceFactoryTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. 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.
@@ -18,19 +18,20 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.exceptions;
+package io.swagger.api.factories;
+
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertNotNull;
/**
- * Created by mhwang on 8/23/16.
+ * Created by mhwang on 3/22/18.
*/
-public class DCAEControllerTimeoutException extends RuntimeException {
-
- public DCAEControllerTimeoutException(String message) {
- super(message);
- }
+public class DcaeServicesApiServiceFactoryTest {
- public DCAEControllerTimeoutException(Throwable e) {
- super(e);
+ @Test
+ public void testGetDcaeServicesApi() {
+ assertNotNull(DcaeServicesApiServiceFactory.getDcaeServicesApi());
}
}
diff --git a/src/test/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactoryTest.java b/src/test/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactoryTest.java
new file mode 100644
index 0000000..033c8a6
--- /dev/null
+++ b/src/test/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactoryTest.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. 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 io.swagger.api.factories;
+
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertNotNull;
+
+/**
+ * Created by mhwang on 3/22/18.
+ */
+public class DcaeServicesGroupbyApiServiceFactoryTest {
+
+ @Test
+ public void testGetDcaeServicesGroupbyApi() {
+ assertNotNull(DcaeServicesGroupbyApiServiceFactory.getDcaeServicesGroupbyApi());
+ }
+
+}
diff --git a/src/test/java/DcaeServiceTypesApiServiceImplTests.java b/src/test/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImplTests.java
index c4ada1f..4a47787 100644
--- a/src/test/java/DcaeServiceTypesApiServiceImplTests.java
+++ b/src/test/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImplTests.java
@@ -1,8 +1,8 @@
-/*-
+package io.swagger.api.impl;/*-
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -18,12 +18,11 @@
* ============LICENSE_END=========================================================
*/
-import org.openecomp.dcae.inventory.daos.DCAEServiceTypesDAO;
-import org.openecomp.dcae.inventory.daos.DCAEServicesDAO;
-import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
-import io.swagger.api.impl.DcaeServiceTypesApiServiceImpl;
+import org.onap.dcae.inventory.daos.DCAEServiceTypesDAO;
+import org.onap.dcae.inventory.daos.DCAEServicesDAO;
+import org.onap.dcae.inventory.daos.InventoryDAOManager;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
import io.swagger.model.DCAEServiceType;
import io.swagger.model.DCAEServiceTypeRequest;
import org.joda.time.DateTime;
diff --git a/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplH2Tests.java b/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplH2Tests.java
new file mode 100644
index 0000000..0a3b777
--- /dev/null
+++ b/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplH2Tests.java
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. 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 io.swagger.api.impl;
+
+import com.codahale.metrics.MetricRegistry;
+import io.dropwizard.db.DataSourceFactory;
+import io.dropwizard.jackson.Jackson;
+import io.dropwizard.jdbi.DBIFactory;
+import io.dropwizard.setup.Environment;
+import io.swagger.api.Util;
+import io.swagger.model.DCAEServiceRequest;
+import org.joda.time.DateTime;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.dcae.inventory.clients.DatabusControllerClient;
+import org.onap.dcae.inventory.daos.*;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.skife.jdbi.v2.DBI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Created by mhwang on 9/25/17.
+ *
+ * This test covers the gap in DcaeServicesApiServiceImplTests - testing the GET query interface
+ * The approach taken here is standing up an H2 in-memory database which is different from the
+ * original test which made an attempt to mock the database calls but ran into an impasse. The
+ * test here was not included in the original class because of conflicting setup operations.
+ */
+@PrepareForTest({InventoryDAOManager.class})
+@RunWith(PowerMockRunner.class)
+public class DcaeServicesApiServiceImplH2Tests {
+
+ private final static Logger LOG = LoggerFactory.getLogger(DcaeServicesApiServiceImplH2Tests.class);
+
+ private DCAEServicesDAO mockServicesDAO = null;
+ private DCAEServiceComponentsDAO mockComponentsDAO = null;
+ private DCAEServicesComponentsMapsDAO mockComponentsMapsDAO = null;
+
+ // https://stackoverflow.com/questions/35825383/how-to-test-jdbi-daos-with-h2-in-memory-database
+ // Caused by: java.lang.ClassNotFoundException: Unable to load class: org.h2.Driver from ClassLoader:sun.misc.Launcher$AppClassLoader@18b4aac2;ClassLoader:sun.misc.Launcher$AppClassLoader@18b4aac2
+ protected DataSourceFactory getDataSourceFactory()
+ {
+ DataSourceFactory dataSourceFactory = new DataSourceFactory();
+ dataSourceFactory.setDriverClass( "org.h2.Driver" );
+ dataSourceFactory.setUrl( "jdbc:h2:mem:testDb" );
+ dataSourceFactory.setUser( "sa" );
+ dataSourceFactory.setPassword( "sa" );
+
+ return dataSourceFactory;
+ }
+
+ @Before
+ public void setUp() {
+ Environment env = new Environment( "test-env", Jackson.newObjectMapper(), null, new MetricRegistry(), null );
+ DBI dbi = new DBIFactory().build( env, getDataSourceFactory(), "test" );
+ mockServicesDAO = dbi.onDemand(DCAEServicesDAO.class);
+ mockComponentsDAO = dbi.onDemand(DCAEServiceComponentsDAO.class);
+ mockComponentsMapsDAO = dbi.onDemand(DCAEServicesComponentsMapsDAO.class);
+
+ // PowerMockito does bytecode magic to mock static methods and use final classes
+ PowerMockito.mockStatic(InventoryDAOManager.class);
+ InventoryDAOManager mockDAOManager = mock(InventoryDAOManager.class);
+
+ when(InventoryDAOManager.getInstance()).thenReturn(mockDAOManager);
+ when(mockDAOManager.getHandle()).thenReturn(dbi.open());
+ }
+
+ @Test
+ public void testDcaeServicesGet () {
+ mockServicesDAO.createTable();
+ mockComponentsDAO.createTable();
+ mockComponentsMapsDAO.createTable();
+
+ DCAEServiceRequest request = new DCAEServiceRequest();
+ request.setTypeId("some-type-id");
+ request.setVnfId("some-vnf-id");
+ request.setVnfType("some-vnf-type");
+ request.setVnfLocation("some-vnf-location");
+ request.setDeploymentRef("some-deployment-ref");
+ DCAEServiceObject so = new DCAEServiceObject("some-service-id", request);
+ mockServicesDAO.insert(so);
+
+ DatabusControllerClient dbcc = mock(DatabusControllerClient.class);
+ DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dbcc);
+ String typeId = "some-type-id";
+ String vnfId = "some-vnf-id";
+ String vnfType = "some-vnf-type";
+ String vnfLocation = "some-vnf-location";
+ String componentType = "some-component-type";
+ Boolean shareable = Boolean.TRUE;
+ DateTime created = null;
+ Integer offset = 0;
+ UriInfo uriInfo = new Util.FakeUriInfo();
+ SecurityContext securityContext = null;
+ Response response = api.dcaeServicesGet(typeId, vnfId, vnfType, vnfLocation, componentType, shareable, created,
+ offset, uriInfo, securityContext);
+ assertEquals(response.getStatus(), 200);
+ }
+
+}
diff --git a/src/test/java/DcaeServicesApiServiceImplTests.java b/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplTests.java
index 50d6e5b..64b7f88 100644
--- a/src/test/java/DcaeServicesApiServiceImplTests.java
+++ b/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplTests.java
@@ -1,8 +1,8 @@
-/*-
+package io.swagger.api.impl;/*-
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -19,24 +19,19 @@
*/
import io.swagger.api.NotFoundException;
-import io.swagger.api.impl.DcaeServicesApiServiceImpl;
+import io.swagger.api.Util;
import io.swagger.model.DCAEService;
-import io.swagger.model.DCAEServiceComponent;
import io.swagger.model.DCAEServiceRequest;
-import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
-import org.junit.internal.runners.statements.Fail;
import org.junit.runner.RunWith;
-import org.openecomp.dcae.inventory.clients.DCAEControllerClient;
-import org.openecomp.dcae.inventory.clients.DatabusControllerClient;
-import org.openecomp.dcae.inventory.daos.DCAEServiceComponentsDAO;
-import org.openecomp.dcae.inventory.daos.DCAEServiceTypesDAO;
-import org.openecomp.dcae.inventory.daos.DCAEServicesDAO;
-import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
-import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceObjectMapper;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.onap.dcae.inventory.clients.DatabusControllerClient;
+import org.onap.dcae.inventory.daos.DCAEServiceComponentsDAO;
+import org.onap.dcae.inventory.daos.DCAEServiceTypesDAO;
+import org.onap.dcae.inventory.daos.DCAEServicesDAO;
+import org.onap.dcae.inventory.daos.InventoryDAOManager;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -44,15 +39,10 @@ import org.powermock.modules.junit4.PowerMockRunner;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
-import org.skife.jdbi.v2.Foreman;
-import org.skife.jdbi.v2.Handle;
-import org.skife.jdbi.v2.Query;
-import org.skife.jdbi.v2.tweak.Argument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -103,9 +93,8 @@ public class DcaeServicesApiServiceImplTests {
fail("Failed to do the reflection trick to test the private method: createDCAEService");
}
- DCAEControllerClient dcc = mock(DCAEControllerClient.class);
DatabusControllerClient dbcc = mock(DatabusControllerClient.class);
- DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dcc, dbcc);
+ DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dbcc);
DCAEServiceRequest serviceRequest = new DCAEServiceRequest();
serviceRequest.setTypeId("type-id-abc");
@@ -133,9 +122,8 @@ public class DcaeServicesApiServiceImplTests {
when(mockServicesDAO.getByServiceId(DCAEServiceObject.DCAEServiceStatus.RUNNING, serviceId)).thenReturn(serviceObject);
when(mockComponentsDAO.getByServiceId(serviceId)).thenReturn(new ArrayList<DCAEServiceComponentObject>());
- DCAEControllerClient dcc = mock(DCAEControllerClient.class);
DatabusControllerClient dbcc = mock(DatabusControllerClient.class);
- DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dcc, dbcc);
+ DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dbcc);
UriInfo uriInfo = new Util.FakeUriInfo();
try {
@@ -162,9 +150,8 @@ public class DcaeServicesApiServiceImplTests {
doReturn(null).when(mockQuery.bind(anyString(), any(DateTime.class)));
when(mockQuery.bind(anyString(), anyInt())).thenReturn(null);
- DCAEControllerClient dcc = mock(DCAEControllerClient.class);
DatabusControllerClient dbcc = mock(DatabusControllerClient.class);
- DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dcc, dbcc);
+ DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dbcc);
String typeId = "some-type-id";
String vnfId = "some-vnf-id";
@@ -174,7 +161,7 @@ public class DcaeServicesApiServiceImplTests {
Boolean shareable = Boolean.TRUE;
DateTime created = null;
Integer offset = 0;
- UriInfo uriInfo = new Util.FakeUriInfo();
+ UriInfo uriInfo = new io.swagger.api.Util.FakeUriInfo();
SecurityContext securityContext = null;
when(mockQuery.list()).thenReturn(new ArrayList<DCAEServiceObject>());
@@ -194,9 +181,8 @@ public class DcaeServicesApiServiceImplTests {
when(mockTypesDAO.getByTypeIdActiveOnly(serviceRequest.getTypeId())).thenReturn(null);
- DCAEControllerClient dcc = mock(DCAEControllerClient.class);
DatabusControllerClient dbcc = mock(DatabusControllerClient.class);
- DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dcc, dbcc);
+ DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dbcc);
UriInfo uriInfo = new Util.FakeUriInfo();
Response response = api.dcaeServicesServiceIdPut(serviceId, serviceRequest, uriInfo, null);
@@ -212,9 +198,8 @@ public class DcaeServicesApiServiceImplTests {
DCAEServiceObject serviceObject = new DCAEServiceObject(serviceId, serviceRequest);
when(mockServicesDAO.getByServiceId(DCAEServiceObject.DCAEServiceStatus.RUNNING, serviceId)).thenReturn(serviceObject);
- DCAEControllerClient dcc = mock(DCAEControllerClient.class);
DatabusControllerClient dbcc = mock(DatabusControllerClient.class);
- DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dcc, dbcc);
+ DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dbcc);
UriInfo uriInfo = new Util.FakeUriInfo();
try {
@@ -233,9 +218,8 @@ public class DcaeServicesApiServiceImplTests {
String serviceId = "service-id-123";
when(mockServicesDAO.getByServiceId(DCAEServiceObject.DCAEServiceStatus.RUNNING, serviceId)).thenReturn(null);
- DCAEControllerClient dcc = mock(DCAEControllerClient.class);
DatabusControllerClient dbcc = mock(DatabusControllerClient.class);
- DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dcc, dbcc);
+ DcaeServicesApiServiceImpl api = new DcaeServicesApiServiceImpl(dbcc);
UriInfo uriInfo = new Util.FakeUriInfo();
try {
diff --git a/src/test/java/DcaeServicesGroupbyApiServiceImplTests.java b/src/test/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImplTests.java
index ffe7cb2..0ae2c3a 100644
--- a/src/test/java/DcaeServicesGroupbyApiServiceImplTests.java
+++ b/src/test/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImplTests.java
@@ -1,8 +1,8 @@
-/*-
+package io.swagger.api.impl;/*-
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. 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.
@@ -18,18 +18,14 @@
* ============LICENSE_END=========================================================
*/
-import io.swagger.api.impl.DcaeServicesGroupbyApiServiceImpl;
+import io.swagger.api.Util;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.stubbing.OngoingStubbing;
-import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
-import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.onap.dcae.inventory.daos.InventoryDAOManager;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import org.skife.jdbi.v2.Handle;
-import org.skife.jdbi.v2.Query;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -74,7 +70,7 @@ public class DcaeServicesGroupbyApiServiceImplTests {
DcaeServicesGroupbyApiServiceImpl api = new DcaeServicesGroupbyApiServiceImpl();
String propertyName = "type";
- UriInfo uriInfo = new Util.FakeUriInfo();
+ UriInfo uriInfo = new io.swagger.api.Util.FakeUriInfo();
Handle mockHandle = mock(Handle.class);
when(InventoryDAOManager.getInstance().getHandle()).thenReturn(mockHandle);
diff --git a/src/test/java/org/onap/dcae/inventory/InventoryConfigurationTest.java b/src/test/java/org/onap/dcae/inventory/InventoryConfigurationTest.java
new file mode 100644
index 0000000..f9dadb8
--- /dev/null
+++ b/src/test/java/org/onap/dcae/inventory/InventoryConfigurationTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. 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.dcae.inventory;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.dropwizard.configuration.YamlConfigurationFactory;
+import io.dropwizard.jackson.Jackson;
+import io.dropwizard.jersey.validation.Validators;
+import org.junit.Test;
+
+import javax.validation.Validator;
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Created by mhwang on 3/22/18.
+ */
+public class InventoryConfigurationTest {
+
+ final private ObjectMapper objectMapper = Jackson.newObjectMapper();
+ final private Validator validator = Validators.newValidator();
+ final private YamlConfigurationFactory<InventoryConfiguration> factory
+ = new YamlConfigurationFactory<>(InventoryConfiguration.class, validator, objectMapper, "dw");
+
+ @Test
+ public void testInventoryConfigurationLoad() {
+ try {
+ final File yaml = new File(Thread.currentThread().getContextClassLoader().getResource("config-inventory.yaml").getPath());
+ InventoryConfiguration configuration = factory.build(yaml);
+
+ assertEquals(configuration.getDatabusControllerConnection().getHost(), "databus-controller-hostname");
+ assertEquals((long) configuration.getDatabusControllerConnection().getPort(), 8443);
+ assertEquals(configuration.getDatabusControllerConnection().getRequired(), true);
+
+ assertEquals(configuration.getDataSourceFactory().getUrl(), "jdbc:postgresql://127.0.0.1:5432/dcae_inv");
+ } catch(Exception e) {
+ fail("Failed to load config-inventory");
+ }
+ }
+
+}
diff --git a/src/test/java/org/onap/dcae/inventory/LinkSerializerTest.java b/src/test/java/org/onap/dcae/inventory/LinkSerializerTest.java
new file mode 100644
index 0000000..81b0554
--- /dev/null
+++ b/src/test/java/org/onap/dcae/inventory/LinkSerializerTest.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. 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.dcae.inventory;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import org.junit.Test;
+
+import javax.ws.rs.core.Link;
+import javax.ws.rs.core.UriBuilder;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+/**
+ * Created by mhwang on 3/25/18.
+ */
+public class LinkSerializerTest {
+
+ @Test
+ public void testSerialize() {
+ JsonGenerator jg = mock(JsonGenerator.class);
+
+ try {
+ Link link = new Link() {
+ @Override
+ public URI getUri() {
+ try {
+ return new URI("http://localhost/some-title");
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @Override
+ public UriBuilder getUriBuilder() {
+ return null;
+ }
+
+ @Override
+ public String getRel() {
+ return "self";
+ }
+
+ @Override
+ public List<String> getRels() {
+ return null;
+ }
+
+ @Override
+ public String getTitle() {
+ return "some-title";
+ }
+
+ @Override
+ public String getType() {
+ return null;
+ }
+
+ @Override
+ public Map<String, String> getParams() {
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return null;
+ }
+ };
+ (new LinkSerializer()).serialize(link, jg, null);
+ } catch (Exception e) {
+ fail("Failed to serialze link");
+ }
+ }
+
+}
diff --git a/src/test/java/org/onap/dcae/inventory/clients/DatabusControllerClientTest.java b/src/test/java/org/onap/dcae/inventory/clients/DatabusControllerClientTest.java
new file mode 100644
index 0000000..ae2f2ff
--- /dev/null
+++ b/src/test/java/org/onap/dcae/inventory/clients/DatabusControllerClientTest.java
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. 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.dcae.inventory.clients;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.dropwizard.configuration.ConfigurationException;
+import io.dropwizard.configuration.YamlConfigurationFactory;
+import io.dropwizard.jackson.Jackson;
+import io.dropwizard.jersey.validation.Validators;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dcae.inventory.InventoryConfiguration;
+import org.onap.dcae.inventory.exceptions.DatabusControllerClientException;
+
+import javax.validation.Validator;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+/**
+ * Created by mhwang on 3/22/18.
+ */
+public class DatabusControllerClientTest {
+
+ final private ObjectMapper objectMapper = Jackson.newObjectMapper();
+ final private Validator validator = Validators.newValidator();
+ final private YamlConfigurationFactory<InventoryConfiguration.DatabusControllerConnectionConfiguration> factory
+ = new YamlConfigurationFactory<>(InventoryConfiguration.DatabusControllerConnectionConfiguration.class, validator, objectMapper, "dw");
+
+ private InventoryConfiguration.DatabusControllerConnectionConfiguration configuration = null;
+
+ @Before
+ public void setupClass() throws IOException, ConfigurationException {
+ final File yaml = new File(Thread.currentThread().getContextClassLoader().getResource("config-databus.yaml").getPath());
+ this.configuration = factory.build(yaml);
+ }
+
+ @Test
+ public void testConstructResourceURI() {
+ DatabusControllerClient client = new DatabusControllerClient(null, this.configuration);
+ URI uri = client.constructResourceURI("/some-path");
+ assertEquals(uri.toString(), "https://databus-controller-hostname:8443/some-path");
+ }
+
+ private DatabusControllerClient setupForIsExists(Response mockResponse) {
+ Client mockClient = mock(Client.class);
+ WebTarget mockWebTarget = mock(WebTarget.class);
+ Invocation.Builder mockBuilder = mock(Invocation.Builder.class);
+
+ try {
+ URI uri = new URI("https://databus-controller-hostname:8443/some-component-id");
+ when(mockClient.target(uri)).thenReturn(mockWebTarget);
+ //when(mockClient.target(new URI(any()))).thenReturn(mockWebTarget);
+ } catch(URISyntaxException e) {
+ fail("URI syntax error");
+ }
+
+ when(mockWebTarget.request(MediaType.APPLICATION_JSON_TYPE)).thenReturn(mockBuilder);
+ when(mockBuilder.header(any(), any())).thenReturn(mockBuilder);
+
+ when(mockBuilder.get()).thenReturn(mockResponse);
+ return new DatabusControllerClient(mockClient, this.configuration);
+
+ }
+
+ @Test
+ public void testIsExists() {
+ Response mockResponse = mock(Response.class);
+ when(mockResponse.getStatus()).thenReturn(200);
+ InputStream stream = new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8));
+ when(mockResponse.getEntity()).thenReturn(stream);
+
+ DatabusControllerClient client = setupForIsExists(mockResponse);
+
+ try {
+ assertEquals(client.isExists("some-component-id"), false);
+ } catch(Exception e) {
+ fail("Unexpected exception");
+ }
+ }
+
+ private void testIsExistsErrors(int statusError) {
+ Response mockResponse = mock(Response.class);
+ when(mockResponse.getStatus()).thenReturn(statusError);
+
+ DatabusControllerClient client = setupForIsExists(mockResponse);
+
+ try {
+ client.isExists("some-component-id");
+ fail("This was supposed to be a fail case. Exception not thrown.");
+ } catch(DatabusControllerClientException e) {
+ // Expected exception
+ } catch(Exception e) {
+ fail("Unexpected exception");
+ }
+ }
+
+ @Test
+ public void testIsExists401() {
+ testIsExistsErrors(401);
+ }
+
+ @Test
+ public void testIsExists403() {
+ testIsExistsErrors(403);
+ }
+
+ @Test
+ public void testIsExists500() {
+ testIsExistsErrors(500);
+ }
+
+}
diff --git a/src/test/java/org/onap/dcae/inventory/daos/DCAEServicesDAOTest.java b/src/test/java/org/onap/dcae/inventory/daos/DCAEServicesDAOTest.java
new file mode 100644
index 0000000..af05704
--- /dev/null
+++ b/src/test/java/org/onap/dcae/inventory/daos/DCAEServicesDAOTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. 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.dcae.inventory.daos;
+
+import com.codahale.metrics.MetricRegistry;
+import io.dropwizard.db.DataSourceFactory;
+import io.dropwizard.jackson.Jackson;
+import io.dropwizard.jdbi.DBIFactory;
+import io.dropwizard.setup.Environment;
+import io.swagger.model.DCAEServiceRequest;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.skife.jdbi.v2.DBI;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Created by mhwang on 3/25/18.
+ */
+public class DCAEServicesDAOTest {
+
+ private DCAEServicesDAO fooDAO;
+
+ // Learned about the H2 approach from here:
+ // https://stackoverflow.com/questions/35825383/how-to-test-jdbi-daos-with-h2-in-memory-database
+ protected DataSourceFactory getDataSourceFactory()
+ {
+ DataSourceFactory dataSourceFactory = new DataSourceFactory();
+ dataSourceFactory.setDriverClass( "org.h2.Driver" );
+ dataSourceFactory.setUrl( "jdbc:h2:mem:testDb" );
+ dataSourceFactory.setUser( "sa" );
+ dataSourceFactory.setPassword( "sa" );
+
+ return dataSourceFactory;
+ }
+
+ @Before
+ public void setUp() {
+ Environment env = new Environment( "test-env", Jackson.newObjectMapper(), null, new MetricRegistry(), null );
+ DBI dbi = new DBIFactory().build( env, getDataSourceFactory(), "test" );
+ fooDAO = dbi.onDemand(DCAEServicesDAO.class);
+ }
+
+ @Test
+ public void testSaveAndGet() {
+ try {
+ fooDAO.createTable();
+ DCAEServiceRequest request = new DCAEServiceRequest();
+ request.setTypeId("some-type-id");
+ request.setVnfId("some-vnf-id");
+ request.setVnfType("some-vnf-type");
+ request.setVnfLocation("some-vnf-location");
+ request.setDeploymentRef("some-deployment-ref");
+ DCAEServiceObject so = new DCAEServiceObject("some-service-id", request);
+ fooDAO.insert(so);
+
+ DCAEServiceObject target = fooDAO.getByServiceId("some-service-id");
+ assertEquals(target.getServiceId(), so.getServiceId());
+ } catch(Exception e) {
+ fail("Failure at some point in this compound test.");
+ }
+ }
+}
diff --git a/src/test/java/org/openecomp/dcae/inventory/daos/InventoryDAOManagerTests.java b/src/test/java/org/onap/dcae/inventory/daos/InventoryDAOManagerTests.java
index 16e3688..8346372 100644
--- a/src/test/java/org/openecomp/dcae/inventory/daos/InventoryDAOManagerTests.java
+++ b/src/test/java/org/onap/dcae/inventory/daos/InventoryDAOManagerTests.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.daos;
+package org.onap.dcae.inventory.daos;
-import org.openecomp.dcae.inventory.InventoryConfiguration;
+import org.onap.dcae.inventory.InventoryConfiguration;
import io.dropwizard.setup.Environment;
import org.junit.Test;
import static org.mockito.Mockito.mock;
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java b/src/test/java/org/onap/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java
index 2a909f4..c0ad9b8 100644
--- a/src/test/java/org/openecomp/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java
+++ b/src/test/java/org/onap/dcae/inventory/dbthings/daos/DCAEServiceTransactionDAOTests.java
@@ -18,14 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.daos;
+package org.onap.dcae.inventory.dbthings.daos;
import org.joda.time.DateTime;
import org.junit.Test;
-import org.openecomp.dcae.inventory.daos.DCAEServiceComponentsDAO;
-import org.openecomp.dcae.inventory.daos.DCAEServiceTransactionDAO;
-import org.openecomp.dcae.inventory.daos.DCAEServicesComponentsMapsDAO;
-import org.openecomp.dcae.inventory.daos.DCAEServicesDAO;
+import org.onap.dcae.inventory.daos.DCAEServiceComponentsDAO;
+import org.onap.dcae.inventory.daos.DCAEServiceTransactionDAO;
+import org.onap.dcae.inventory.daos.DCAEServicesComponentsMapsDAO;
+import org.onap.dcae.inventory.daos.DCAEServicesDAO;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java b/src/test/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java
index cb3c7f1..bb511e2 100644
--- a/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java
+++ b/src/test/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapperTests.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.mappers;
+package org.onap.dcae.inventory.dbthings.mappers;
import org.junit.Test;
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java b/src/test/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java
index 1946343..ab150bb 100644
--- a/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java
+++ b/src/test/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapperTests.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.mappers;
+package org.onap.dcae.inventory.dbthings.mappers;
import org.junit.Test;
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java b/src/test/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java
index f8c2428..c1caa29 100644
--- a/src/test/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java
+++ b/src/test/java/org/onap/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapperTests.java
@@ -18,8 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.mappers;
+package org.onap.dcae.inventory.dbthings.mappers;
+import junit.framework.TestCase;
import org.junit.Test;
import java.sql.Array;
@@ -100,7 +101,7 @@ public class DCAEServiceTypeObjectMapperTests {
}
});
- assertNotNull(mapper.map(0, resultSet, null));
+ TestCase.assertNotNull(mapper.map(0, resultSet, null));
} catch(Exception e) {
fail("Unexpected exception");
}
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObjectTests.java b/src/test/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceComponentObjectTests.java
index 44f4f73..cb81131 100644
--- a/src/test/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObjectTests.java
+++ b/src/test/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceComponentObjectTests.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.models;
+package org.onap.dcae.inventory.dbthings.models;
import io.swagger.model.DCAEServiceComponentRequest;
import org.junit.Test;
diff --git a/src/test/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObjectTests.java b/src/test/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObjectTests.java
index 9f7b6f8..7a39883 100644
--- a/src/test/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObjectTests.java
+++ b/src/test/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObjectTests.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.dbthings.models;
+package org.onap.dcae.inventory.dbthings.models;
import io.swagger.model.DCAEServiceRequest;
import org.junit.Test;
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerClientException.java b/src/test/java/org/onap/dcae/inventory/exceptions/DatabusControllerClientExceptionTest.java
index eb30ae7..fcde16e 100644
--- a/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerClientException.java
+++ b/src/test/java/org/onap/dcae/inventory/exceptions/DatabusControllerClientExceptionTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* dcae-inventory
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. 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.
@@ -18,19 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.exceptions;
+package org.onap.dcae.inventory.exceptions;
+
+import org.junit.Test;
/**
- * Created by mhwang on 5/13/16.
+ * Created by mhwang on 3/26/18.
*/
-public class DCAEControllerClientException extends RuntimeException {
-
- public DCAEControllerClientException(String message) {
- super(message);
- }
+public class DatabusControllerClientExceptionTest {
- public DCAEControllerClientException(Throwable e) {
- super(e);
+ @Test
+ public void testBasicConstructor() {
+ new DatabusControllerClientException(new RuntimeException("Boo"));
}
-
}
diff --git a/src/test/java/org/openecomp/dcae/inventory/exception/mappers/DBIExceptionMapperTests.java b/src/test/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapperTests.java
index 6e72182..b0d5ba4 100644
--- a/src/test/java/org/openecomp/dcae/inventory/exception/mappers/DBIExceptionMapperTests.java
+++ b/src/test/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapperTests.java
@@ -18,10 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.exception.mappers;
+package org.onap.dcae.inventory.exceptions.mappers;
-import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
-import org.openecomp.dcae.inventory.exceptions.mappers.DBIExceptionMapper;
+import org.onap.dcae.inventory.daos.InventoryDAOManager;
+import org.onap.dcae.inventory.exceptions.mappers.DBIExceptionMapper;
import io.swagger.api.ApiResponseMessage;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/src/test/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapperTests.java b/src/test/java/org/onap/dcae/inventory/providers/NotFoundExceptionMapperTests.java
index 083b237..8e2b767 100644
--- a/src/test/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapperTests.java
+++ b/src/test/java/org/onap/dcae/inventory/providers/NotFoundExceptionMapperTests.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.dcae.inventory.providers;
+package org.onap.dcae.inventory.providers;
import io.swagger.api.NotFoundException;
import org.junit.Test;
diff --git a/src/test/resources/config-databus.yaml b/src/test/resources/config-databus.yaml
new file mode 100644
index 0000000..f51c869
--- /dev/null
+++ b/src/test/resources/config-databus.yaml
@@ -0,0 +1,4 @@
+host: databus-controller-hostname
+port: 8443
+mechId: some-mech-id
+password: some-mech-password
diff --git a/src/test/resources/config-inventory.yaml b/src/test/resources/config-inventory.yaml
new file mode 100644
index 0000000..3206566
--- /dev/null
+++ b/src/test/resources/config-inventory.yaml
@@ -0,0 +1,88 @@
+# The database config was lifted from https://dropwizard.github.io/dropwizard/0.7.1/docs/manual/jdbi.html
+database:
+ # the name of your JDBC driver
+ driverClass: org.postgresql.Driver
+
+ # the username
+ user: postgres
+
+ # the password
+ password: test123
+
+ # the JDBC URL
+ # TODO: Probably want to programmatically set the database name.
+ url: jdbc:postgresql://127.0.0.1:5432/dcae_inv
+
+ # any properties specific to your JDBC driver:
+ properties:
+ charSet: UTF-8
+
+ # the maximum amount of time to wait on an empty pool before throwing an exception
+ maxWaitForConnection: 1s
+
+ # the SQL query to run when validating a connection's liveness
+ validationQuery: "/* MyService Health Check */ SELECT 1"
+
+ # the minimum number of connections to keep open
+ minSize: 2
+
+ # the maximum number of connections to keep open
+ maxSize: 8
+
+ initialSize: 2
+
+ # whether or not idle connections should be validated
+ checkConnectionWhileIdle: false
+
+ # the amount of time to sleep between runs of the idle connection validation, abandoned cleaner and idle pool resizing
+ evictionInterval: 10s
+
+ # the minimum amount of time an connection must sit idle in the pool before it is eligible for eviction
+ minIdleTime: 1 minute
+
+databusControllerConnection:
+ host: databus-controller-hostname
+ port: 8443
+ mechId: some-mech-id
+ password: some-password
+
+httpClient:
+ # The minimum number of threads to use for asynchronous calls.
+ minThreads: 1
+
+ # The maximum number of threads to use for asynchronous calls.
+ maxThreads: 128
+
+ # If true, the client will automatically decode response entities
+ # with gzip content encoding.
+ gzipEnabled: false
+
+ # If true, the client will encode request entities with gzip
+ # content encoding. (Requires gzipEnabled to be true).
+ gzipEnabledForRequests: false
+
+ # Requests to databus controller were timing out so I bumped it up 4x of default
+ timeout: 5000milliseconds
+ connectionTimeout: 5000milliseconds
+
+server:
+ # requestLog is for those messages you see right when the service handles HTTP requests
+ requestLog:
+ appenders:
+ - type: file
+ currentLogFilename: /opt/logs/DCAE/inventory/audit.log
+ archive: true
+ archivedLogFilenamePattern: /opt/logs/DCAE/inventory/audit-%d.log.gz
+ archivedFileCount: 10
+ - type: console
+
+# Rolling is c.q.l.core.rolling.TimeBasedRollingPolicy
+logging:
+ level: INFO
+ appenders:
+ - type: file
+ currentLogFilename: /opt/logs/DCAE/inventory/audit.log
+ archive: true
+ archivedLogFilenamePattern: /opt/logs/DCAE/inventory/audit-%d.log.gz
+ archivedFileCount: 10
+ - type: console
diff --git a/swagger_inventory.yaml b/swagger_inventory.yaml
index 11dbcbc..c18419c 100644
--- a/swagger_inventory.yaml
+++ b/swagger_inventory.yaml
@@ -1,6 +1,23 @@
+# ================================================================================
+# Copyright (c) 2017-2018 AT&T Intellectual Property. 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=========================================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
swagger: '2.0'
info:
- version: "2.1.0"
+ version: "3.0.0"
title: DCAE Inventory API
description: |
DCAE Inventory is a web service that provides the following:
@@ -225,14 +242,6 @@ paths:
description: "List of `DCAEService` objects"
schema:
$ref: "#/definitions/InlineResponse2001"
- 502:
- description: "Bad response from DCAE controller"
- schema:
- $ref: "#/definitions/ApiResponseMessage"
- 504:
- description: "Failed to connect with DCAE controller"
- schema:
- $ref: "#/definitions/ApiResponseMessage"
/dcae-services-groupby/{propertyName}:
get:
summary: ""
@@ -277,18 +286,10 @@ paths:
description: "Single `DCAEService` object"
schema:
$ref: "#/definitions/DCAEService"
- 502:
- description: "Bad response from DCAE controller"
- schema:
- $ref: "#/definitions/ApiResponseMessage"
404:
description: "DCAE service not found"
schema:
$ref: "#/definitions/ApiResponseMessage"
- 504:
- description: "Failed to connect with DCAE controller"
- schema:
- $ref: "#/definitions/ApiResponseMessage"
put:
summary: ""
description: "Put a new or update an existing `DCAEService` object."
@@ -408,7 +409,6 @@ definitions:
description: "Specifies the name of the underying source service that is responsible\
\ for this components"
enum:
- - "DCAEController"
- "DMaaPController"
shareable:
type: "integer"
diff --git a/version.properties b/version.properties
index 35d03a3..97784ff 100644
--- a/version.properties
+++ b/version.properties
@@ -1,9 +1,9 @@
# Versioning variables
# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )
# because they are used in Jenkins, whose plug-in doesn't support
-major=1
+major=3
minor=0
-patch=0
+patch=1
base_version=${major}.${minor}.${patch}
# Release must be completed with git revision # in Jenkins