aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap
diff options
context:
space:
mode:
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/aai/AAICreateResourcesTest.java8
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java23
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java38
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java18
6 files changed, 67 insertions, 26 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java
index 7d3d298c68..2e588b7078 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java
@@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.aai;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -38,7 +38,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
@@ -86,7 +86,7 @@ public class AAICreateResourcesTest {
public void createAAIProjectTest() {
doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), isA(Optional.class));
doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+
aaiCreateResources.createAAIProject(projectName, serviceInstanceId);
@@ -185,7 +185,7 @@ public class AAICreateResourcesTest {
@Test
public void getVnfInstanceExceptionTest() {
- doThrow(Exception.class).when(aaiResourcesClient).get(isA(AAIResourceUri.class));
+ doThrow(RuntimeException.class).when(aaiResourcesClient).get(isA(AAIResourceUri.class));
Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId);
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java
index 5808a330a3..a540a6d2cc 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java
@@ -20,7 +20,7 @@
package org.onap.so.bpmn.infrastructure.aai;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -77,7 +77,7 @@ public class AAIDeleteServiceInstanceTest {
doReturn("testProcessKey").when(execution).getVariable("testProcessKey");
doReturn("serviceInstanceId").when(execution).getVariable("serviceInstanceId");
- doThrow(Exception.class).when(aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ doThrow(RuntimeException.class).when(aaiResourcesClient).delete(isA(AAIResourceUri.class));
aaiDeleteServiceInstance.execute(execution);
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
index 3eb3bd8796..eeda355f80 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
@@ -20,9 +20,8 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -34,8 +33,10 @@ 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.Rule;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.onap.so.bpmn.core.WorkflowException;
@@ -45,6 +46,9 @@ public class CheckAaiForCorrelationIdDelegateTest {
public static class ConnectionOkTests {
private CheckAaiForCorrelationIdDelegate delegate;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
@Before
public void setUp() {
@@ -53,13 +57,14 @@ public class CheckAaiForCorrelationIdDelegateTest {
}
@Test
- public void shouldThrowExceptionWhenCorrelationIdIsNotSet() {
+ public void shouldThrowExceptionWhenCorrelationIdIsNotSet() throws Exception {
// given
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable(CORRELATION_ID)).thenReturn(null);
when(execution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
// when, then
- assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ delegate.execute(execution);
verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class));
}
@@ -89,6 +94,9 @@ public class CheckAaiForCorrelationIdDelegateTest {
public static class NoConnectionTests {
private CheckAaiForCorrelationIdDelegate delegate;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
@Before
public void setUp() {
@@ -97,13 +105,14 @@ public class CheckAaiForCorrelationIdDelegateTest {
}
@Test
- public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() {
+ public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() throws Exception {
// given
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY);
when(execution.getVariable("testProcessKey")).thenReturn("testProcessKey");
// when, then
- assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ delegate.execute(execution);
verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class));
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
index ddf33a1d77..7a31ae1a67 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
@@ -29,7 +29,7 @@ import org.junit.Test;
import org.mockito.InOrder;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
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 2e8fb4be78..ab8d206a62 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
@@ -20,8 +20,7 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -30,12 +29,17 @@ 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.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
public class PnfCheckInputsTest {
private static final String DEFAULT_TIMEOUT = "P1D";
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
private DelegateExecution mockDelegateExecution() {
new PnfCheckInputs(DEFAULT_TIMEOUT);
DelegateExecution delegateExecution = mock(DelegateExecution.class);
@@ -49,7 +53,19 @@ public class PnfCheckInputsTest {
PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
DelegateExecution delegateExecution = mockDelegateExecution();
// when, then
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ testedObject.execute(delegateExecution);
+ }
+
+ @Test
+ public void shouldThrowException_whenPnfIdIsEmptyString() throws Exception {
+ // given
+ PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
+ DelegateExecution delegateExecution = mockDelegateExecution();
+ when(delegateExecution.getVariable(CORRELATION_ID)).thenReturn("");
+ // when, then
+ expectedException.expect(BpmnError.class);
+ testedObject.execute(delegateExecution);
}
private DelegateExecution mockDelegateExecutionWithCorrelationId() {
@@ -65,7 +81,19 @@ public class PnfCheckInputsTest {
PnfCheckInputs testedObject = new PnfCheckInputs(null);
DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
// when, then
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ testedObject.execute(delegateExecution);
+ }
+
+ @Test
+ public void shouldThrowException_whenTimeoutIsEmptyStringAndDefaultIsNotDefined() throws Exception {
+ // given
+ PnfCheckInputs testedObject = new PnfCheckInputs(null);
+ DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
+ when(delegateExecution.getVariable(TIMEOUT_FOR_NOTIFICATION)).thenReturn("");
+ // when, then
+ expectedException.expect(BpmnError.class);
+ testedObject.execute(delegateExecution);
}
@Test
@@ -78,4 +106,4 @@ public class PnfCheckInputsTest {
// then
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 1b0169d6d3..33b4689629 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
@@ -22,8 +22,9 @@
package org.onap.so.bpmn.infrastructure.pnf.dmaap;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
+
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -49,7 +50,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.PnfEventReadyDmaapClient.DmaapTopicListenerThread;
import org.springframework.core.env.Environment;
@RunWith(MockitoJUnitRunner.class)
@@ -113,10 +114,13 @@ public class PnfEventReadyDmaapClientTest {
thenReturn(createResponse(String.format(JSON_EXAMPLE_WITH_CORRELATION_ID, CORRELATION_ID)));
testedObjectInnerClassThread.run();
ArgumentCaptor<HttpGet> captor1 = ArgumentCaptor.forClass(HttpGet.class);
- verify(httpClientMock).execute(captor1.capture());
- assertThat(captor1.getValue().getURI()).hasHost(HOST).hasPort(PORT).hasScheme(PROTOCOL)
- .hasPath(
- "/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + "");
+ verify(httpClientMock).execute(captor1.capture());
+
+ assertEquals(captor1.getValue().getURI().getHost(),HOST);
+ assertEquals(captor1.getValue().getURI().getPort(),PORT);
+ assertEquals(captor1.getValue().getURI().getScheme(),PROTOCOL);
+ assertEquals(captor1.getValue().getURI().getPath(),"/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + "");
+
verify(threadMockToNotifyCamundaFlow).run();
verify(executorMock).shutdown();
}