aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java/org
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-07 11:50:06 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-07 11:51:05 -0400
commit47d3bea99e44211533e9e014164cc7e245f5e5bd (patch)
tree0609507614cbaa23a52c85f6531857d2ea20e513 /mso-catalog-db/src/main/java/org
parent956f5e200a3a54a39d253c98636986e846013c29 (diff)
E2EServiceInstances to be free of catalogdb
Fixing Junits Making MSO requests free from direct repository calls Add @Param annotation so as to fix JPA methods with query parameters Fix createE2EServiceInstance Test Add Unit Tests for Sunny day scenarios revert import auto-alignment Issue-ID: SO-811 Change-Id: I9f69d817622b0807642a783311d6959817a77970 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-catalog-db/src/main/java/org')
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java103
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java3
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java8
3 files changed, 77 insertions, 37 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index d3a1c5d8d6..edfaba0fb2 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -20,14 +20,6 @@
package org.onap.so.db.catalog.client;
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.core.UriBuilder;
-
import org.onap.so.db.catalog.beans.BuildingBlockDetail;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
@@ -40,6 +32,7 @@ import org.onap.so.db.catalog.beans.ResourceType;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
@@ -54,38 +47,58 @@ import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
-
import uk.co.blackpepper.bowman.Client;
import uk.co.blackpepper.bowman.ClientFactory;
import uk.co.blackpepper.bowman.Configuration;
import uk.co.blackpepper.bowman.RestTemplateConfigurer;
+import javax.annotation.PostConstruct;
+import javax.ws.rs.core.UriBuilder;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
@Component("CatalogDbClient")
public class CatalogDbClient {
- protected Client<Service> serviceClient;
+ private static final String SERVICE_RECIPE_SEARCH = "/serviceRecipe/search";
+ private static final String SERVICE_MODEL_UUID = "SERVICE_MODEL_UUID";
+ private static final String ACTION = "ACTION";
+ private static final String MODEL_NAME = "MODEL_NAME";
+ private static final String SERVICE_SEARCH = "/service/search";
+ private static final String MODEL_VERSION = "MODEL_VERSION";
+ private static final String MODEL_INVARIANT_UUID = "MODEL_INVARIANT_UUID";
+ private String findFirstByModelNameURI = "/findFirstByModelNameOrderByModelVersionDesc";
+ private String findFirstByServiceModelUUIDAndActionURI = "/findFirstByServiceModelUUIDAndAction";
+ private String findByModelVersionAndModelInvariantUUIDURI = "/findByModelVersionAndModelInvariantUUID";
+
+ private Client<Service> serviceClient;
- protected Client<VfModuleCustomization> vfModuleCustomizationClient;
+ private Client<VfModuleCustomization> vfModuleCustomizationClient;
- protected Client<OrchestrationFlow> orchestrationClient;
+ private Client<OrchestrationFlow> orchestrationClient;
- protected Client<NorthBoundRequest> northBoundRequestClient;
+ private Client<NorthBoundRequest> northBoundRequestClient;
- protected Client<RainyDayHandlerStatus> rainyDayHandlerStatusClient;
+ private Client<RainyDayHandlerStatus> rainyDayHandlerStatusClient;
- protected Client<BuildingBlockDetail> buildingBlockDetailClient;
+ private Client<BuildingBlockDetail> buildingBlockDetailClient;
- protected Client<OrchestrationStatusStateTransitionDirective> orchestrationStatusStateTransitionDirectiveClient;
+ private Client<OrchestrationStatusStateTransitionDirective> orchestrationStatusStateTransitionDirectiveClient;
- protected Client<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizationClient;
+ private Client<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizationClient;
- protected Client<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationClient;
+ private Client<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationClient;
- protected Client<InstanceGroup> instanceGroupClient;
+ private Client<InstanceGroup> instanceGroupClient;
- protected Client<NetworkCollectionResourceCustomization> networkCollectionResourceCustomizationClient;
+ private Client<NetworkCollectionResourceCustomization> networkCollectionResourceCustomizationClient;
- protected Client<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationClient;
+ private Client<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationClient;
+
+ private Client<ServiceRecipe> serviceRecipeClient;
@Value("${mso.catalog.db.spring.endpoint}")
protected String endpoint;
@@ -93,6 +106,13 @@ public class CatalogDbClient {
@Value("${mso.db.auth}")
private String msoAdaptersAuth;
+ @PostConstruct
+ public void init(){
+ findFirstByModelNameURI = endpoint + SERVICE_SEARCH + findFirstByModelNameURI;
+ findByModelVersionAndModelInvariantUUIDURI = endpoint + SERVICE_SEARCH + findByModelVersionAndModelInvariantUUIDURI;
+ findFirstByServiceModelUUIDAndActionURI = endpoint + SERVICE_RECIPE_SEARCH + findFirstByServiceModelUUIDAndActionURI;
+ }
+
public CatalogDbClient() {
ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory());
@@ -126,6 +146,7 @@ public class CatalogDbClient {
instanceGroupClient = clientFactory.create(InstanceGroup.class);
networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class);
collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class);
+ serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
}
public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) {
@@ -198,7 +219,7 @@ public class CatalogDbClient {
return this.getMultipleOrchestrationFlows(UriBuilder.fromUri(endpoint + "/orchestrationFlow/").build());
}
- protected List<OrchestrationFlow> getMultipleOrchestrationFlows(URI uri) {
+ private List<OrchestrationFlow> getMultipleOrchestrationFlows(URI uri) {
Iterable<OrchestrationFlow> orchIterator = orchestrationClient.getAll(uri);
List<OrchestrationFlow> orchList = new ArrayList<>();
Iterator<OrchestrationFlow> it = orchIterator.iterator();
@@ -229,7 +250,7 @@ public class CatalogDbClient {
return collectionInstanceGroupCustList;
}
- protected List<VnfcInstanceGroupCustomization> getMultipleVnfcInstanceGroupCustomizations(URI uri) {
+ private List<VnfcInstanceGroupCustomization> getMultipleVnfcInstanceGroupCustomizations(URI uri) {
Iterable<VnfcInstanceGroupCustomization> vnfcIterator = vnfcInstanceGroupCustomizationClient.getAll(uri);
List<VnfcInstanceGroupCustomization> vnfcList = new ArrayList<>();
Iterator<VnfcInstanceGroupCustomization> it = vnfcIterator.iterator();
@@ -264,35 +285,53 @@ public class CatalogDbClient {
.build());
}
- protected CollectionNetworkResourceCustomization getSingleCollectionNetworkResourceCustomization(URI uri) {
+ public ServiceRecipe getFirstByServiceModelUUIDAndAction(String modelUUID, String action){
+ return this.getSingleServiceRecipe(UriBuilder.fromUri(findFirstByServiceModelUUIDAndActionURI)
+ .queryParam(SERVICE_MODEL_UUID,modelUUID)
+ .queryParam(ACTION,action)
+ .build());
+ }
+
+ public Service getFirstByModelNameOrderByModelVersionDesc(String modelName){
+ return this.getSingleService(UriBuilder.fromUri(findFirstByModelNameURI)
+ .queryParam(MODEL_NAME,modelName)
+ .build());
+ }
+
+
+ private CollectionNetworkResourceCustomization getSingleCollectionNetworkResourceCustomization(URI uri) {
return collectionNetworkResourceCustomizationClient.get(uri);
}
- protected InstanceGroup getSingleInstanceGroup(URI uri) {
+ private InstanceGroup getSingleInstanceGroup(URI uri) {
return instanceGroupClient.get(uri);
}
- protected Service getSingleService(URI uri) {
+ private Service getSingleService(URI uri) {
return serviceClient.get(uri);
}
- protected VfModuleCustomization getSingleVfModuleCustomization(URI uri) {
+ private VfModuleCustomization getSingleVfModuleCustomization(URI uri) {
return vfModuleCustomizationClient.get(uri);
}
- protected NorthBoundRequest getSingleNorthBoundRequest(URI uri) {
+ private NorthBoundRequest getSingleNorthBoundRequest(URI uri) {
return northBoundRequestClient.get(uri);
}
- protected RainyDayHandlerStatus getSingleRainyDayHandlerStatus(URI uri) {
+ private RainyDayHandlerStatus getSingleRainyDayHandlerStatus(URI uri) {
return rainyDayHandlerStatusClient.get(uri);
}
+
+ private ServiceRecipe getSingleServiceRecipe(URI uri){
+ return serviceRecipeClient.get(uri);
+ }
public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) {
return this.getSingleService(
- UriBuilder.fromUri(endpoint + "/service/search/findByModelVersionAndModelInvariantUUID")
- .queryParam("MODEL_VERSION", modelVersion)
- .queryParam("MODEL_INVARIANT_UUID", modelInvariantUUID).build());
+ UriBuilder.fromUri(findByModelVersionAndModelInvariantUUIDURI)
+ .queryParam(MODEL_VERSION, modelVersion)
+ .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build());
}
//USED FOR TEST ONLY
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java
index 57578cfb07..cd46846d78 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java
@@ -22,6 +22,7 @@ package org.onap.so.db.catalog.data.repository;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "serviceRecipe", path = "serviceRecipe")
@@ -30,5 +31,5 @@ public interface ServiceRecipeRepository extends JpaRepository<ServiceRecipe, Lo
public ServiceRecipe findByAction(String action);
- public ServiceRecipe findFirstByServiceModelUUIDAndAction(String serviceModelUUID, String action);
+ public ServiceRecipe findFirstByServiceModelUUIDAndAction(@Param("SERVICE_MODEL_UUID") String serviceModelUUID, @Param("ACTION") String action);
} \ No newline at end of file
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java
index eac432a4dd..25b1757185 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java
@@ -41,7 +41,7 @@ public interface ServiceRepository extends JpaRepository<Service, String> {
* @return
*/
@Query(value = "SELECT * FROM service WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;", nativeQuery = true)
- Service findFirstByModelNameOrderByModelVersionDesc(String modelName);
+ Service findFirstByModelNameOrderByModelVersionDesc(@Param("MODEL_NAME") String modelName);
/**
* This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting
@@ -59,7 +59,7 @@ public interface ServiceRepository extends JpaRepository<Service, String> {
/**
* This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting
- * @param modelName
+ * @param modelUUID
* @return
*/
@Query(value = "SELECT * FROM service WHERE MODEL_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;", nativeQuery = true)
@@ -67,7 +67,7 @@ public interface ServiceRepository extends JpaRepository<Service, String> {
/**
* This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting
- * @param modelName
+ * @param modelUUID
* @return
*/
@Query(value = "SELECT * FROM service WHERE MODEL_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;", nativeQuery = true)
@@ -78,7 +78,7 @@ public interface ServiceRepository extends JpaRepository<Service, String> {
/**
* This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting
- * @param modelName
+ * @param modelInvariantUUID
* @return
*/
@Query(value = "SELECT * FROM service WHERE MODEL_INVARIANT_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;", nativeQuery = true)