Strengthens independence between UTs in OLM
[transportpce.git] / olm / src / test / java / org / opendaylight / transportpce / olm / service / OlmPowerServiceImplTest.java
index 29c2b7dde4cbeabd07dfad64695aa6c78b6618ca..78d4c01b9d8f8302dc1611478ba2a3b3e675166b 100644 (file)
@@ -97,10 +97,11 @@ public class OlmPowerServiceImplTest  extends AbstractTest {
 
     @Before
     public void setUp() {
-        this.mountPoint = new MountPointStub(this.getDataBroker());
+        this.dataBroker =  getNewDataBroker();
+        this.mountPoint = new MountPointStub(this.dataBroker);
         this.mountPointService = new MountPointServiceStub(mountPoint);
         this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
-        this.mappingUtils = Mockito.spy(new MappingUtilsImpl(getDataBroker()));
+        this.mappingUtils = Mockito.spy(new MappingUtilsImpl(dataBroker));
         Mockito.doReturn(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1).when(mappingUtils)
                 .getOpenRoadmVersion(Mockito.anyString());
         this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
@@ -113,18 +114,17 @@ public class OlmPowerServiceImplTest  extends AbstractTest {
         this.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager),
                 this.mappingUtils,this.openRoadmInterfacesImpl121,this.openRoadmInterfacesImpl22);
         this.portMappingVersion22 =
-                new PortMappingVersion221(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
+                new PortMappingVersion221(dataBroker, deviceTransactionManager, this.openRoadmInterfaces);
         this.portMappingVersion121 =
-                new PortMappingVersion121(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
-        this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion22, this.portMappingVersion121);
+                new PortMappingVersion121(dataBroker, deviceTransactionManager, this.openRoadmInterfaces);
+        this.portMapping = new PortMappingImpl(dataBroker, this.portMappingVersion22, this.portMappingVersion121);
         this.portMapping = Mockito.spy(this.portMapping);
-        this.powerMgmt = new PowerMgmtImpl(this.getDataBroker(), this.openRoadmInterfaces, this.crossConnect,
+        this.powerMgmt = new PowerMgmtImpl(this.dataBroker, this.openRoadmInterfaces, this.crossConnect,
             this.deviceTransactionManager);
-        this.olmPowerService = new OlmPowerServiceImpl(this.getDataBroker(), this.powerMgmt,
+        this.olmPowerService = new OlmPowerServiceImpl(this.dataBroker, this.powerMgmt,
             this.deviceTransactionManager, this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
-        this.dataBroker =  PowerMockito.spy(getDataBroker());
         this.powerMgmtMock = PowerMockito.mock(PowerMgmtImpl.class);
-        this.olmPowerServiceMock = new OlmPowerServiceImpl(this.getDataBroker(), this.powerMgmtMock,
+        this.olmPowerServiceMock = new OlmPowerServiceImpl(this.dataBroker, this.powerMgmtMock,
             this.deviceTransactionManager, this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
         this.olmPowerServiceMock = Mockito.mock(OlmPowerServiceImpl.class);
         MockitoAnnotations.initMocks(this);
@@ -201,7 +201,7 @@ public class OlmPowerServiceImplTest  extends AbstractTest {
             .augmentation(Network1.class)
             .build();
         Network1 network = TransactionUtils.getNetwork();
-        TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, network);
+        TransactionUtils.writeTransaction(this.dataBroker, networkIID, network);
         try {
             Thread.sleep(1000);
         } catch (InterruptedException e) {
@@ -225,7 +225,7 @@ public class OlmPowerServiceImplTest  extends AbstractTest {
             .augmentation(Network1.class)
             .build();
         Network1 network = TransactionUtils.getEmptyNetwork();
-        TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, network);
+        TransactionUtils.writeTransaction(this.dataBroker, networkIID, network);
         try {
             Thread.sleep(1000);
         } catch (InterruptedException e) {
@@ -245,7 +245,7 @@ public class OlmPowerServiceImplTest  extends AbstractTest {
             .augmentation(Network1.class)
             .build();
         Network1 network = TransactionUtils.getNullNetwork();
-        TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, network);
+        TransactionUtils.writeTransaction(this.dataBroker, networkIID, network);
         try {
             Thread.sleep(1000);
         } catch (InterruptedException e) {
@@ -272,7 +272,7 @@ public class OlmPowerServiceImplTest  extends AbstractTest {
             .augmentation(Network1.class)
             .build();
         Network1 network = TransactionUtils.getNetwork();
-        TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, network);
+        TransactionUtils.writeTransaction(this.dataBroker, networkIID, network);
         try {
             Thread.sleep(1000);
         } catch (InterruptedException e) {