aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/test')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy118
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java (renamed from bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java)18
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java43
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java123
4 files changed, 241 insertions, 61 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy
new file mode 100644
index 0000000000..9ee995e036
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy
@@ -0,0 +1,118 @@
+package org.onap.so.bpmn.infrastructure.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Rule
+import org.junit.Test
+import org.mockito.MockitoAnnotations
+import org.onap.so.bpmn.common.recipe.ResourceInput
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
+
+import static org.mockito.Mockito.*
+/**
+ * Copyright 2018 ZTE Corporation.
+ *
+ * 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.
+ */
+class CreateSDNCNetworkResourceTest extends GroovyTestCase {
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090)
+
+ String Prefix = "CRESDNCRES_"
+ String sdncAdapterWorkflowResponse
+
+ void init() {
+ MockitoAnnotations.initMocks(this)
+ sdncAdapterWorkflowResponse = """
+ <sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
+ <sdncadapterworkflow:response-data>
+ <CallbackHeader>
+ <RequestId>726420e0-3962-4bf2-9655-aac82fc7055e</RequestId>
+ <ResponseCode>200</ResponseCode>
+ <ResponseMessage>OK</ResponseMessage>
+ </CallbackHeader>
+ <RequestData xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">&lt;output xmlns="org:onap:sdnc:northbound:generic-resource"&gt;&lt;response-message&gt;&lt;/response-message&gt;&lt;ack-final-indicator&gt;Y&lt;/ack-final-indicator&gt;&lt;svc-request-id&gt;726420e0-3962-4bf2-9655-aac82fc7055e&lt;/svc-request-id&gt;&lt;network-response-information&gt;&lt;instance-id&gt;9fa732b8-2c54-4eba-926d-464d18c07474&lt;/instance-id&gt;&lt;object-path&gt;restconf/config/GENERIC-RESOURCE-API:services/service/a99deffb-12e2-4656-8cf2-2d2a996d0f52/service-data/networks/network/9fa732b8-2c54-4eba-926d-464d18c07474/network-data/&lt;/object-path&gt;&lt;/network-response-information&gt;&lt;response-code&gt;200&lt;/response-code&gt;&lt;service-response-information&gt;&lt;instance-id&gt;a99deffb-12e2-4656-8cf2-2d2a996d0f52&lt;/instance-id&gt;&lt;/service-response-information&gt;&lt;/output&gt;</RequestData>
+ </sdncadapterworkflow:response-data>
+ </sdncadapterworkflow:SDNCAdapterWorkflowResponse>"""
+
+ }
+
+ private ResourceInput getResInputObj(String modelName) {
+ String resourceInput = "{\n" +
+ "\t\"resourceInstanceName\": \"SotnFc-wan-connection_wanconnection-37\",\n" +
+ "\t\"resourceInstanceDes\": null,\n" +
+ "\t\"globalSubscriberId\": \"sdwandemo\",\n" +
+ "\t\"serviceType\": \"CCVPN\",\n" +
+ "\t\"operationId\": \"df3387b5-4fbf-41bd-82a0-13a955ac178a\",\n" +
+ "\t\"serviceModelInfo\": {\n" +
+ "\t\t\"modelName\": \"WanConnectionSvc03\",\n" +
+ "\t\t\"modelUuid\": \"198b066c-0771-4157-9594-1824adfdda7e\",\n" +
+ "\t\t\"modelInvariantUuid\": \"43fb5165-7d03-4009-8951-a8f45d3f0148\",\n" +
+ "\t\t\"modelVersion\": \"1.0\",\n" +
+ "\t\t\"modelCustomizationUuid\": \"\",\n" +
+ "\t\t\"modelCustomizationName\": \"\",\n" +
+ "\t\t\"modelInstanceName\": \"\",\n" +
+ "\t\t\"modelType\": \"\"\n" +
+ "\t},\n" +
+ "\t\"resourceModelInfo\": {\n" +
+ "\t\t\"modelName\": \"" +
+ modelName +
+ "\",\n" +
+ "\t\t\"modelUuid\": \"6a0bf88b-343c-415b-88c1-6f73702452c4\",\n" +
+ "\t\t\"modelInvariantUuid\": \"50bc3415-2e01-4e50-a9e1-ec9584599bb3\",\n" +
+ "\t\t\"modelCustomizationUuid\": \"b205d620-84bd-4058-afa0-e3aeee8bb712\",\n" +
+ "\t\t\"modelCustomizationName\": \"\",\n" +
+ "\t\t\"modelInstanceName\": \"SotnFc-wan-connection 0\",\n" +
+ "\t\t\"modelType\": \"\"\n" +
+ "\t},\n" +
+ "\t\"resourceInstancenUuid\": null,\n" +
+ "\t\"resourceParameters\": \"{\\n\\\"locationConstraints\\\":[],\\n\\\"requestInputs\\\":{\\\"sotnfcspecwanconnection0_route-objective-function\\\":null,\\\"sotnfcspecwanconnection0_colorAware\\\":null,\\\"3rdctlspecwanconnection0_thirdPartyAdaptorRpc\\\":null,\\\"sotnfcspecwanconnection0_couplingFlag\\\":null,\\\"sotnfcspecwanconnection0_pbs\\\":null,\\\"3rdctlspecwanconnection0_thirdPartySdncId\\\":null,\\\"sotnfcspecwanconnection0_cbs\\\":null,\\\"3rdctlspecwanconnection0_thirdpartySdncName\\\":null,\\\"sotnfcspecwanconnection0_total-size\\\":null,\\\"3rdctlspecwanconnection0_templateFileName\\\":\\\"sotn_create_zte_template.json\\\",\\\"fcwanconnection0_type\\\":null,\\\"sotnfcspecwanconnection0_cir\\\":null,\\\"fcwanconnection0_uuid\\\":null,\\\"sotnfcspecwanconnection0_diversity-policy\\\":null,\\\"nf_naming\\\":true,\\\"multi_stage_design\\\":false,\\\"availability_zone_max_count\\\":1,\\\"3rdctlspecwanconnection0_restapiUrl\\\":\\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\\"max_instances\\\":null,\\\"sotnfcspecwanconnection0_reroute\\\":null,\\\"fcwanconnection0_name\\\":null,\\\"sotnfcspecwanconnection0_dualLink\\\":null,\\\"min_instances\\\":null,\\\"sotnfcspecwanconnection0_pir\\\":null,\\\"sotnfcspecwanconnection0_service-type\\\":null}\\n}\",\n" +
+ "\t\"operationType\": \"createInstance\",\n" +
+ "\t\"serviceInstanceId\": \"ffa07ae4-f820-45af-9439-1416b3bc1d39\",\n" +
+ "\t\"requestsInputs\": \"{\\r\\n\\t\\\"service\\\": {\\r\\n\\t\\t\\\"name\\\": \\\"wanconnection-37\\\",\\r\\n\\t\\t\\\"description\\\": \\\"deafe\\\",\\r\\n\\t\\t\\\"serviceInvariantUuid\\\": \\\"43fb5165-7d03-4009-8951-a8f45d3f0148\\\",\\r\\n\\t\\t\\\"serviceUuid\\\": \\\"198b066c-0771-4157-9594-1824adfdda7e\\\",\\r\\n\\t\\t\\\"globalSubscriberId\\\": \\\"sdwandemo\\\",\\r\\n\\t\\t\\\"serviceType\\\": \\\"CCVPN\\\",\\r\\n\\t\\t\\\"parameters\\\": {\\r\\n\\t\\t\\t\\\"resources\\\": [\\r\\n\\t\\t\\t],\\r\\n\\t\\t\\t\\\"requestInputs\\\": {\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sotn_create_zte_template.json\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sdwan_create_zte_template.json\\\"\\r\\n\\t\\t\\t}\\r\\n\\t\\t}\\r\\n\\t}\\r\\n}\"\n" +
+ "}"
+ ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
+ return resourceInputObj
+ }
+
+ @Test
+ void testAfterCreateSDNCCall() {
+ init()
+ checkGetInstanceId(getResInputObj("SotnFc-wan-connection"))
+ checkGetInstanceId(getResInputObj("SOTNConnectivity"))
+ checkGetInstanceId(getResInputObj("SDWANConnectivity"))
+ }
+
+ private void checkGetInstanceId(ResourceInput input) {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable(Prefix + "sdncCreateReturnCode")).thenReturn("200")
+ when(mockExecution.getVariable(Prefix + "SuccessIndicator")).thenReturn("false")
+ when(mockExecution.getVariable("isActivateRequired")).thenReturn("true")
+ when(mockExecution.getVariable("CRENWKI_createSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse)
+ when(mockExecution.getVariable(Prefix + "resourceInput")).thenReturn(input.toString())
+ CreateSDNCNetworkResource createSDNCNetworkResource = new CreateSDNCNetworkResource()
+ createSDNCNetworkResource.afterCreateSDNCCall(mockExecution)
+ def instanceId = getInstanceId()
+ verify(mockExecution).setVariable("networkInstanceId", instanceId)
+ }
+
+ private getInstanceId() {
+ def response = new XmlSlurper().parseText(sdncAdapterWorkflowResponse)
+ def data = response.toString()
+ data = data.substring(data.indexOf("<"))
+ def resp = new XmlSlurper().parseText(data)
+ def instanceId = resp."network-response-information"."instance-id"
+ return instanceId
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java
index 465dc085fc..0872060d55 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
* 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
@@ -20,31 +22,35 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+import java.util.UUID;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Test;
import org.onap.aai.domain.yang.Pnf;
-public class CreateAaiEntryWithPnfIdDelegateTest {
+public class CreatePnfEntryInAaiDelegateTest {
@Test
public void shouldSetPnfIdAndPnfName() throws Exception {
// given
- CreateAaiEntryWithPnfIdDelegate delegate = new CreateAaiEntryWithPnfIdDelegate();
+ String pnfUuid = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
+ CreatePnfEntryInAaiDelegate delegate = new CreatePnfEntryInAaiDelegate();
AaiConnectionTestImpl aaiConnection = new AaiConnectionTestImpl();
delegate.setAaiConnection(aaiConnection);
DelegateExecution execution = mock(DelegateExecution.class);
- when(execution.getVariable(eq(CORRELATION_ID))).thenReturn("testCorrelationId");
+ given(execution.getVariable(eq(CORRELATION_ID))).willReturn("testCorrelationId");
+ given(execution.getVariable(eq(PNF_UUID))).willReturn(pnfUuid);
// when
delegate.execute(execution);
// then
Pnf createdEntry = aaiConnection.getCreated().get("testCorrelationId");
- assertThat(createdEntry.getPnfId()).isEqualTo("testCorrelationId");
+ assertThat(createdEntry.getPnfId()).isEqualTo(pnfUuid);
assertThat(createdEntry.getPnfName()).isEqualTo("testCorrelationId");
- assertThat(createdEntry.isInMaint()).isTrue();
+ assertThat(createdEntry.isInMaint()).isNull();
}
} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java
new file mode 100644
index 0000000000..763a4546e8
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
+ * 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.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Test;
+
+public class GeneratePnfUuidDelegateTest {
+ private static final String UUID_REGEX = "(?i)^[0-9a-f]{8}-[0-9a-f]{4}-[1-5]{1}[0-9a-f]{3}-[89ab]{1}[0-9a-f]{3}-[0-9a-f]{12}$";
+
+ @Test
+ public void execute_shouldSetValidUuidAsPnfUuid() {
+ // given
+ GeneratePnfUuidDelegate delegate = new GeneratePnfUuidDelegate();
+ DelegateExecution execution = new DelegateExecutionFake();
+ // when
+ delegate.execute(execution);
+ // then
+ assertThat((String) execution.getVariable(PNF_UUID)).matches(UUID_REGEX);
+ }
+} \ No newline at end of file
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 ab8d206a62..d670305a9a 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
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
* 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
@@ -20,90 +22,101 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
+import java.util.UUID;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.junit.Rule;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
public class PnfCheckInputsTest {
private static final String DEFAULT_TIMEOUT = "P1D";
+ private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
+ private static final String RESERVED_UUID = new UUID(0, 0).toString();
+
+ private DelegateExecution delegateExecution;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- private DelegateExecution mockDelegateExecution() {
- new PnfCheckInputs(DEFAULT_TIMEOUT);
- DelegateExecution delegateExecution = mock(DelegateExecution.class);
- when(delegateExecution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
- return delegateExecution;
+ @Before
+ public void setUp() {
+ delegateExecution = new DelegateExecutionFake();
+ delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
}
@Test
- public void shouldThrowException_whenPnfIdNotSet() {
- // given
- PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
- DelegateExecution delegateExecution = mockDelegateExecution();
- // when, then
- expectedException.expect(BpmnError.class);
- testedObject.execute(delegateExecution);
+ public void shouldThrowException_whenCorrelationIdNotSet() {
+ PnfCheckInputs testedObject = prepareExecutionForCorrelationId(null);
+ 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
- expectedException.expect(BpmnError.class);
- testedObject.execute(delegateExecution);
+ public void shouldThrowException_whenCorrelationIdIsEmptyString() {
+ PnfCheckInputs testedObject = prepareExecutionForCorrelationId("");
+ 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() {
+ PnfCheckInputs testedObject = prepareExecutionForTimeout(null, null);
+ assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
}
@Test
- public void shouldThrowException_whenTimeoutIsNotSetAndDefaultIsNotDefined() {
- // given
- PnfCheckInputs testedObject = new PnfCheckInputs(null);
- DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
- // when, then
- expectedException.expect(BpmnError.class);
- testedObject.execute(delegateExecution);
+ public void shouldThrowException_whenTimeoutIsEmptyStringAndDefaultIsNotDefined() {
+ PnfCheckInputs testedObject = prepareExecutionForTimeout(null, "");
+ 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
- expectedException.expect(BpmnError.class);
+ public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() {
+ PnfCheckInputs testedObject = prepareExecutionForTimeout(DEFAULT_TIMEOUT, null);
testedObject.execute(delegateExecution);
+ assertThat(delegateExecution.getVariable(TIMEOUT_FOR_NOTIFICATION)).isEqualTo(DEFAULT_TIMEOUT);
}
@Test
- public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() {
- // given
+ public void shouldThrowException_whenPnfUuidIsNotSet() {
+ PnfCheckInputs testedObject = prepareExecutionForUuid(null);
+ assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ }
+
+ @Test
+ public void shouldThrowException_whenPnfUuidIsEmptyString() {
+ PnfCheckInputs testedObject = prepareExecutionForUuid("");
+ assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ }
+
+ @Test
+ public void shouldThrowException_whenPnfUuidIsReservedUuid() {
+ PnfCheckInputs testedObject = prepareExecutionForUuid(RESERVED_UUID);
+ assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ }
+
+ private PnfCheckInputs prepareExecutionForCorrelationId(String correlationId) {
PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
- DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
- // when
- testedObject.execute(delegateExecution);
- // then
- verify(delegateExecution).setVariable(eq(TIMEOUT_FOR_NOTIFICATION), eq(DEFAULT_TIMEOUT));
+ delegateExecution.setVariable(CORRELATION_ID, correlationId);
+ delegateExecution.setVariable(PNF_UUID, VALID_UUID);
+ return testedObject;
+ }
+
+ private PnfCheckInputs prepareExecutionForTimeout(String defaultTimeout, String timeout) {
+ PnfCheckInputs testedObject = new PnfCheckInputs(defaultTimeout);
+ delegateExecution.setVariable(CORRELATION_ID, "testCorrelationId");
+ delegateExecution.setVariable(PNF_UUID, VALID_UUID);
+ delegateExecution.setVariable(TIMEOUT_FOR_NOTIFICATION, timeout);
+ return testedObject;
+ }
+
+ private PnfCheckInputs prepareExecutionForUuid(String uuid) {
+ PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
+ delegateExecution.setVariable(CORRELATION_ID, "testCorrelationId");
+ delegateExecution.setVariable(PNF_UUID, uuid);
+ return testedObject;
}
}