Search in sources :

Example 11 with ExecutionServiceInput

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.

the class ServiceLevelUpgradeTest method workflow_validInput_expectedOutput.

@Test
public void workflow_validInput_expectedOutput() throws InterruptedException {
    mockCatalogDb();
    mockRequestDb();
    mockAai();
    grpcNettyServer.resetList();
    final String msoRequestId = UUID.randomUUID().toString();
    executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId);
    final String testBusinessKey = UUID.randomUUID().toString();
    logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey);
    ProcessInstance pi = runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables);
    int waitCount = 10;
    while (!isProcessInstanceEnded() && waitCount >= 0) {
        Thread.sleep(WORKFLOW_WAIT_TIME);
        waitCount--;
    }
    // Layout is to reflect the bpmn visual layout
    assertThat(pi).isEnded().hasPassedInOrder("Event_02mc8tr", "Activity_18vue7u", "Activity_09bqns0", "Activity_02vp5np", "Activity_0n17xou", "Gateway_1nr51kr", "Activity_0snmatn", "Activity_0e6w886", "Activity_1q4o9fx", "Gateway_02fectw", "Activity_1hp67qz", "Gateway_18ch73t", "Activity_0ft7fa2", "Gateway_1vq11i7", "Activity_0o2rrag", "Activity_1n4rk7m", "Activity_1lz38px", "Event_12983th");
    List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
    assertEquals(10, detailedMessages.size());
    int count = 0;
    String action = "";
    try {
        for (ExecutionServiceInput eSI : detailedMessages) {
            action = actionNames[count];
            if (action.equals(eSI.getActionIdentifiers().getActionName()) && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) {
                checkWithActionName(eSI, action, pnfNames[count]);
                count++;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("GenericPnfSoftwareUpgrade request exception", e);
    }
    assertTrue(count == actionNames.length);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) IOException(java.io.IOException) BaseBPMNTest(org.onap.so.BaseBPMNTest) Test(org.junit.Test)

Example 12 with ExecutionServiceInput

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.

the class CDSProcessingClientTest method testSendMessage.

@Test
public void testSendMessage() throws Exception {
    ExecutionServiceInput fakeRequest1 = ExecutionServiceInput.newBuilder().setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("request1").build()).build();
    ExecutionServiceOutput fakeResponse1 = ExecutionServiceOutput.newBuilder().setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("response1").build()).build();
    ExecutionServiceOutput fakeResponse2 = ExecutionServiceOutput.newBuilder().setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("response2").build()).build();
    CountDownLatch finishLatch = client.sendRequest(fakeRequest1);
    // request message sent and delivered for one time
    assertTrue(allRequestsDelivered.await(1, TimeUnit.SECONDS));
    assertEquals(Collections.singletonList("request1"), messagesDelivered);
    // Let the server send out two simple response messages
    // and verify that the client receives them.
    responseObserverRef.get().onNext(fakeResponse1);
    verify(listener).onMessage(fakeResponse1);
    responseObserverRef.get().onNext(fakeResponse2);
    verify(listener).onMessage(fakeResponse2);
    // let server complete.
    responseObserverRef.get().onCompleted();
    assertTrue(finishLatch.await(1, TimeUnit.SECONDS));
}
Also used : ExecutionServiceOutput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput) CountDownLatch(java.util.concurrent.CountDownLatch) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) Test(org.junit.Test)

Example 13 with ExecutionServiceInput

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.

the class CDSProcessingClientTest method setUp.

@Before
public void setUp() throws Exception {
    String serverName = InProcessServerBuilder.generateName();
    grpcCleanup.register(InProcessServerBuilder.forName(serverName).fallbackHandlerRegistry(serviceRegistry).directExecutor().build().start());
    handler = new CDSProcessingHandler(listener);
    client = new CDSProcessingClient(InProcessChannelBuilder.forName(serverName).directExecutor().build(), handler);
    final BluePrintProcessingServiceImplBase routeChatImpl = new BluePrintProcessingServiceImplBase() {

        @Override
        public StreamObserver<ExecutionServiceInput> process(StreamObserver<ExecutionServiceOutput> responseObserver) {
            responseObserverRef.set(responseObserver);
            StreamObserver<ExecutionServiceInput> requestObserver = new StreamObserver<ExecutionServiceInput>() {

                @Override
                public void onNext(ExecutionServiceInput message) {
                    messagesDelivered.add(message.getActionIdentifiers().getActionName());
                }

                @Override
                public void onError(Throwable t) {
                }

                @Override
                public void onCompleted() {
                    allRequestsDelivered.countDown();
                }
            };
            return requestObserver;
        }
    };
    serviceRegistry.addService(routeChatImpl);
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) BluePrintProcessingServiceImplBase(org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) Before(org.junit.Before)

Example 14 with ExecutionServiceInput

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.

the class CDSProcessingClientTest method testSendMessageFail.

@Test
public void testSendMessageFail() throws Exception {
    ExecutionServiceInput fakeRequest1 = ExecutionServiceInput.newBuilder().setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("request1").build()).build();
    CountDownLatch finishLatch = client.sendRequest(fakeRequest1);
    responseObserverRef.get().onError(new Throwable("fail test"));
    verify(listener).onError(any(Throwable.class));
    assertTrue(finishLatch.await(1, TimeUnit.SECONDS));
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) Test(org.junit.Test)

Aggregations

ExecutionServiceInput (org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput)14 Test (org.junit.Test)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 BaseBPMNTest (org.onap.so.BaseBPMNTest)5 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)4 IOException (java.io.IOException)4 PreconditionFailedException (org.onap.so.client.PreconditionFailedException)4 BadResponseException (org.onap.so.client.exception.BadResponseException)4 StreamObserver (io.grpc.stub.StreamObserver)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ExecutionServiceOutput (org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput)3 BluePrintProcessingServiceImplBase (org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase)2 AbstractCDSPropertiesBean (org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)2 PostConstruct (javax.annotation.PostConstruct)1 Before (org.junit.Before)1 ActionIdentifiers (org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers)1 BluePrintProcessingServiceStub (org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub)1