diff options
Diffstat (limited to 'adapters')
10 files changed, 46 insertions, 30 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java index 2f7d19ff1d..cc79e615f1 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java @@ -24,12 +24,14 @@ import org.springframework.cache.CacheManager; import org.springframework.cache.caffeine.CaffeineCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import com.github.benmanes.caffeine.cache.Caffeine; @Configuration public class NovaCacheConfig { @Bean + @Primary public CacheManager cacheManager() { CaffeineCacheManager cacheManager = new CaffeineCacheManager("novaClient"); cacheManager.setCaffeine(caffeineCacheBuilder()); diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index 0201dd6776..bfb600f3ba 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -73,14 +73,14 @@ </plugin> </plugins> <pluginManagement> - <plugins> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java index fdec7cf5d6..4d8f55e220 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java @@ -20,8 +20,8 @@ package org.onap.so.adapters.catalogdb; -import java.util.stream.Collectors; import javax.persistence.EntityManager; +import javax.persistence.metamodel.Type; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.data.rest.core.config.RepositoryRestConfiguration; @@ -35,8 +35,8 @@ public class CatalogDbRepositoryConfiguration extends RepositoryRestConfigurerAd @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { - config.exposeIdsFor(entityManager.getMetamodel().getEntities().stream().map(e -> e.getJavaType()) - .collect(Collectors.toList()).toArray(new Class[0])); + config.exposeIdsFor( + entityManager.getMetamodel().getEntities().stream().map(Type::getJavaType).toArray(Class[]::new)); } } diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 9cee2882be..893f50c458 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -263,7 +263,7 @@ <artifactId>openstack4j-jersey2</artifactId> <version>3.2.0</version> </dependency> - <dependency> + <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.22.1</version> diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java index b104c3310c..4d8c74dbfe 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java @@ -21,7 +21,6 @@ package org.onap.so.adapters.inventory.delete; import javax.annotation.PostConstruct; -import org.camunda.bpm.client.ExternalTaskClient; import org.onap.so.utils.ExternalTaskServiceUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; @@ -43,10 +42,11 @@ public class DeleteInventoryService { @PostConstruct public void auditAAIInventory() throws Exception { - ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryDelete") - .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000"))) - .handler(deleteInventory::executeExternalTask).open(); + for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { + externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete") + .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000"))) + .handler(deleteInventory::executeExternalTask).open(); + } } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java index 4e8443bf45..200f6375ea 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.JsonMappingException; @Component public class AuditDataService { + private static final String AUDIT_STACK_DATA = "AuditStackData"; + @Autowired private RequestsDbClient requestsDbClient; @@ -30,7 +32,7 @@ public class AuditDataService { throws JsonProcessingException { List<RequestProcessingData> requestProcessingDataList = requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(), - auditInventory.getHeatStackName(), "AuditStackData"); + auditInventory.getHeatStackName(), AUDIT_STACK_DATA); if (requestProcessingDataList.isEmpty()) { GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); String auditListString = objectMapper.getMapper().writeValueAsString(auditList);; @@ -39,7 +41,7 @@ public class AuditDataService { requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId()); requestProcessingData.setGroupingId(auditInventory.getVfModuleId()); requestProcessingData.setName(auditInventory.getHeatStackName()); - requestProcessingData.setTag("AuditStackData"); + requestProcessingData.setTag(AUDIT_STACK_DATA); requestProcessingData.setValue(auditListString); requestsDbClient.saveRequestProcessingData(requestProcessingData); @@ -53,12 +55,11 @@ public class AuditDataService { * @throws JsonMappingException * @throws JsonParseException */ - public Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory) - throws JsonParseException, JsonMappingException, IOException { + public Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory) throws IOException { List<RequestProcessingData> requestProcessingDataList = requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(), - auditInventory.getHeatStackName(), "AuditStackData"); + auditInventory.getHeatStackName(), AUDIT_STACK_DATA); if (!requestProcessingDataList.isEmpty()) { RequestProcessingData requestProcessingData = requestProcessingDataList.get(0); String auditListString = requestProcessingData.getValue(); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java index 8829c702cf..e2fa89bf39 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java @@ -60,6 +60,7 @@ public class OpenstackClientFactoryImpl implements OpenstackClientFactory { OSClientV3 client; try { + OSFactory.enableHttpLoggingFilter(true); client = OSFactory.builderV3().endpoint(osAccess.getUrl()) .credentials(osAccess.getUser(), osAccess.getPassword(), osAccess.getDomainNameIdentifier()) .scopeToProject(Identifier.byId(osAccess.getTenantId()), osAccess.getProjectNameIdentifier()) @@ -81,6 +82,7 @@ public class OpenstackClientFactoryImpl implements OpenstackClientFactory { OSClientV2 client; try { + OSFactory.enableHttpLoggingFilter(true); client = OSFactory.builderV2().endpoint(osAccess.getUrl()) .credentials(osAccess.getUser(), osAccess.getPassword()).tenantId(osAccess.getTenantId()) .authenticate().useRegion(osAccess.getRegion()); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java index fd36995f3d..76e5bbc47f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java @@ -1,10 +1,9 @@ package org.onap.so.adapters.tasks.audit; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; +import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -13,7 +12,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.Vserver; -import org.onap.so.adapters.tasks.audit.AuditDataService; import org.onap.so.audit.beans.AuditInventory; import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.db.request.beans.RequestProcessingData; @@ -22,6 +20,7 @@ import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import com.fasterxml.jackson.core.JsonProcessingException; + @RunWith(MockitoJUnitRunner.Silent.class) public class AuditDataServiceTest { @@ -56,9 +55,8 @@ public class AuditDataServiceTest { vserver.setVserverId("testVserverId"); audit.setAaiObject(vserver); auditList.getAuditList().add(audit); - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - String auditListString = objectMapper.getMapper().writeValueAsString(auditList);; + String auditListString = objectMapper.getMapper().writeValueAsString(auditList); RequestProcessingData requestProcessingData = new RequestProcessingData(); requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId()); @@ -99,4 +97,17 @@ public class AuditDataServiceTest { "testVnfModuleId", "testVfModuleName1", "AuditStackData"); } + @Test + public void testGetStackDataToRequestDbWhenRequestProcessingDataListIsEmpty() throws Exception { + + Mockito.doReturn(new ArrayList<RequestProcessingData>()).when(requestsDbClient) + .getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any()); + Optional<AAIObjectAuditList> result = auditDataService.getStackDataFromRequestDb(auditInventory); + Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag( + "testVnfModuleId", "testVfModuleName1", "AuditStackData"); + assertThat(result).isEmpty(); + + } + + } diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml index ba179b6717..55e59d134e 100644 --- a/adapters/mso-requests-db-adapter/pom.xml +++ b/adapters/mso-requests-db-adapter/pom.xml @@ -280,7 +280,7 @@ </ignore> </action> </pluginExecution> - <pluginExecution> + <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml index 0c320faf8a..8bc9501fbd 100644 --- a/adapters/mso-sdnc-adapter/pom.xml +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -16,7 +16,7 @@ <build> <finalName>${project.artifactId}-${project.version}</finalName> - <pluginManagement> + <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> |