Search in sources :

Example 81 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class SkipCDSBuildingBlockListenerTest method testSkipCDSforService.

@Test
public void testSkipCDSforService() {
    setBuildingBlockAndCurrentSequence(SERVICE_SCOPE, "service-config-assign", SERVICE_MODEL_VERSION_ID, 0);
    when(catalogDbClient.getServiceByID(SERVICE_MODEL_VERSION_ID)).thenReturn(new Service());
    skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
    assertEquals(1, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE));
}
Also used : Service(org.onap.so.db.catalog.beans.Service) Test(org.junit.Test)

Example 82 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class QueryServiceArtifactTest method createList.

private List<ServiceArtifact> createList() {
    List<ServiceArtifact> artifacts = new ArrayList<>();
    Service service = mock(Service.class);
    ServiceArtifact artifact = new ServiceArtifact();
    artifact.setService(service);
    artifact.setArtifactUUID("b170dbeb-2954-4a4f-ad12-6bc84b3e089e");
    artifact.setChecksum("ZWRkMGM3NzNjMmE3NzliYTFiZGNmZjVlMDE4OWEzMTA=");
    artifact.setDescription("embbCn");
    artifact.setType("OTHER");
    artifact.setName("eMBB.zip");
    artifact.setVersion("1");
    artifacts.add(artifact);
    return artifacts;
}
Also used : ServiceArtifact(org.onap.so.db.catalog.beans.ServiceArtifact) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service)

Example 83 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class CatalogDbAdapterRest method serviceVnfsImpl.

public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, String smiUuid, String smVer, String smName, String filter) {
    QueryServiceVnfs qryResp = null;
    int respStatus = HttpStatus.SC_OK;
    List<VnfResourceCustomization> ret = new ArrayList<>();
    Service service = null;
    try {
        if (vnfUuid != null && !"".equals(vnfUuid))
            ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid);
        else if (serviceModelUUID != null && !"".equals(serviceModelUUID))
            service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID);
        else if (smiUuid != null && !"".equals(smiUuid))
            if (smVer != null && !"".equals(smVer))
                service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, smiUuid);
            else
                service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid);
        else if (smName != null && !"".equals(smName)) {
            if (smVer != null && !"".equals(smVer))
                service = serviceRepo.findByModelNameAndModelVersion(smName, smVer);
            else
                service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName);
        } else {
            throw (new Exception(NO_MATCHING_PARAMETERS));
        }
        if (service == null && ret.isEmpty()) {
            respStatus = HttpStatus.SC_NOT_FOUND;
            qryResp = new QueryServiceVnfs();
        } else if (service == null && !ret.isEmpty()) {
            if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) {
                ret.forEach(vnfCustomization -> vnfCustomization.setResourceInput(null));
            }
            qryResp = new QueryServiceVnfs(ret);
        } else if (service != null) {
            ret = service.getVnfCustomizations();
            if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) {
                ret.forEach(vnfCustomization -> vnfCustomization.setResourceInput(null));
            }
            qryResp = new QueryServiceVnfs(ret);
        }
        logger.debug("serviceVnfs qryResp= {}", qryResp);
        return respond(version, respStatus, isArray, qryResp);
    } catch (Exception e) {
        logger.error("Exception - queryServiceVnfs", e);
        CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
        return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(new GenericEntity<CatalogQueryException>(excResp) {
        }).build();
    }
}
Also used : VnfRecipe(org.onap.so.db.catalog.beans.VnfRecipe) QueryServiceMacroHolder(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceMacroHolder) NetworkRecipeRepository(org.onap.so.db.catalog.data.repository.NetworkRecipeRepository) Produces(javax.ws.rs.Produces) Path(javax.ws.rs.Path) VfModule(org.onap.so.db.catalog.beans.VfModule) LoggerFactory(org.slf4j.LoggerFactory) HttpStatus(org.apache.http.HttpStatus) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) VnfRecipeRepository(org.onap.so.db.catalog.data.repository.VnfRecipeRepository) QueryServiceNetworks(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) Service(org.onap.so.db.catalog.beans.Service) VFModuleRepository(org.onap.so.db.catalog.data.repository.VFModuleRepository) NetworkResourceRepository(org.onap.so.db.catalog.data.repository.NetworkResourceRepository) ProcessingFlagsRepository(org.onap.so.db.catalog.data.repository.ProcessingFlagsRepository) QueryServiceCsar(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar) GenericEntity(javax.ws.rs.core.GenericEntity) QueryServiceVnfs(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs) ProcessingFlags(org.onap.so.db.catalog.beans.ProcessingFlags) List(java.util.List) AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) HttpHeaders(javax.ws.rs.core.HttpHeaders) Response(javax.ws.rs.core.Response) NetworkResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) VnfCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfCustomizationRepository) QueryAllottedResourceCustomization(org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization) Recipe(org.onap.so.db.catalog.beans.Recipe) PathParam(javax.ws.rs.PathParam) QueryVfModule(org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule) GET(javax.ws.rs.GET) InstanceGroupRepository(org.onap.so.db.catalog.data.repository.InstanceGroupRepository) CatalogQuery(org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery) ArrayList(java.util.ArrayList) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) AllottedResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository) CatalogQueryExceptionCategory(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory) AllottedResourceRepository(org.onap.so.db.catalog.data.repository.AllottedResourceRepository) VnfResource(org.onap.so.db.catalog.beans.VnfResource) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) Logger(org.slf4j.Logger) ServiceMacroHolder(org.onap.so.db.catalog.rest.beans.ServiceMacroHolder) QueryResourceRecipe(org.onap.so.adapters.catalogdb.catalogrest.QueryResourceRecipe) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) VnfResourceRepository(org.onap.so.db.catalog.data.repository.VnfResourceRepository) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Component(org.springframework.stereotype.Component) ArRecipeRepository(org.onap.so.db.catalog.data.repository.ArRecipeRepository) ServiceRepository(org.onap.so.db.catalog.data.repository.ServiceRepository) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization) PUT(javax.ws.rs.PUT) ToscaCsarRepository(org.onap.so.db.catalog.data.repository.ToscaCsarRepository) Transactional(org.springframework.transaction.annotation.Transactional) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) QueryServiceVnfs(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException)

