SfcGeniusSfStateListener extends AsyncDataTreeChangeListenerBase<ServiceFunctionState,
        SfcGeniusSfStateListener> { @Override protected void remove(InstanceIdentifier<ServiceFunctionState> instanceIdentifier, ServiceFunctionState oldSf) { LOG.debug("Received service function state remove event {} {}", instanceIdentifier, oldSf); int numberOfOldPaths = oldSf.getSfServicePath() == null ? 0 : oldSf.getSfServicePath().size(); if (numberOfOldPaths > 0) { String sfName = oldSf.getName().getValue(); executor.execute(() -> interfaceManager.unbindInterfacesOfServiceFunction(sfName)); } } SfcGeniusSfStateListener(ISfcGeniusInterfaceServiceHandler interfaceManager, Executor executor);   }
@Test public void remove() throws Exception { when(serviceFunctionState.getName()).thenReturn(new SfName("SF1")); when(serviceFunctionState.getSfServicePath()).thenReturn(sfpList); when(sfpList.size()).thenReturn(1); sfcGeniusSfStateListener.remove(null, serviceFunctionState); verify(executor).execute(runnableCaptor.capture()); runnableCaptor.getValue().run(); verify(iSfcGeniusInterfaceServiceHandler).unbindInterfacesOfServiceFunction("SF1"); }
@Test public void removeNoPaths() throws Exception { when(serviceFunctionState.getName()).thenReturn(new SfName("SF1")); when(serviceFunctionState.getSfServicePath()).thenReturn(sfpList); when(sfpList.size()).thenReturn(0); sfcGeniusSfStateListener.remove(null, serviceFunctionState); verifyZeroInteractions(executor); verifyZeroInteractions(iSfcGeniusInterfaceServiceHandler); }