aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-10-04 16:15:13 +0200
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-10-22 08:58:35 +0000
commit60f8f5342f1fba49373699c1466e6ca06d1adc34 (patch)
tree34320ee7a22af1133138abfbbdc601a9883f9d62 /bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap
parent325d4e28475c88066f8c33415c283ff9ac356a1c (diff)
Pnf Spring Environment correction
Change-Id: Ifd33f4ba0f62b15605ea21eb3d9256c3e70a1d2f Issue-ID: SO-1102 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java29
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java20
2 files changed, 23 insertions, 26 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
index aab289fd90..2e8fb4be78 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
@@ -30,55 +30,52 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.junit.Before;
import org.junit.Test;
public class PnfCheckInputsTest {
- private PnfCheckInputs delegate;
-
- @Before
- public void setUp() throws Exception {
- delegate = new PnfCheckInputs();
- }
+ private static final String DEFAULT_TIMEOUT = "P1D";
private DelegateExecution mockDelegateExecution() {
+ new PnfCheckInputs(DEFAULT_TIMEOUT);
DelegateExecution delegateExecution = mock(DelegateExecution.class);
when(delegateExecution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
return delegateExecution;
}
@Test
- public void shouldThrowException_whenPnfIdNotSet() throws Exception {
+ public void shouldThrowException_whenPnfIdNotSet() {
// given
+ PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
DelegateExecution delegateExecution = mockDelegateExecution();
// when, then
- assertThatThrownBy(() -> delegate.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
}
private DelegateExecution mockDelegateExecutionWithCorrelationId() {
+ new PnfCheckInputs(DEFAULT_TIMEOUT);
DelegateExecution delegateExecution = mockDelegateExecution();
when(delegateExecution.getVariable(CORRELATION_ID)).thenReturn("testCorrelationId");
return delegateExecution;
}
@Test
- public void shouldThrowException_whenTimeoutIsNotSetAndDefaultIsNotDefined() throws Exception {
+ public void shouldThrowException_whenTimeoutIsNotSetAndDefaultIsNotDefined() {
// given
+ PnfCheckInputs testedObject = new PnfCheckInputs(null);
DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
// when, then
- assertThatThrownBy(() -> delegate.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
}
@Test
- public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() throws Exception {
+ public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() {
// given
- String defaultTimeout = "T1D";
- delegate.setDefaultTimeout(defaultTimeout);
+ PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
// when
- delegate.execute(delegateExecution);
+ testedObject.execute(delegateExecution);
// then
- verify(delegateExecution).setVariable(eq(TIMEOUT_FOR_NOTIFICATION), eq(defaultTimeout));
+ verify(delegateExecution).setVariable(eq(TIMEOUT_FOR_NOTIFICATION), eq(DEFAULT_TIMEOUT));
}
} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
index 9ae7ad9bdc..aab01c0a3e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
@@ -33,7 +33,6 @@ import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import org.apache.http.HttpEntity;
@@ -47,7 +46,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.PnfEventReadyDmaapClient.DmaapTopicListenerThread;
@@ -81,6 +79,8 @@ public class PnfEventReadyDmaapClientTest {
private static final String EVENT_TOPIC_TEST = "eventTopicTest";
private static final String CONSUMER_ID = "consumerTestId";
private static final String CONSUMER_GROUP = "consumerGroupTest";
+ private static final int TOPIC_LISTENER_DELAY_IN_SECONDS = 5;
+
@Mock
private Environment env;
private PnfEventReadyDmaapClient testedObject;
@@ -92,16 +92,16 @@ public class PnfEventReadyDmaapClientTest {
@Before
public void init() throws NoSuchFieldException, IllegalAccessException {
- testedObject = new PnfEventReadyDmaapClient(env);
when(env.getProperty(eq("pnf.dmaap.port"), eq(Integer.class))).thenReturn(PORT);
when(env.getProperty(eq("pnf.dmaap.host"))).thenReturn(HOST);
- testedObject.setDmaapProtocol(PROTOCOL);
- testedObject.setDmaapUriPathPrefix(URI_PATH_PREFIX);
- testedObject.setDmaapTopicName(EVENT_TOPIC_TEST);
- testedObject.setConsumerId(CONSUMER_ID);
- testedObject.setConsumerGroup(CONSUMER_GROUP);
- testedObject.setDmaapClientDelayInSeconds(1);
- testedObject.init();
+ when(env.getProperty(eq("pnf.dmaap.protocol"))).thenReturn(PROTOCOL);
+ when(env.getProperty(eq("pnf.dmaap.uriPathPrefix"))).thenReturn(URI_PATH_PREFIX);
+ when(env.getProperty(eq("pnf.dmaap.topicName"))).thenReturn(EVENT_TOPIC_TEST);
+ when(env.getProperty(eq("pnf.dmaap.consumerId"))).thenReturn(CONSUMER_ID);
+ when(env.getProperty(eq("pnf.dmaap.consumerGroup"))).thenReturn(CONSUMER_GROUP);
+ when(env.getProperty(eq("pnf.dmaap.topicListenerDelayInSeconds"), eq(Integer.class)))
+ .thenReturn(TOPIC_LISTENER_DELAY_IN_SECONDS);
+ testedObject = new PnfEventReadyDmaapClient(env);
testedObjectInnerClassThread = testedObject.new DmaapTopicListenerThread();
httpClientMock = mock(HttpClient.class);
threadMockToNotifyCamundaFlow = mock(Runnable.class);