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.dataChange;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.ccsdk.sli.northbound.DataChangeProvider;
27 import org.onap.ccsdk.sli.northbound.DataChangeClient;
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.sli.northbound.datachange.rev150519.DataChangeNotificationInput;
33 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.rev150519.DataChangeNotificationInputBuilder;
34 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.rev150519.DataChangeNotificationOutput;
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;
42 public class TestDataChange extends AbstractConcurrentDataBrokerTest {
44 private DataChangeProvider dataChangeProvider;
45 private static final Logger LOG = LoggerFactory.getLogger(DataChangeProvider.class);
48 public void setUp() throws Exception {
49 if (null == dataChangeProvider) {
50 DataBroker dataBroker = getDataBroker();
51 NotificationPublishService mockNotification = mock(NotificationPublishService.class);
52 RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class);
53 DataChangeClient mockSliClient = mock(DataChangeClient.class);
54 dataChangeProvider = new DataChangeProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient);
58 //Testcase should return error 503 when No service logic active for dataChange.
60 public void testDataChangeNotification() {
62 DataChangeNotificationInputBuilder inputBuilder = new DataChangeNotificationInputBuilder();
64 inputBuilder.setAaiEventId("1");
67 // TODO: currently initialize SvcLogicServiceClient is failing, need to fix
68 java.util.concurrent.Future<RpcResult<DataChangeNotificationOutput>> future = dataChangeProvider
69 .dataChangeNotification(inputBuilder.build());
70 RpcResult<DataChangeNotificationOutput> rpcResult = null;
72 rpcResult = future.get();
73 } catch (Exception e) {
76 LOG.info("result: {}", rpcResult);
77 assertEquals("503", rpcResult.getResult().getDataChangeResponseCode());
80 //Input parameter validation
82 public void testDataChangeNotificationInputValidation() {
84 java.util.concurrent.Future<RpcResult<DataChangeNotificationOutput>> future = dataChangeProvider
85 .dataChangeNotification(null);
86 RpcResult<DataChangeNotificationOutput> rpcResult = null;
88 rpcResult = future.get();
89 } catch (Exception e) {
92 LOG.info("result: {}", rpcResult);
93 assertEquals("403", rpcResult.getResult().getDataChangeResponseCode());