2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.so.bpmn.infrastructure.pnf.delegate;
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;
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;
36 public class CreatePnfEntryInAaiDelegateTest {
39 public void shouldSetPnfIdAndPnfName() throws Exception {
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);
49 delegate.execute(execution);
51 Pnf createdEntry = aaiConnection.getCreated().get("testCorrelationId");
52 assertThat(createdEntry.getPnfId()).isEqualTo(pnfUuid);
53 assertThat(createdEntry.getPnfName()).isEqualTo("testCorrelationId");
54 assertThat(createdEntry.isInMaint()).isNull();