1 package org.onap.so.bpmn.infrastructure.pnf.tasks;
3 import org.junit.Before;
5 import org.junit.runner.RunWith;
6 import org.mockito.InjectMocks;
7 import org.mockito.Mock;
8 import org.mockito.junit.MockitoJUnitRunner;
9 import org.onap.aai.domain.yang.Pnf;
10 import org.onap.so.bpmn.common.BuildingBlockExecution;
11 import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl;
12 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
13 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
14 import static org.assertj.core.api.Assertions.assertThat;
15 import static org.mockito.ArgumentMatchers.any;
16 import static org.mockito.ArgumentMatchers.eq;
17 import static org.mockito.Mockito.mock;
18 import static org.mockito.Mockito.when;
19 import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_CORRELATION_ID;
20 import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_UUID;
21 import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.preparePnf;
23 @RunWith(MockitoJUnitRunner.class)
24 public class CreatePnfEntryInAaiTest {
27 private ExtractPojosForBB extractPojosForBB;
29 private CreatePnfEntryInAai task = new CreatePnfEntryInAai();
30 private PnfManagementTestImpl pnfManagementTest = new PnfManagementTestImpl();
33 public void setUp() throws Exception {
34 task.setPnfManagement(pnfManagementTest);
35 when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF)))
36 .thenReturn(preparePnf(PNF_CORRELATION_ID, PNF_UUID));
40 public void shouldSetPnfIdAndPnfName() throws Exception {
42 task.execute(mock(BuildingBlockExecution.class));
44 Pnf createdEntry = pnfManagementTest.getCreated().get(PNF_CORRELATION_ID);
45 assertThat(createdEntry.getPnfId()).isEqualTo(PNF_UUID);
46 assertThat(createdEntry.getPnfName()).isEqualTo(PNF_CORRELATION_ID);
47 assertThat(createdEntry.isInMaint()).isNull();