X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=generic-resource-api%2Fprovider%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fsdnc%2Fnorthbound%2FNetworkTopologyOperationRPCTest.java;fp=generic-resource-api%2Fprovider%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fsdnc%2Fnorthbound%2FTestGenericResourceApi.java;h=29ef1b4fd9d1b6dee52666a068e688f45b0311b8;hb=refs%2Fchanges%2F11%2F19811%2F1;hp=939ada805db8db3df4274efd5308f8420d7a3ac6;hpb=45ac56ef4f49b57bee4aa2cd52e4e41618ae2251;p=sdnc%2Fnorthbound.git diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TestGenericResourceApi.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java similarity index 51% rename from generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TestGenericResourceApi.java rename to generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java index 939ada80..29ef1b4f 100644 --- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TestGenericResourceApi.java +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,83 +21,24 @@ package org.onap.sdnc.northbound; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import org.junit.Before; import org.junit.Test; -import static org.mockito.Mockito.mock; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationInputBuilder; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.information.NetworkInformationBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation.RequestAction; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeaderBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformationBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestGenericResourceApi extends AbstractConcurrentDataBrokerTest { - - private GenericResourceApiProvider genericResourceApiProvider; - private static final Logger LOG = LoggerFactory.getLogger(GenericResourceApiProvider.class); - - @Before - public void setUp() throws Exception { - if (null == genericResourceApiProvider) { - DataBroker dataBroker = getDataBroker(); - NotificationPublishService mockNotification = mock(NotificationPublishService.class); - RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); - GenericResourceApiSvcLogicServiceClient client = mock(GenericResourceApiSvcLogicServiceClient.class); - try { - genericResourceApiProvider = new GenericResourceApiProvider(dataBroker, mockNotification, mockRpcRegistry, client); - } catch (Exception e) { - LOG.error("Caught exception on setUp", e); - throw e; - } - } - } - - @Test - public void testServiceTopologyOperation() { - - ServiceTopologyOperationInputBuilder inputBuilder = new ServiceTopologyOperationInputBuilder(); - - SdncRequestHeaderBuilder sdncRequestHeaderBuilder = new SdncRequestHeaderBuilder(); - sdncRequestHeaderBuilder.setSvcRequestId("1111"); - sdncRequestHeaderBuilder.setSvcAction(SvcAction.Assign); - inputBuilder.setSdncRequestHeader(sdncRequestHeaderBuilder.build()); - - RequestInformationBuilder requestInformationBuilder = new RequestInformationBuilder(); - requestInformationBuilder.setRequestId("1111"); - requestInformationBuilder.setRequestAction(RequestAction.CreateServiceInstance); - inputBuilder.setRequestInformation(requestInformationBuilder.build()); - ServiceInformationBuilder serviceInformationBuilder = new ServiceInformationBuilder(); - serviceInformationBuilder.setServiceInstanceId("1111"); - inputBuilder.setServiceInformation(serviceInformationBuilder.build()); +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; - // TODO: currently initialize GenericResourceApiSvcLogicServiceClient is failing, need to fix - java.util.concurrent.Future> future = genericResourceApiProvider - .serviceTopologyOperation(inputBuilder.build()); - RpcResult rpcResult = null; - try { - rpcResult = future.get(); - } catch (Exception e) { - fail("Error : " + e); - } - LOG.info("result: {}", rpcResult); - assertEquals("1111", rpcResult.getResult().getSvcRequestId()); - } +@RunWith(MockitoJUnitRunner.class) +public class NetworkTopologyOperationRPCTest extends GenericResourceApiProviderTest { @Test public void testNetworkTopologyOperation() { @@ -111,7 +52,7 @@ public class TestGenericResourceApi extends AbstractConcurrentDataBrokerTest { RequestInformationBuilder requestInformationBuilder = new RequestInformationBuilder(); requestInformationBuilder.setRequestId("1111"); - requestInformationBuilder.setRequestAction(RequestAction.CreateNetworkInstance); + requestInformationBuilder.setRequestAction(RequestInformation.RequestAction.CreateNetworkInstance); inputBuilder.setRequestInformation(requestInformationBuilder.build()); ServiceInformationBuilder serviceInformationBuilder = new ServiceInformationBuilder(); @@ -122,7 +63,7 @@ public class TestGenericResourceApi extends AbstractConcurrentDataBrokerTest { inputBuilder.setNetworkInformation(networkInformationBuilder.build()); java.util.concurrent.Future> future = genericResourceApiProvider - .networkTopologyOperation(inputBuilder.build()); + .networkTopologyOperation(inputBuilder.build()); RpcResult rpcResult = null; try { rpcResult = future.get(); @@ -132,4 +73,7 @@ public class TestGenericResourceApi extends AbstractConcurrentDataBrokerTest { LOG.info("result: {}", rpcResult); assertEquals("1111", rpcResult.getResult().getSvcRequestId()); } + + + }