2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.vid.services;
24 import org.mockito.Mock;
25 import org.mockito.MockitoAnnotations;
26 import org.onap.vid.model.ArtifactInfo;
27 import org.onap.vid.model.SOWorkflow;
28 import org.onap.vid.model.SOWorkflowList;
29 import org.onap.vid.model.WorkflowInputParameter;
30 import org.onap.vid.model.WorkflowSource;
31 import org.onap.vid.model.WorkflowSpecification;
32 import org.onap.vid.model.WorkflowSpecificationWrapper;
33 import org.onap.vid.mso.MsoBusinessLogic;
34 import org.testng.annotations.BeforeMethod;
35 import org.testng.annotations.Test;
37 import java.util.Collections;
38 import java.util.List;
39 import java.util.UUID;
41 import static org.assertj.core.api.Assertions.assertThat;
42 import static org.mockito.Mockito.when;
44 public class ExternalWorkflowsServiceImplTest {
47 private MsoBusinessLogic msoBusinessLogic;
50 private static final UUID SAMPLE_UUID = UUID.randomUUID();
54 MockitoAnnotations.initMocks(this);
58 public void shouldReturnWorkflowsOnValidResponse() {
60 ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(msoBusinessLogic);
61 WorkflowInputParameter parameter = new WorkflowInputParameter("sampleLabel", "text",
62 true, Collections.EMPTY_LIST, "sampleName", "userParams", "description");
63 SOWorkflowList workflowList = createWorkflowList(parameter);
64 SOWorkflow workflow = new SOWorkflow(SAMPLE_UUID.toString(), "sampleName", WorkflowSource.SDC, Collections.singletonList(parameter));
65 when(msoBusinessLogic.getWorkflowListByModelId("test")).thenReturn(workflowList);
67 List<SOWorkflow> workflows = extWorkflowsService.getWorkflows("test");
69 assertThat(workflows).hasSize(1).contains(workflow);
72 private SOWorkflowList createWorkflowList(WorkflowInputParameter parameter) {
73 ArtifactInfo artifactInfo = new ArtifactInfo("workflow", SAMPLE_UUID.toString(), "sampleArtifactName",
74 "sampleVersion", "sampleDescription", "sampleName", "sampleOperation", "sdc", "vnf");
75 WorkflowSpecification specification = new WorkflowSpecification(artifactInfo, Collections.EMPTY_LIST, Collections.singletonList(parameter));
76 WorkflowSpecificationWrapper wrapper = new WorkflowSpecificationWrapper(specification);
77 return new SOWorkflowList(Collections.singletonList(wrapper));