daa210e4b6057bc6acf702d99e4bca48d3a19137
[ccsdk/features.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                      reserved.
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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
22 package org.onap.ccsdk.features.sdnr.northbound.oofpcipoc;
23
24 import org.junit.Before;
25 import org.junit.Test;
26
27 import org.onap.ccsdk.features.sdnr.northbound.oofpcipoc.OofpcipocClient;
28 import org.onap.ccsdk.features.sdnr.northbound.oofpcipoc.OofpcipocProvider;
29
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;
34
35 import org.opendaylight.yangtools.yang.common.RpcResult;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 import static org.junit.Assert.*;
40 import static org.mockito.Mockito.mock;
41
42 import java.math.*;
43
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;
49
50
51
52 public class TestOofpcipoc extends AbstractConcurrentDataBrokerTest {
53
54     private OofpcipocProvider oofpcipocProvider;
55     private static final Logger LOG = LoggerFactory.getLogger(OofpcipocProvider.class);
56
57     @Before
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);
65         }
66     }
67
68     //Testcase should return error 503 when No service logic active for ConfigurationPhyCellId
69     @Test
70     public void testConfigurationPhyCellId() {
71
72         ConfigurationPhyCellIdInputBuilder inputBuilder = new ConfigurationPhyCellIdInputBuilder();
73
74         inputBuilder.setFapServiceNumberOfEntries(new BigInteger("1"));
75
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;
80         try {
81             rpcResult = future.get();
82         } catch (Exception e) {
83             fail("Error : " + e);
84         }
85         LOG.info("result: {}", rpcResult);
86         assertEquals("503", rpcResult.getResult().getResponseCode());
87     }
88
89     //Input parameter validation
90     @Test
91     public void testConfigurationPhyCellIdValidation() {
92
93         ListenableFuture<RpcResult<ConfigurationPhyCellIdOutput>> future = oofpcipocProvider
94                                                                                       .configurationPhyCellId(null);
95         RpcResult<ConfigurationPhyCellIdOutput> rpcResult = null;
96         try {
97             rpcResult = future.get();
98         } catch (Exception e) {
99             fail("Error : " + e);
100         }
101         LOG.info("result: {}", rpcResult);
102         assertEquals("Input is null", rpcResult.getResult().getResponseCode());
103     }
104 }