10/31: merge casablanca to master
[so.git] / bpmn / so-bpmn-infrastructure-common / src / test / java / org / onap / so / bpmn / infrastructure / pnf / delegate / PnfCheckInputsTest.java
index 2e8fb4b..1f3ecce 100644 (file)
@@ -52,6 +52,16 @@ public class PnfCheckInputsTest {
         assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
     }
 
+    @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
+        assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+    }
+
     private DelegateExecution mockDelegateExecutionWithCorrelationId() {
         new PnfCheckInputs(DEFAULT_TIMEOUT);
         DelegateExecution delegateExecution = mockDelegateExecution();
@@ -68,6 +78,16 @@ public class PnfCheckInputsTest {
         assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
     }
 
+    @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
+        assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+    }
+
     @Test
     public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() {
         // given
@@ -78,4 +98,4 @@ public class PnfCheckInputsTest {
         // then
         verify(delegateExecution).setVariable(eq(TIMEOUT_FOR_NOTIFICATION), eq(DEFAULT_TIMEOUT));
     }
-}
\ No newline at end of file
+}