0872060d55464607ce823bf5f7d00bf2efeb42c7
[so.git] / bpmn / so-bpmn-infrastructure-common / src / test / java / org / onap / so / bpmn / infrastructure / pnf / delegate / CreatePnfEntryInAaiDelegateTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright 2018 Nokia
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22 package org.onap.so.bpmn.infrastructure.pnf.delegate;
23
24 import static org.assertj.core.api.Assertions.assertThat;
25 import static org.mockito.BDDMockito.given;
26 import static org.mockito.Matchers.eq;
27 import static org.mockito.Mockito.mock;
28 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
29 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
30
31 import java.util.UUID;
32 import org.camunda.bpm.engine.delegate.DelegateExecution;
33 import org.junit.Test;
34 import org.onap.aai.domain.yang.Pnf;
35
36 public class CreatePnfEntryInAaiDelegateTest {
37
38     @Test
39     public void shouldSetPnfIdAndPnfName() throws Exception {
40         // given
41         String pnfUuid = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
42         CreatePnfEntryInAaiDelegate delegate = new CreatePnfEntryInAaiDelegate();
43         AaiConnectionTestImpl aaiConnection = new AaiConnectionTestImpl();
44         delegate.setAaiConnection(aaiConnection);
45         DelegateExecution execution = mock(DelegateExecution.class);
46         given(execution.getVariable(eq(CORRELATION_ID))).willReturn("testCorrelationId");
47         given(execution.getVariable(eq(PNF_UUID))).willReturn(pnfUuid);
48         // when
49         delegate.execute(execution);
50         // then
51         Pnf createdEntry = aaiConnection.getCreated().get("testCorrelationId");
52         assertThat(createdEntry.getPnfId()).isEqualTo(pnfUuid);
53         assertThat(createdEntry.getPnfName()).isEqualTo("testCorrelationId");
54         assertThat(createdEntry.isInMaint()).isNull();
55     }
56 }