Example 84 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class CatalogDbAdapterRest method serviceAllottedResourcesImpl.

public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) {
    QueryAllottedResourceCustomization qryResp;
    int respStatus = HttpStatus.SC_OK;
    String uuid = "";
    List<AllottedResourceCustomization> ret = new ArrayList<>();
    Service service = null;
    try {
        if (smUuid != null && !"".equals(smUuid)) {
            uuid = smUuid;
            service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid);
        } else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
            uuid = serviceModelInvariantUuid;
            if (smVer != null && !"".equals(smVer)) {
                service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, uuid);
            } else {
                service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
            }
        } else if (aUuid != null && !"".equals(aUuid)) {
            uuid = aUuid;
            ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid);
        } else {
            throw (new Exception(NO_MATCHING_PARAMETERS));
        }
        if (service != null)
            ret = service.getAllottedCustomizations();
        if (ret == null || ret.isEmpty()) {
            logger.debug("AllottedResourceCustomization not found");
            respStatus = HttpStatus.SC_NOT_FOUND;
            qryResp = new QueryAllottedResourceCustomization();
        } else {
            qryResp = new QueryAllottedResourceCustomization(ret);
            logger.debug("AllottedResourceCustomization qryResp= {}", qryResp);
        }
        return respond(version, respStatus, isArray, qryResp);
    } catch (Exception e) {
        logger.error("Exception - queryAllottedResourceCustomization", e);
        CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
        return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(new GenericEntity<CatalogQueryException>(excResp) {
        }).build();
    }
}
Also used : ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) QueryAllottedResourceCustomization(org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) QueryAllottedResourceCustomization(org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization)

Example 85 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class CatalogDbClientTest method testGetServiceByModelName.

@Test
public void testGetServiceByModelName() {
    Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
    assertNotNull(service);
    assertNotNull(service.getModelVersion());
    assertNotNull(service.getModelInvariantUUID());
    assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
    assertEquals("NA", service.getServiceRole());
}
Also used : Service(org.onap.so.db.catalog.beans.Service) ExternalServiceToInternalService(org.onap.so.db.catalog.beans.ExternalServiceToInternalService) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)

Aggregations

Service (org.onap.so.db.catalog.beans.Service)171 Test (org.junit.Test)135 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)57 File (java.io.File)48 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)47 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)46 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)40 ArrayList (java.util.ArrayList)39 HashMap (java.util.HashMap)37 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)37 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)36 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)29 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)24 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)22 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)19 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)18 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)18 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)18 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)18 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)18