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=========================================================
22 package org.onap.sdnc.northbound.asdcapi;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiProvider;
27 import org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiSliClient;
28 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
29 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
30 import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
31 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
32 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInputBuilder;
33 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateOutput;
34 import org.opendaylight.yangtools.yang.common.RpcResult;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
38 import static org.junit.Assert.*;
39 import static org.mockito.Mockito.mock;
41 public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest {
43 private AsdcApiProvider asdcApiProvider;
44 private static final Logger LOG = LoggerFactory.getLogger(AsdcApiProvider.class);
47 public void setUp() throws Exception {
48 if (null == asdcApiProvider) {
49 DataBroker dataBroker = getDataBroker();
50 NotificationPublishService mockNotification = mock(NotificationPublishService.class);
51 RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class);
52 AsdcApiSliClient mockSliClient = mock(AsdcApiSliClient.class);
53 asdcApiProvider = new AsdcApiProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient);
57 //Testcase should return error 503 when No service logic active for ASDC-API.
59 public void testVfLicenseModelUpdate() {
61 VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder();
63 inputBuilder.setArtifactName("abc");
64 inputBuilder.setArtifactVersion("1");
66 // TODO: currently initialize SvcLogicServiceClient is failing, need to fix
67 java.util.concurrent.Future<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
68 .vfLicenseModelUpdate(inputBuilder.build());
69 RpcResult<VfLicenseModelUpdateOutput> rpcResult = null;
71 rpcResult = future.get();
72 } catch (Exception e) {
75 LOG.info("result: {}", rpcResult);
76 assertEquals("503", rpcResult.getResult().getAsdcApiResponseCode());
79 //Input parameter validation
81 public void testVfLicenseModelUpdateInputValidation() {
83 VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder();
85 inputBuilder.setArtifactName("abc");
86 inputBuilder.setArtifactVersion("1");
88 java.util.concurrent.Future<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
89 .vfLicenseModelUpdate(null);
93 @Test(expected = IllegalArgumentException.class)
94 public void testVfLicenseModelUpdateValidation1() {
96 VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder();
98 java.util.concurrent.Future<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
99 .vfLicenseModelUpdate(inputBuilder.build());
100 RpcResult<VfLicenseModelUpdateOutput> rpcResult = null;
102 rpcResult = future.get();
103 } catch (Exception e) {
104 fail("Error : " + e);