diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src')
2 files changed, 37 insertions, 9 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index 7a967d3159..750b7ace35 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2019 TechMahindra * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -130,13 +132,15 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { //CDSProcessingListener cdsProcessingListener = new AbstractCDSProcessingBBUtils(); - CDSProcessingClient cdsClient = new CDSProcessingClient(this); - CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput); - + CDSProcessingClient cdsClient = null; + CountDownLatch countDownLatch; try { + cdsClient = new CDSProcessingClient(this); + countDownLatch = cdsClient.sendRequest(executionServiceInput); countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS); } catch (InterruptedException ex) { logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex); + Thread.currentThread().interrupt(); } finally { cdsClient.close(); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java index b2812d9bfb..161f879716 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java @@ -20,28 +20,36 @@ package org.onap.so.client.cds; -import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.exception.ExceptionBuilder; -@RunWith(JUnit4.class) +@RunWith(MockitoJUnitRunner.class) public class AbstractCDSProcessingBBUtilsTest { @InjectMocks private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils = new AbstractCDSProcessingBBUtils(); @InjectMocks AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean(); + @Mock + ExceptionBuilder exceptionUtil; - @Test - public void preProcessRequestTest() throws Exception { + @Before + public void init(){ String requestObject = "{\"config-assign-request\":{\"resolution-key\":\"resolutionKey\", \"config-assign-properties\":{\"service-instance-id\":\"serviceInstanceId\", \"vnf-id\":\"vnfId\", \"vnf-name\":\"vnfName\", \"service-model-uuid\":\"serviceModelUuid\", \"vnf-customization-uuid\":\"vnfCustomizationUuid\",\"Instance1\":\"Instance1Value\",\"Instance2\":\"Instance2Value\",\"Param3\":\"Param3Value\"}}}"; String blueprintName = "blueprintName"; String blueprintVersion = "blueprintVersion"; @@ -59,12 +67,28 @@ public class AbstractCDSProcessingBBUtilsTest { abstractCDSPropertiesBean.setRequestId(requestId); abstractCDSPropertiesBean.setRequestObject(requestObject); abstractCDSPropertiesBean.setSubRequestId(subRequestId); + } + + @Test + public void preProcessRequestTest() throws Exception { DelegateExecution execution = mock(DelegateExecution.class); when(execution.getVariable("executionObject")).thenReturn(abstractCDSPropertiesBean); abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution); - assertTrue(true); + verify(exceptionUtil, times(0)) + .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(Exception.class)); + } + + @Test + public void sendRequestToCDSClientTest() { + + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable("executionServiceInput")).thenReturn(abstractCDSPropertiesBean); + abstractCDSProcessingBBUtils.sendRequestToCDSClient(execution); + verify(exceptionUtil, times(1)) + .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(Exception.class)); + } } |