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