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=62de9fb3fe171542a1833021a9ba114934e93a83;hb=a77937222db28970e716507baa1d221679d4e0d0;hp=71d57e075c300af6cb6dba39fe8aba2c4d765dcf;hpb=2e7347dac70ba667dcfc8b4d35bc45faf09a5d46;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 71d57e075..62de9fb3f 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 @@ -5,32 +5,65 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.transportpce.pce.utils.service; +package org.opendaylight.transportpce.pce.service; +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.service.PathComputationServiceImpl; +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; 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( - new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())), + networkTransactionService, this.getNotificationPublishService()); pathComputationServiceImpl.init(); } @Test public void pathComputationRequestTest() { - Assert.assertNotNull(pathComputationServiceImpl.pathComputationRequest(PceTestData.getPCERequest())); + Assert.assertNotNull( + pathComputationServiceImpl.pathComputationRequest(PceTestData.getPCE_simpletopology_test1_request())); + + } + + @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(); } }