SfcGeniusInterfaceServiceManager implements ISfcGeniusInterfaceServiceHandler { @Override public void interfaceStateUp(String interfaceName, BigInteger dpnId) { ReadWriteTransaction readWriteTransaction = dataBroker.newReadWriteTransaction(); SfcGeniusRspHandler rspHandler = getSfcGeniusRspHandler(readWriteTransaction); SfcGeniusServiceHandler serviceHandler = getSfcGeniusServiceHandler(readWriteTransaction); SfcGeniusSfReader sfReader = getSfcGeniusSfReader(readWriteTransaction); sfReader.readSfOnInterface(interfaceName).thenCompose(serviceFunctions -> serviceFunctions.isEmpty() ? CompletableFuture.completedFuture(null) : CompletableFuture.allOf( rspHandler.interfaceStateUp(interfaceName, serviceFunctions), serviceHandler.interfaceStateUp(interfaceName, dpnId)) .thenCompose((aVoid) -> SfcGeniusUtils.toCompletableFuture(readWriteTransaction.submit(), executor) ).handle((aVoid, exception) -> { if (exception != null) { LOG.error("Error handling interface {} state up on {}", interfaceName, dpnId, exception); } return null; })) .join(); } SfcGeniusInterfaceServiceManager(DataBroker dataBroker,
                                            RpcProviderRegistry rpcProviderRegistry,
                                            Executor executor); @Override void bindInterfacesOfServiceFunction(String sfName); @Override void unbindInterfacesOfServiceFunction(String sfName); @Override void interfaceStateUp(String interfaceName, BigInteger dpnId); @Override void interfaceStateDown(String interfaceName, BigInteger nodeId);  }
@Test public void interfaceStateUp() throws Exception { List<SfName> sfNameList = Collections.singletonList(new SfName("SF1")); when(sfcGeniusSfReader.readSfOnInterface("IF1")).thenReturn(CompletableFuture.completedFuture(sfNameList)); sfcGeniusInterfaceServiceManager.interfaceStateUp("IF1", BigInteger.valueOf(7)); verify(sfcGeniusRspHandler).interfaceStateUp(eq("IF1"), same(sfNameList)); verify(sfcGeniusServiceHandler).interfaceStateUp("IF1", BigInteger.valueOf(7)); verify(readWriteTransaction).submit(); }