diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2018-10-04 16:15:13 +0200 |
---|---|---|
committer | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2018-10-24 12:04:36 +0200 |
commit | 6c2c8a66fade016f74b51bdfea3ba04494530b97 (patch) | |
tree | 4ba0fda25e5cb0cdc529d178f9b38102db7bbe17 /bpmn/so-bpmn-infrastructure-common/src/test/java/org | |
parent | 0116cbfe7836b05381fe5632e0e536a625789b31 (diff) |
Pnf Spring Environment correction
Change-Id: Ic9d83e2919bd1f947fdca07d8982bd5e794c9dbe
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')
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); |