2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.clamp.clds.client.req;
26 import org.camunda.bpm.engine.delegate.DelegateExecution;
27 import org.junit.Assert;
28 import org.junit.Test;
29 import org.onap.clamp.clds.client.SdcCatalogServices;
30 import org.onap.clamp.clds.model.CldsAsdcResource;
31 import org.onap.clamp.clds.model.CldsAsdcServiceDetail;
32 import org.onap.clamp.clds.model.prop.Global;
33 import org.onap.clamp.clds.model.prop.ModelProperties;
35 import java.util.ArrayList;
36 import java.util.List;
38 import static org.mockito.Mockito.mock;
39 import static org.mockito.Mockito.when;
42 * Created by Julien Bertozzi on 6/20/17.
44 public class SdcReqTest {
46 String baseUrl = "AYBABTU";
47 String serviceInvariantUUID = "serviceInvariantUUID";
50 public void getAsdcReqUrlsListNoGlobalPropTest() throws Exception {
51 ModelProperties prop = mock(ModelProperties.class);
52 SdcCatalogServices sdcCatalogServices = mock(SdcCatalogServices.class);
53 DelegateExecution delegateExecution = mock(DelegateExecution.class);
54 Global global = mock(Global.class);
55 CldsAsdcServiceDetail cldsAsdcServiceDetail = mock(CldsAsdcServiceDetail.class);
56 CldsAsdcResource cldsAsdcResource = mock(CldsAsdcResource.class);
57 List<CldsAsdcResource> cldsAsdcResources = new ArrayList<>();
58 cldsAsdcResources.add(cldsAsdcResource);
59 List<String> resourceVf = new ArrayList<>();
60 resourceVf.add(serviceInvariantUUID);
62 Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty());
64 when(prop.getGlobal()).thenReturn(global);
65 Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty());
67 when(global.getService()).thenReturn(serviceInvariantUUID);
68 Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty());
70 when(sdcCatalogServices.getCldsAsdcServiceDetailFromJson(null)).thenReturn(cldsAsdcServiceDetail);
71 when(global.getResourceVf()).thenReturn(new ArrayList<>());
72 Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty());
74 when(cldsAsdcServiceDetail.getResources()).thenReturn(cldsAsdcResources);
75 Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty());
77 when(cldsAsdcResource.getResoucreType()).thenReturn("VF");
78 Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty());
80 when(global.getResourceVf()).thenReturn(resourceVf);
81 when(cldsAsdcResource.getResourceInvariantUUID()).thenReturn(serviceInvariantUUID);
82 when(cldsAsdcResource.getResourceInstanceName()).thenReturn("Resource instance name");
83 List<String> expected = new ArrayList<>();
84 expected.add("AYBABTU/null/resourceInstances/resourceinstancename/artifacts");
85 Assert.assertEquals(expected, SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution));