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.ccsdk.features.sdnr.northbound.oofpcipoc;
24 import org.junit.Before;
25 import org.junit.Test;
27 import org.opendaylight.yangtools.yang.common.RpcResult;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 import static org.junit.Assert.*;
32 import static org.mockito.Mockito.mock;
36 import org.opendaylight.mdsal.binding.api.DataBroker;
37 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
38 import org.opendaylight.mdsal.binding.api.RpcProviderService;
40 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdInputBuilder;
41 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdOutput;
43 import com.google.common.util.concurrent.ListenableFuture;
47 public class TestOofpcipoc {
49 private OofpcipocProvider oofpcipocProvider;
50 private static final Logger LOG = LoggerFactory.getLogger(OofpcipocProvider.class);
53 public void setUp() throws Exception {
54 if (null == oofpcipocProvider) {
55 DataBroker dataBroker = mock(DataBroker.class);
56 NotificationPublishService mockNotification = mock(NotificationPublishService.class);
57 RpcProviderService mockRpcRegistry = mock(RpcProviderService.class);
58 OofpcipocClient mockSliClient = mock(OofpcipocClient.class);
59 oofpcipocProvider = new OofpcipocProvider();
60 oofpcipocProvider.setDataBroker(dataBroker);
61 oofpcipocProvider.setNotificationPublishService(mockNotification);
62 oofpcipocProvider.setRpcProviderService(mockRpcRegistry);
63 oofpcipocProvider.setClient(mockSliClient);
67 //Testcase should return error 503 when No service logic active for ConfigurationPhyCellId
69 public void testConfigurationPhyCellId() {
71 ConfigurationPhyCellIdInputBuilder inputBuilder = new ConfigurationPhyCellIdInputBuilder();
73 inputBuilder.setFapServiceNumberOfEntries(new BigInteger("1"));
75 // TODO: currently initialize SvcLogicServiceClient is failing, need to fix
76 ListenableFuture<RpcResult<ConfigurationPhyCellIdOutput>> future = oofpcipocProvider
77 .configurationPhyCellId(inputBuilder.build());
78 RpcResult<ConfigurationPhyCellIdOutput> rpcResult = null;
80 rpcResult = future.get();
81 } catch (Exception e) {
84 LOG.info("result: {}", rpcResult);
85 assertEquals("503", rpcResult.getResult().getResponseCode());
88 //Input parameter validation
90 public void testConfigurationPhyCellIdValidation() {
92 ListenableFuture<RpcResult<ConfigurationPhyCellIdOutput>> future = oofpcipocProvider
93 .configurationPhyCellId(null);
94 RpcResult<ConfigurationPhyCellIdOutput> rpcResult = null;
96 rpcResult = future.get();
97 } catch (Exception e) {
100 LOG.info("result: {}", rpcResult);
101 assertEquals("Input is null", rpcResult.getResult().getResponseCode());