### Question:
VppEndpointListener extends DataTreeChangeHandler<VppEndpoint> { @Override protected void onSubtreeModified(DataObjectModification<VppEndpoint> rootNode, InstanceIdentifier<VppEndpoint> rootIdentifier) { VppEndpointConfEvent event = new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter()); LOG.debug("Dispatching event on subtree modified: {}", event.getClass()); eventBus.post(event); } VppEndpointListener(DataBroker dataProvider, EventBus eventBus); void flushPendingVppEndpoint(@Nonnull String hostName,@Nonnull String intfName);  }### Answer:
@Test public void testOnSubtreeModified() throws Exception { ArgumentCaptor<VppEndpointConfEvent> argVppEpEvent = ArgumentCaptor.forClass(VppEndpointConfEvent.class); VppEndpointBuilder vppEndpointBuilder = getBaseVppEndpointBuilder(); VppEndpoint vppEndpoint = vppEndpointBuilder.build(); InstanceIdentifier<VppEndpoint> vppEpIid = InstanceIdentifier.builder(Config.class).child(VppEndpoint.class, vppEndpoint.getKey()).build(); WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.CONFIGURATION, vppEpIid, vppEndpoint); wTx.submit().get(); VppEndpoint modifiedVppEndpoint = vppEndpointBuilder.setVppInterfaceName(IFACE_NAME).build(); wTx = getDataBroker().newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.CONFIGURATION, vppEpIid, modifiedVppEndpoint); wTx.submit().get(); Mockito.verify(eventBusMock, Mockito.times(2)).post(argVppEpEvent.capture()); VppEndpointConfEvent capturedFirstVppEpEvent = argVppEpEvent.getAllValues().get(0); Assert.assertEquals(vppEpIid, capturedFirstVppEpEvent.getIid()); assertEqualsOptional(null, capturedFirstVppEpEvent.getBefore()); assertEqualsOptional(vppEndpoint, capturedFirstVppEpEvent.getAfter()); VppEndpointConfEvent capturedSecondVppEpEvent = argVppEpEvent.getAllValues().get(1); Assert.assertEquals(vppEpIid, capturedSecondVppEpEvent.getIid()); assertEqualsOptional(vppEndpoint, capturedSecondVppEpEvent.getBefore()); assertEqualsOptional(modifiedVppEndpoint, capturedSecondVppEpEvent.getAfter()); }