use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.
the class InfraActiveRequestsRepositoryCustomControllerTest method checkInstanceNameDuplicateViaTestNotFound.
@Test
public void checkInstanceNameDuplicateViaTestNotFound() {
Map<String, String> requestMap = new HashMap<>();
requestMap.put("operationalEnvironmentId", "NotFoundOperationalEnvId");
InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) requestMap, null, infraActiveRequests.getRequestScope());
HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() {
});
infraActiveRequestsResponse = response.getBody();
assertEquals(200, response.getStatusCodeValue());
assertEquals(null, response.getBody());
}
use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.
the class InfraActiveRequestsRepositoryCustomControllerTest method checkInstanceNameDuplicateTestNotFound.
@Test
public void checkInstanceNameDuplicateTestNotFound() {
String instanceNameDuplicateCheckRequest = "{\r\n\t \"instanceName\":\"TestNotFoundInstanceName\",\r\n\t \"requestScope\":\"testasdfasdfasdf\"\r\n}";
HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() {
});
assertEquals(200, response.getStatusCodeValue());
assertEquals(null, response.getBody());
}
use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.
the class MsoRequestsDbAdapterImpl method updateInfraRequest.
@Transactional
@Override
public void updateInfraRequest(String requestId, String lastModifiedBy, String statusMessage, String responseBody, RequestStatusType requestStatus, String progress, String vnfOutputs, String serviceInstanceId, String networkId, String vnfId, String vfModuleId, String volumeGroupId, String serviceInstanceName, String configurationId, String configurationName, String vfModuleName) throws MsoRequestsDbException {
try {
InfraActiveRequests request = infraActive.findOneByRequestId(requestId);
if (request == null) {
String error = "Entity not found. Unable to retrieve MSO Infra Requests DB for Request ID " + requestId;
throw new MsoRequestsDbException(error);
}
if (statusMessage != null) {
request.setStatusMessage(statusMessage);
}
if (responseBody != null) {
request.setResponseBody(responseBody);
}
if (requestStatus != null) {
request.setRequestStatus(requestStatus.toString());
}
if (progress != null) {
setProgress(progress, request);
}
if (vnfOutputs != null) {
request.setVnfOutputs(vnfOutputs);
}
if (serviceInstanceId != null) {
request.setServiceInstanceId(serviceInstanceId);
}
if (networkId != null) {
request.setNetworkId(networkId);
}
if (vnfId != null) {
request.setVnfId(vnfId);
}
if (vfModuleId != null) {
request.setVfModuleId(vfModuleId);
}
if (volumeGroupId != null) {
request.setVolumeGroupId(volumeGroupId);
}
if (serviceInstanceName != null) {
request.setServiceInstanceName(serviceInstanceName);
}
if (vfModuleName != null) {
request.setVfModuleName(vfModuleName);
}
if (configurationId != null) {
request.setConfigurationId(configurationId);
}
if (configurationName != null) {
request.setConfigurationName(configurationName);
}
if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) {
Timestamp nowTimeStamp = new Timestamp(System.currentTimeMillis());
request.setEndTime(nowTimeStamp);
}
request.setLastModifiedBy(lastModifiedBy);
infraActive.save(request);
} catch (Exception e) {
String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId;
logger.error(error, e);
throw new MsoRequestsDbException(error, ErrorCode.BusinessProcessError, e);
}
}
use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.
the class MSORequestDBImplTest method getByRequestId.
@Test
public void getByRequestId() throws MsoRequestsDbException {
InfraActiveRequests testRequest = setupTestEntities();
// Given
String requestId = "00032ab7-3fb3-42e5-965d-8ea592502017";
// When
InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(requestId);
if (infraRequest == null)
fail("Null infraRequest");
// Then
assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime"));
}
use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.
the class MSORequestDBImplTest method updateInfraRequestNulls.
@Test
public void updateInfraRequestNulls() throws MsoRequestsDbException {
InfraActiveRequests testRequest = setupTestEntities();
// Given
String requestId = "00032ab7-3fb3-42e5-965d-8ea592502017";
// When
dbAdapter.updateInfraRequest(testRequest.getRequestId(), testRequest.getLastModifiedBy(), null, null, null, null, null, null, null, null, null, null, null, null, null, null);
InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(requestId);
// Then
assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime"));
}
Aggregations