SfcGeniusIfStateReader extends SfcGeniusReaderAbstract { public CompletableFuture<BigInteger> readDpnId(String interfaceName) { InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.builder(InterfacesState.class) .child(Interface.class, new InterfaceKey(interfaceName)) .build(); return doRead(LogicalDatastoreType.OPERATIONAL, interfaceIID) .thenApply(Interface::getLowerLayerIf) .thenApply(SfcGeniusUtils::getDpnIdFromLowerLayerIfList); } SfcGeniusIfStateReader(ReadTransaction readTransaction, Executor executor); CompletableFuture<BigInteger> readDpnId(String interfaceName);  }
@Test public void readDpnId() throws Exception { String interfaceName = "IF1"; List<String> lowerLayerIfList = Collections.singletonList("openflow:1234567890:1"); when(anInterface.getLowerLayerIf()).thenReturn(lowerLayerIfList); doReturn(CompletableFuture.completedFuture(anInterface)) .when(reader).doRead(eq(LogicalDatastoreType.OPERATIONAL), instanceIdentifierCaptor.capture()); BigInteger readDpnId = reader.readDpnId(interfaceName).get(); assertThat(instanceIdentifierCaptor.getValue().firstKeyOf(Interface.class).getName(), is(interfaceName)); assertThat(readDpnId, is(BigInteger.valueOf(1234567890))); }