### Question:
NetworkBfdPortService { public void setup(Endpoint endpoint, int physicalPortNumber) { log.info("BFD-port service receive SETUP request for {} (physical-port:{})", endpoint, physicalPortNumber); BfdPortFsm controller = controllerFactory.produce(persistenceManager, endpoint, physicalPortNumber); BfdPortFsmContext context = BfdPortFsmContext.builder(carrier).build(); handle(controller, BfdPortFsmEvent.HISTORY, context); controllerByLogicalPort.put(controller.getLogicalEndpoint(), controller); controllerByPhysicalPort.put(controller.getPhysicalEndpoint(), controller); IslReference autostartData = autostart.remove(controller.getPhysicalEndpoint()); if (autostartData != null) { context = BfdPortFsmContext.builder(carrier) .islReference(autostartData) .build(); handle(controller, BfdPortFsmEvent.ENABLE, context); } } NetworkBfdPortService(IBfdPortCarrier carrier, PersistenceManager persistenceManager); void setup(Endpoint endpoint, int physicalPortNumber); Endpoint remove(Endpoint logicalEndpoint); void updateLinkStatus(Endpoint logicalEndpoint, LinkStatus linkStatus); void updateOnlineMode(Endpoint endpoint, boolean mode); void enable(Endpoint physicalEndpoint, IslReference reference); void disable(Endpoint physicalEndpoint); void speakerResponse(String key, Endpoint logicalEndpoint, BfdSessionResponse response); void speakerTimeout(String key, Endpoint logicalEndpoint);  }### Answer:
@Test public void enableBeforeSetup() { IslReference reference = new IslReference(alphaEndpoint, betaEndpoint); doEnableBeforeSetup(reference); doAnswer(invocation -> invocation.getArgument(0)) .when(bfdSessionRepository).add(any()); mockSwitchLookup(alphaSwitch); mockSwitchLookup(betaSwitch); mockMissingBfdSession(alphaLogicalEndpoint); when(carrier.setupBfdSession(any(NoviBfdSession.class))).thenReturn(setupRequestKey); service.setup(alphaLogicalEndpoint, alphaEndpoint.getPortNumber()); verify(bfdSessionRepository).add(any(BfdSession.class)); verify(carrier).setupBfdSession(argThat( arg -> arg.getTarget().getDatapath().equals(alphaEndpoint.getDatapath()) && arg.getPhysicalPortNumber() == alphaEndpoint.getPortNumber() && arg.getLogicalPortNumber() == alphaLogicalEndpoint.getPortNumber() && arg.getRemote().getDatapath().equals(betaEndpoint.getDatapath()))); verifyNoMoreInteractions(carrier); }