a562da490b13dc1f7bd2c68cf7219c5445d61547
[so.git] / bpmn / so-bpmn-infrastructure-common / src / test / java / org / onap / so / bpmn / infrastructure / pnf / delegate / AssignPnfInputsCheckerDelegateTest.java
1 package org.onap.so.bpmn.infrastructure.pnf.delegate;
2
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;
7 import org.junit.Test;
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;
12
13 public class AssignPnfInputsCheckerDelegateTest {
14
15     private DelegateExecutionBuilder delegateExecutionBuilder;
16     private AssignPnfInputsCheckerDelegate testedObject;
17     private DelegateExecution execution;
18
19     @Before
20     public void setUp() {
21         testedObject = new AssignPnfInputsCheckerDelegate();
22         delegateExecutionBuilder = new DelegateExecutionBuilder();
23     }
24
25     @Test
26     public void shouldThrowException_whenPnfCorrelationIdNotSet() {
27         execution = delegateExecutionBuilder.setPnfCorrelationId(null).setPnfUuid(VALID_UUID).build();
28         assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
29     }
30
31     @Test
32     public void shouldThrowException_whenPnfUuidIsNotSet() {
33         execution = delegateExecutionBuilder.setPnfUuid(null).build();
34         assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
35     }
36
37     @Test
38     public void shouldThrowException_whenPnfUuidIsEmptyString() {
39         execution = delegateExecutionBuilder.setPnfUuid(StringUtils.EMPTY).build();
40         assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
41     }
42
43     @Test
44     public void shouldThrowException_whenPnfUuidIsReservedUuid() {
45         execution = delegateExecutionBuilder.setPnfUuid(RESERVED_UUID).build();
46         assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class);
47     }
48
49     private void assertThatSutExecutionThrowsExceptionOfInstance(Class<?> type) {
50         assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(type);
51     }
52 }