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.onap.ccsdk.features.sdnr.northbound.oofpcipoc.OofpcipocClient;
28 import org.onap.ccsdk.features.sdnr.northbound.oofpcipoc.OofpcipocProvider;
30 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
31 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
32 import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
33 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
35 import org.opendaylight.yangtools.yang.common.RpcResult;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
39 import static org.junit.Assert.*;
40 import static org.mockito.Mockito.mock;
44 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdInput;
45 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdInputBuilder;
46 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdOutput;
47 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdOutputBuilder;
48 import com.google.common.util.concurrent.ListenableFuture;
52 public class TestOofpcipoc extends AbstractConcurrentDataBrokerTest {
54 private OofpcipocProvider oofpcipocProvider;
55 private static final Logger LOG = LoggerFactory.getLogger(OofpcipocProvider.class);
58 public void setUp() throws Exception {
59 if (null == oofpcipocProvider) {
60 DataBroker dataBroker = getDataBroker();
61 NotificationPublishService mockNotification = mock(NotificationPublishService.class);
62 RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class);
63 OofpcipocClient mockSliClient = mock(OofpcipocClient.class);
64 oofpcipocProvider = new OofpcipocProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient);
68 //Testcase should return error 503 when No service logic active for ConfigurationPhyCellId
70 public void testConfigurationPhyCellId() {
72 ConfigurationPhyCellIdInputBuilder inputBuilder = new ConfigurationPhyCellIdInputBuilder();
74 inputBuilder.setFapServiceNumberOfEntries(new BigInteger("1"));
76 // TODO: currently initialize SvcLogicServiceClient is failing, need to fix
77 ListenableFuture<RpcResult<ConfigurationPhyCellIdOutput>> future = oofpcipocProvider
78 .configurationPhyCellId(inputBuilder.build());
79 RpcResult<ConfigurationPhyCellIdOutput> rpcResult = null;
81 rpcResult = future.get();
82 } catch (Exception e) {
85 LOG.info("result: {}", rpcResult);
86 assertEquals("503", rpcResult.getResult().getResponseCode());
89 //Input parameter validation
91 public void testConfigurationPhyCellIdValidation() {
93 ListenableFuture<RpcResult<ConfigurationPhyCellIdOutput>> future = oofpcipocProvider
94 .configurationPhyCellId(null);
95 RpcResult<ConfigurationPhyCellIdOutput> rpcResult = null;
97 rpcResult = future.get();
98 } catch (Exception e) {
101 LOG.info("result: {}", rpcResult);
102 assertEquals("Input is null", rpcResult.getResult().getResponseCode());