aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp
diff options
context:
space:
mode:
authorbiniek <lukasz.biniek@nokia.com>2018-05-17 12:11:50 +0200
committerbiniek <lukasz.biniek@nokia.com>2018-05-17 12:21:13 +0200
commit59e4171c755943b1ac7e16d80980e8736045e5aa (patch)
tree7a403a18497e70d86edbd734d686c22a242d01c5 /bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp
parentc82216b0be5e2fab57031056d386a192b6abbce2 (diff)
Added checking input variables in pnf-pnp
Change-Id: I1a4f4b9704385a17995e76d4b87484c2f588b889 Issue-ID: SO-506 Signed-off-by: biniek <lukasz.biniek@nokia.com>
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp')
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
new file mode 100644
index 0000000000..1799e7fcbc
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.infrastructure.pnf.delegate;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
+import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
+
+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 DelegateExecution mockDelegateExecution() {
+ DelegateExecution delegateExecution = mock(DelegateExecution.class);
+ when(delegateExecution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
+ return delegateExecution;
+ }
+
+ @Test
+ public void shouldThrowException_whenPnfIdNotSet() throws Exception {
+ // given
+ DelegateExecution delegateExecution = mockDelegateExecution();
+ // when, then
+ assertThatThrownBy(() -> delegate.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ }
+
+ private DelegateExecution mockDelegateExecutionWithCorrelationId() {
+ DelegateExecution delegateExecution = mockDelegateExecution();
+ when(delegateExecution.getVariable(CORRELATION_ID)).thenReturn("testCorrelationId");
+ return delegateExecution;
+ }
+
+ @Test
+ public void shouldThrowException_whenTimeoutIsNotSetAndDefaultIsNotDefined() throws Exception {
+ // given
+ DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
+ // when, then
+ assertThatThrownBy(() -> delegate.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ }
+
+ @Test
+ public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() throws Exception {
+ // given
+ String defaultTimeout = "T1D";
+ delegate.setDefaultTimeout(defaultTimeout);
+ DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
+ // when
+ delegate.execute(delegateExecution);
+ // then
+ verify(delegateExecution).setVariable(eq(TIMEOUT_FOR_NOTIFICATION), eq(defaultTimeout));
+ }
+} \ No newline at end of file