SfcGeniusRspHandler { CompletableFuture<Void> interfaceStateUp(String interfaceName, List<SfName> sfNameList) { SfcGeniusSfStatesReader sfStatesReader = getSfStatesReader(); LOG.debug("Re-render for interface {} of service functions {}", interfaceName, sfNameList); return sfStatesReader.readSfpNames(sfNameList) .thenCompose(rspList -> CompletableFuture.allOf( rspList.stream() .map(SfpName::getValue) .map(RspName::new) .map(this::reRenderRsp) .toArray(size -> new CompletableFuture<?>[size]) )); } SfcGeniusRspHandler(ReadWriteTransaction transaction, Executor executor);   }
@Test public void interfaceStateUp() throws Exception { String testInterface = "TestInterface"; List<SfName> sfNameList = Arrays.asList(new SfName("SF1"), new SfName("SF2")); List<SfpName> sfpNameList = Arrays.asList(new SfpName("RSP1"), new SfpName("RSP2")); List<RspName> rspNameList = Arrays.asList(new RspName("RSP1"), new RspName("RSP2")); List<RenderedServicePath> rspList = Arrays.asList( new RenderedServicePathBuilder().setName(rspNameList.get(0)).build(), new RenderedServicePathBuilder().setName(rspNameList.get(1)).build() ); when(sfcGeniusSfStatesReader.readSfpNames(sfNameList)) .thenReturn(CompletableFuture.completedFuture(sfpNameList)); when(sfcGeniusRspReader.readRsp(rspNameList.get(0))) .thenReturn(CompletableFuture.completedFuture(rspList.get(0))); when(sfcGeniusRspReader.readRsp(rspNameList.get(1))) .thenReturn(CompletableFuture.completedFuture(rspList.get(1))); when(sfcGeniusRspWriter.deleteRsp(rspList.get(0))) .thenReturn(CompletableFuture.completedFuture(rspList.get(0))); when(sfcGeniusRspWriter.deleteRsp(rspList.get(1))) .thenReturn(CompletableFuture.completedFuture(rspList.get(1))); when(sfcGeniusRspWriter.createRsp(any())) .thenReturn(CompletableFuture.completedFuture(null)); sfcGeniusRspHandler.interfaceStateUp(testInterface, sfNameList); verify(sfcGeniusRspWriter).deleteRsp(rspList.get(0)); verify(sfcGeniusRspWriter).createRsp(rspList.get(0)); verify(sfcGeniusRspWriter).deleteRsp(rspList.get(1)); verify(sfcGeniusRspWriter).createRsp(rspList.get(1)); }