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));
}
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;
}
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();
}
}
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();
}
}
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());
}
Aggregations