From 2627d1efc45aaf7d30dc6b9b33a2e5a22728a531 Mon Sep 17 00:00:00 2001 From: Gilles Thouenon Date: Tue, 14 Mar 2023 15:41:02 +0100 Subject: [PATCH] Convert PathComputationServiceImpl into Component Adapt UT and blueprint file accordingly. JIRA: TRNSPRTPCE-736 Signed-off-by: Gilles Thouenon Change-Id: Ifbcd73c6a2390bbaa5fa468617ff46ba1515892c --- .../service/PathComputationServiceImpl.java | 21 +++++++++---------- .../OSGI-INF/blueprint/pce-blueprint.xml | 18 +--------------- .../PathComputationServiceImplTest.java | 7 ------- 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java b/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java index 32942c2bd..3bda9da10 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java @@ -55,9 +55,13 @@ import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.ServicePathNotificationTypes; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.handler.header.ServiceHandlerHeaderBuilder; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Component(immediate = true) public class PathComputationServiceImpl implements PathComputationService { private static final Logger LOG = LoggerFactory.getLogger(PathComputationServiceImpl.class); @@ -68,22 +72,17 @@ public class PathComputationServiceImpl implements PathComputationService { private final GnpyConsumer gnpyConsumer; private PortMapping portMapping; - public PathComputationServiceImpl(NetworkTransactionService networkTransactionService, - NotificationPublishService notificationPublishService, - GnpyConsumer gnpyConsumer, PortMapping portMapping) { + @Activate + public PathComputationServiceImpl(@Reference NetworkTransactionService networkTransactionService, + @Reference NotificationPublishService notificationPublishService, + @Reference GnpyConsumer gnpyConsumer, + @Reference PortMapping portMapping) { this.notificationPublishService = notificationPublishService; this.networkTransactionService = networkTransactionService; this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5)); this.gnpyConsumer = gnpyConsumer; this.portMapping = portMapping; - } - - public void init() { - LOG.info("init ..."); - } - - public void close() { - LOG.info("close."); + LOG.debug("PathComputationServiceImpl instantiated"); } @SuppressFBWarnings( diff --git a/pce/src/main/resources/OSGI-INF/blueprint/pce-blueprint.xml b/pce/src/main/resources/OSGI-INF/blueprint/pce-blueprint.xml index a42a0f8a6..1ba493936 100755 --- a/pce/src/main/resources/OSGI-INF/blueprint/pce-blueprint.xml +++ b/pce/src/main/resources/OSGI-INF/blueprint/pce-blueprint.xml @@ -11,20 +11,8 @@ Author: Martial Coulibaly on behalf of Orange --> - - - - - - - - - - - + on behalf of Orange - - - 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 66ae13a72..4408d094e 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 @@ -10,7 +10,6 @@ package org.opendaylight.transportpce.pce.service; import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.Map; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -40,7 +39,6 @@ public class PathComputationServiceImplTest extends AbstractTest { pathComputationServiceImpl = new PathComputationServiceImpl( networkTransactionService, this.getNotificationPublishService(), null, null); - pathComputationServiceImpl.init(); } @Test @@ -79,9 +77,4 @@ public class PathComputationServiceImplTest extends AbstractTest { pathComputationServiceImpl.generateGnpyResponse(null,"path"); assertNotNull(pathComputationServiceImpl.pathComputationRerouteRequest(PceTestData.getPCEReroute())); } - - @AfterEach - void destroy() { - pathComputationServiceImpl.close(); - } } -- 2.36.6