X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fservice%2FPathComputationServiceImplTest.java;h=2c93c5bc3bc8d885102a88b0e0f54e89e6430180;hb=f49968974e1477d4fd9cfdd87d867c9ad347678e;hp=20d904e1e140abe60421053a6795befb5f2828a5;hpb=38788ce8eedd77f7b1dc089df00d9e2a9bcfc1f8;p=transportpce.git diff --git a/pce/src/test/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImplTest.java b/pce/src/test/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImplTest.java index 20d904e1e..2c93c5bc3 100644 --- a/pce/src/test/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImplTest.java +++ b/pce/src/test/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImplTest.java @@ -7,52 +7,38 @@ */ package org.opendaylight.transportpce.pce.service; -import java.math.BigDecimal; -import java.util.Arrays; +import java.util.Map; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.transportpce.common.DataStoreContext; -import org.opendaylight.transportpce.common.network.NetworkTransactionImpl; import org.opendaylight.transportpce.common.network.NetworkTransactionService; -import org.opendaylight.transportpce.common.network.RequestProcessor; -import org.opendaylight.transportpce.pce.gnpy.GnpyResult; -import org.opendaylight.transportpce.pce.gnpy.GnpyTopoImpl; import org.opendaylight.transportpce.pce.utils.PceTestData; -import org.opendaylight.transportpce.pce.utils.PceTestUtils; -import org.opendaylight.transportpce.pce.utils.TransactionUtils; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.PathBandwidth; -import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.generic.path.properties.PathPropertiesBuilder; -import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.generic.path.properties.path.properties.PathMetricBuilder; -import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.no.path.info.NoPathBuilder; -import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.result.Response; -import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.result.ResponseBuilder; -import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.result.response.response.type.NoPathCaseBuilder; -import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.result.response.response.type.PathCaseBuilder; - - +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.PathBandwidth; +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.PathPropertiesBuilder; +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.path.properties.PathMetric; +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.path.properties.PathMetricBuilder; +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.no.path.info.NoPathBuilder; +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.Response; +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.ResponseBuilder; +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.ResponseKey; +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.NoPathCaseBuilder; +import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.PathCaseBuilder; +import org.opendaylight.yangtools.yang.common.Decimal64; public class PathComputationServiceImplTest extends AbstractTest { private PathComputationServiceImpl pathComputationServiceImpl; private static NetworkTransactionService networkTransactionService = null; - private static GnpyTopoImpl gnpyTopoImpl = null; - private static GnpyResult gnpyResult = null; - private DataStoreContext dataStoreContext = this.getDataStoreContextUtil(); - private DataBroker dataBroker = this.getDataBroker(); @Before public void setUp() { networkTransactionService = Mockito.mock(NetworkTransactionService.class); - gnpyTopoImpl = Mockito.mock(GnpyTopoImpl.class); - gnpyResult = Mockito.mock(GnpyResult.class); pathComputationServiceImpl = new PathComputationServiceImpl( networkTransactionService, - this.getNotificationPublishService()); + this.getNotificationPublishService(), null, null); pathComputationServiceImpl.init(); } @@ -66,7 +52,8 @@ public class PathComputationServiceImplTest extends AbstractTest { @Test public void testPathComputationRequestNoPath() { - Response response = new ResponseBuilder().setResponseType(new NoPathCaseBuilder() + Response response = new ResponseBuilder() + .withKey(new ResponseKey("responseId")).setResponseType(new NoPathCaseBuilder() .setNoPath(new NoPathBuilder().setNoPath("no path").build()).build()).build(); pathComputationServiceImpl.generateGnpyResponse(response,"path"); @@ -77,10 +64,12 @@ public class PathComputationServiceImplTest extends AbstractTest { @Test public void testPathComputationRequestPathCase() { - Response response = new ResponseBuilder().setResponseType(new PathCaseBuilder() - .setPathProperties(new PathPropertiesBuilder().setPathMetric(Arrays.asList(new PathMetricBuilder() - .setAccumulativeValue(new BigDecimal(21)) - .setMetricType(PathBandwidth.class).build())) + PathMetric pathMetric = new PathMetricBuilder() + .setAccumulativeValue(Decimal64.valueOf("21")) + .setMetricType(PathBandwidth.class).build(); + Response response = new ResponseBuilder() + .withKey(new ResponseKey("responseId")).setResponseType(new PathCaseBuilder() + .setPathProperties(new PathPropertiesBuilder().setPathMetric(Map.of(pathMetric.key(),pathMetric)) .build()).build()).build(); pathComputationServiceImpl.generateGnpyResponse(response,"path"); @@ -89,17 +78,6 @@ public class PathComputationServiceImplTest extends AbstractTest { } - @Test(expected = Exception.class) - public void generateGnpyResponse() throws Exception { - PceTestUtils.writeNetworkIntoDataStore(dataBroker, dataStoreContext, TransactionUtils.getNetworkForSpanLoss()); - GnpyResult gnpyResult2 = - new GnpyResult("A-to-Z", - new GnpyTopoImpl(new NetworkTransactionImpl( - new RequestProcessor(dataBroker)))); - pathComputationServiceImpl.generateGnpyResponse(gnpyResult2.getResponse(), "A-to-Z"); - } - - @After public void destroy() { pathComputationServiceImpl.close();