1 package org.onap.so.bpmn.infrastructure.pnf.delegate;
3 import org.apache.commons.lang3.StringUtils;
4 import org.camunda.bpm.engine.delegate.BpmnError;
5 import org.camunda.bpm.engine.delegate.DelegateExecution;
6 import org.junit.Before;
8 import static org.assertj.core.api.Assertions.assertThatThrownBy;
9 import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfInputCheckersTestUtils.DelegateExecutionBuilder;
10 import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfInputCheckersTestUtils.RESERVED_UUID;
11 import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfInputCheckersTestUtils.VALID_UUID;
13 public class AssignPnfInputsCheckerDelegateTest {
15 private DelegateExecutionBuilder delegateExecutionBuilder;
16 private AssignPnfInputsCheckerDelegate testedObject;
17 private DelegateExecution execution;
21 testedObject = new AssignPnfInputsCheckerDelegate();
22 delegateExecutionBuilder = new DelegateExecutionBuilder();
26 public void shouldThrowException_whenPnfCorrelationIdNotSet() {
27 execution = delegateExecutionBuilder.setPnfCorrelationId(null).setPnfUuid(VALID_UUID).build();
28 assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
32 public void shouldThrowException_whenPnfUuidIsNotSet() {
33 execution = delegateExecutionBuilder.setPnfUuid(null).build();
34 assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
38 public void shouldThrowException_whenPnfUuidIsEmptyString() {
39 execution = delegateExecutionBuilder.setPnfUuid(StringUtils.EMPTY).build();
40 assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
44 public void shouldThrowException_whenPnfUuidIsReservedUuid() {
45 execution = delegateExecutionBuilder.setPnfUuid(RESERVED_UUID).build();
46 assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
49 private void assertThatSutExecutionThrowsExceptionOfInstance(Class<?> type) {
50 assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(type);