Search in sources :

Example 6 with RequestProcessingData

use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.

the class StackStatusHandlerTest method recordExists_Test.

@Test
public final void recordExists_Test() throws MsoException, IOException {
    RequestProcessingData requestProcessingData = new RequestProcessingData();
    requestProcessingData.setValue("testMe");
    String requestId = getRequestId();
    doReturn(requestProcessingData).when(requestDBClient).getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId, "stackName", "id");
    Stack latestStack = new Stack();
    latestStack.setId("id");
    latestStack.setStackName("stackName");
    latestStack.setStackStatus("CREATE_COMPLETE");
    latestStack.setStackStatusReason("Stack Finished");
    statusHandler.updateStackStatus(latestStack, requestId);
    Mockito.verify(requestDBClient, times(1)).updateRequestProcessingData(requestProcessingData);
    assertNotEquals("testMe", requestProcessingData.getValue());
}
Also used : RequestProcessingData(org.onap.so.db.request.beans.RequestProcessingData) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 7 with RequestProcessingData

use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.

the class StackStatusHandlerTest method record_Not_Exists_Test.

@Test
public final void record_Not_Exists_Test() throws MsoException, IOException {
    String requestId = getRequestId();
    ArgumentCaptor<RequestProcessingData> requestCaptor = ArgumentCaptor.forClass(RequestProcessingData.class);
    doReturn(null).when(requestDBClient).getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId, "stackName", "id");
    Stack latestStack = new Stack();
    latestStack.setId("id");
    latestStack.setStackName("stackName");
    latestStack.setStackStatus("CREATE_COMPLETE");
    latestStack.setStackStatusReason("Stack Finished");
    statusHandler.updateStackStatus(latestStack, requestId);
    Mockito.verify(requestDBClient, times(1)).saveRequestProcessingData(requestCaptor.capture());
    RequestProcessingData actualRequest = requestCaptor.getValue();
    assertEquals("id", actualRequest.getGroupingId());
    assertEquals("StackInformation", actualRequest.getTag());
    assertEquals("stackName", actualRequest.getName());
    assertNotNull(actualRequest.getValue());
}
Also used : RequestProcessingData(org.onap.so.db.request.beans.RequestProcessingData) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 8 with RequestProcessingData

use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.

the class RequestProcessingDataRequestDbQueryTest method RequestProcessingDataBySoRequestIdTest.

@Test
@Transactional
public void RequestProcessingDataBySoRequestIdTest() {
    String soRequestId = "00032ab7-na18-42e5-965d-8ea592502018";
    String tag = "pincFabricConfigRequest";
    RequestProcessingData firstEntry = new RequestProcessingData();
    RequestProcessingData secondEntry = new RequestProcessingData();
    List<RequestProcessingData> expectedList = new ArrayList<>();
    firstEntry.setSoRequestId(soRequestId);
    firstEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
    firstEntry.setName("configurationId");
    firstEntry.setValue("52234bc0-d6a6-41d4-a901-79015e4877e2");
    firstEntry.setTag(tag);
    secondEntry.setSoRequestId(soRequestId);
    secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
    secondEntry.setName("requestAction");
    secondEntry.setValue("assign");
    secondEntry.setTag(tag);
    expectedList.add(firstEntry);
    expectedList.add(secondEntry);
    List<RequestProcessingData> dataFound = client.getRequestProcessingDataBySoRequestId(soRequestId);
    // bean comparison with shazam fails serialization: Forgot to register a type adapter?
    assertEquals(dataFound.get(0).getSoRequestId(), firstEntry.getSoRequestId());
    assertEquals(dataFound.get(0).getGroupingId(), firstEntry.getGroupingId());
    assertEquals(dataFound.get(0).getName(), firstEntry.getName());
    assertEquals(dataFound.get(0).getValue(), firstEntry.getValue());
    assertEquals(dataFound.get(0).getTag(), firstEntry.getTag());
    assertEquals(dataFound.get(1).getSoRequestId(), secondEntry.getSoRequestId());
    assertEquals(dataFound.get(1).getGroupingId(), secondEntry.getGroupingId());
    assertEquals(dataFound.get(1).getName(), secondEntry.getName());
    assertEquals(dataFound.get(1).getValue(), secondEntry.getValue());
    assertEquals(dataFound.get(1).getTag(), secondEntry.getTag());
}
Also used : RequestProcessingData(org.onap.so.db.request.beans.RequestProcessingData) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(javax.transaction.Transactional)

Example 9 with RequestProcessingData

use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.

the class RequestsDbClientTest method getRequestProcessingDataBySoRequestIdAndName.

@Test
public void getRequestProcessingDataBySoRequestIdAndName() {
    RequestProcessingData requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestIdAndNameAndGrouping("00032ab7-na18-42e5-965d-8ea592502018", "requestAction", "7d2e8c07-4d10-456d-bddc-37abf38ca714");
    assertNotNull(requestProcessingData);
}
Also used : RequestProcessingData(org.onap.so.db.request.beans.RequestProcessingData) Test(org.junit.Test)

Example 10 with RequestProcessingData

use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.

the class BBInputSetupUtils method loadOriginalFlowExecutionPath.

public List<ExecuteBuildingBlock> loadOriginalFlowExecutionPath(String requestId) {
    if (requestId != null) {
        InfraActiveRequests request = loadInfraActiveRequestById(requestId);
        if (request.getOriginalRequestId() != null) {
            RequestProcessingData requestProcessingData = this.requestsDbClient.getRequestProcessingDataBySoRequestIdAndName(request.getOriginalRequestId(), PROCESSING_DATA_NAME_EXECUTION_FLOWS);
            try {
                ObjectMapper om = new ObjectMapper();
                TypeFactory typeFactory = om.getTypeFactory();
                om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                return om.readValue(requestProcessingData.getValue(), typeFactory.constructCollectionType(List.class, ExecuteBuildingBlock.class));
            } catch (Exception e) {
                logger.error(DATA_LOAD_ERROR, e);
                throw new RuntimeException("Error Loading Original Request Data", e);
            }
        } else {
            throw new RuntimeException("Original Request Id is null for record: " + requestId);
        }
    } else {
        throw new RuntimeException("Null Request Id Passed in");
    }
}
Also used : RequestProcessingData(org.onap.so.db.request.beans.RequestProcessingData) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) MultipleObjectsFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

RequestProcessingData (org.onap.so.db.request.beans.RequestProcessingData)15 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 URI (java.net.URI)4 Transactional (javax.transaction.Transactional)4 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)4 HttpEntity (org.springframework.http.HttpEntity)4 HttpHeaders (org.springframework.http.HttpHeaders)3 Stack (com.woorea.openstack.heat.model.Stack)2 Operation (io.swagger.v3.oas.annotations.Operation)2 IOException (java.io.IOException)2 List (java.util.List)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)2 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)2 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)2 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)2 ValidationException (org.onap.so.exceptions.ValidationException)2