SfcGeniusSfReader extends SfcGeniusReaderAbstract { public CompletableFuture<List<SfName>> readSfOnInterface(String interfaceName) { InstanceIdentifier<ServiceFunctions> sfsIID = InstanceIdentifier.builder(ServiceFunctions.class).build(); return doReadOptional(LogicalDatastoreType.CONFIGURATION, sfsIID) .thenApply(optionalServiceFunctions -> optionalServiceFunctions .map(ServiceFunctions::getServiceFunction) .orElse(Collections.emptyList()) .stream() .filter(serviceFunction -> isServiceFunctionOnInterface(serviceFunction, interfaceName)) .map(ServiceFunction::getName) .collect(Collectors.toList())); } SfcGeniusSfReader(ReadTransaction readTransaction, Executor executor); CompletableFuture<List<SfName>> readSfOnInterface(String interfaceName); CompletableFuture<List<String>> readInterfacesOfSf(SfName sfName);  }
@Test public void readSfOnInterface() throws Exception { InstanceIdentifier<ServiceFunctions> iid = InstanceIdentifier.builder(ServiceFunctions.class).build(); doReturn(CompletableFuture.completedFuture(Optional.of(serviceFunctions))) .when(reader).doReadOptional(LogicalDatastoreType.CONFIGURATION, iid); CompletableFuture<List<SfName>> sfNames = reader.readSfOnInterface("IFA"); assertThat(sfNames.get(), containsInAnyOrder(new SfName("SF1"), new SfName("SF3"), new SfName("SF5"))); assertTrue(sfNames.get().size() == 3); }