aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorbiniek <lukasz.biniek@nokia.com>2018-08-02 13:08:42 +0200
committerbiniek <lukasz.biniek@nokia.com>2018-08-02 13:08:42 +0200
commitd1930077521716bcea3f7a7bdd58dd820d7f68dd (patch)
treebe9d5750e1fcd400f9dae37683e864ed759a6a57 /bpmn
parenta1e0b7b9b37c50eaf942a62d8b2487efcfd33c29 (diff)
Removed references to spring in tests
Change-Id: I2b477295fc4fbf0d80a4eabb0604b49e8db649c0 Issue-ID: SO-583 Signed-off-by: biniek <lukasz.biniek@nokia.com>
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java24
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java24
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java4
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java38
4 files changed, 43 insertions, 47 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java
index f5d212f61c..4282b0f2bb 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java
@@ -20,35 +20,27 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Test;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = {CancelDmaapSubscription.class, DmaapClientTestImpl.class})
public class CancelDmaapSubscriptionTest {
- @Autowired
- public CancelDmaapSubscription delegate;
-
- @Autowired
- private DmaapClientTestImpl dmaapClientTest;
-
@Test
public void shouldCancelSubscription() throws Exception {
// given
+ CancelDmaapSubscription delegate = new CancelDmaapSubscription();
+ DmaapClientTestImpl dmaapClientTest = new DmaapClientTestImpl();
+ delegate.setDmaapClient(dmaapClientTest);
DelegateExecution delegateExecution = mock(DelegateExecution.class);
when(delegateExecution.getVariable(eq(ExecutionVariableNames.CORRELATION_ID))).thenReturn("testCorrelationId");
when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
- dmaapClientTest.registerForUpdate("testCorrelationId", () -> {});
+ dmaapClientTest.registerForUpdate("testCorrelationId", () -> {
+ });
// when
delegate.execute(delegateExecution);
// then
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
index 301e5d9f6d..627e57bfb8 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
@@ -36,6 +36,7 @@ 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;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
@@ -47,15 +48,18 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(Enclosed.class)
public class CheckAaiForCorrelationIdDelegateTest {
- @RunWith(SpringRunner.class)
- @SpringBootTest(classes = {CheckAaiForCorrelationIdDelegate.class, AaiConnectionTestImpl.class})
public static class ConnectionOkTests {
- @Autowired
private CheckAaiForCorrelationIdDelegate delegate;
+ @Before
+ public void setUp() {
+ delegate = new CheckAaiForCorrelationIdDelegate();
+ delegate.setAaiConnection(new AaiConnectionTestImpl());
+ }
+
@Test
- public void shouldThrowExceptionWhenCorrelationIdIsNotSet() throws Exception {
+ public void shouldThrowExceptionWhenCorrelationIdIsNotSet() {
// given
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable(CORRELATION_ID)).thenReturn(null);
@@ -110,16 +114,18 @@ public class CheckAaiForCorrelationIdDelegateTest {
}
}
-
- @RunWith(SpringRunner.class)
- @SpringBootTest(classes = {CheckAaiForCorrelationIdDelegate.class, AaiConnectionThrowingException.class})
public static class NoConnectionTests {
- @Autowired
private CheckAaiForCorrelationIdDelegate delegate;
+ @Before
+ public void setUp() {
+ delegate = new CheckAaiForCorrelationIdDelegate();
+ delegate.setAaiConnection(new AaiConnectionThrowingException());
+ }
+
@Test
- public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() throws Exception {
+ public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() {
// given
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY_NO_IP);
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
index 9c8f19f102..f2a4205ebd 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
@@ -53,6 +53,10 @@ public class DmaapClientTestImpl implements DmaapClient {
return informConsumer;
}
+ public void sendMessage() {
+ informConsumer.run();
+ }
+
public boolean haveRegisteredConsumer() {
return correlationId != null;
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
index 168cd69436..ddf33a1d77 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
@@ -20,33 +20,30 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.ProcessEngineServices;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.InOrder;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = {InformDmaapClient.class, DmaapClientTestImpl.class})
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
+
public class InformDmaapClientTest {
+ @Before
+ public void setUp() throws Exception {
+ informDmaapClient = new InformDmaapClient();
+ dmaapClientTest = new DmaapClientTestImpl();
+ informDmaapClient.setDmaapClient(dmaapClientTest);
+ delegateExecution = mockDelegateExecution();
+ }
- @Autowired
private InformDmaapClient informDmaapClient;
- @Autowired
private DmaapClientTestImpl dmaapClientTest;
private DelegateExecution delegateExecution;
@@ -55,8 +52,6 @@ public class InformDmaapClientTest {
@Test
public void shouldSendListenerToDmaapClient() throws Exception {
- // given
- mockDelegateExecution();
// when
informDmaapClient.execute(delegateExecution);
// then
@@ -67,8 +62,6 @@ public class InformDmaapClientTest {
@Test
public void shouldSendListenerToDmaapClientAndSendMessageToCamunda() throws Exception {
- // given
- mockDelegateExecution();
// when
informDmaapClient.execute(delegateExecution);
dmaapClientTest.getInformConsumer().run();
@@ -79,8 +72,8 @@ public class InformDmaapClientTest {
inOrder.verify(messageCorrelationBuilder).correlateWithResult();
}
- private void mockDelegateExecution() {
- delegateExecution = mock(DelegateExecution.class);
+ private DelegateExecution mockDelegateExecution() {
+ DelegateExecution delegateExecution = mock(DelegateExecution.class);
when(delegateExecution.getVariable(eq(ExecutionVariableNames.CORRELATION_ID))).thenReturn("testCorrelationId");
when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
@@ -90,5 +83,6 @@ public class InformDmaapClientTest {
messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
when(runtimeService.createMessageCorrelation(any())).thenReturn(messageCorrelationBuilder);
when(messageCorrelationBuilder.processInstanceBusinessKey(any())).thenReturn(messageCorrelationBuilder);
+ return delegateExecution;
}
} \ No newline at end of file