### Question:
NetworkSwitchService { public void switchAddWithHistory(HistoryFacts history) { log.info("Switch service receive switch ADD from history request for {}", history.getSwitchId()); SwitchFsm switchFsm = controllerFactory.produce(persistenceManager, history.getSwitchId(), options); SwitchFsmContext fsmContext = SwitchFsmContext.builder(carrier) .history(history) .build(); controller.put(history.getSwitchId(), switchFsm); controllerExecutor.fire(switchFsm, SwitchFsmEvent.HISTORY, fsmContext); } NetworkSwitchService(ISwitchCarrier carrier, PersistenceManager persistenceManager,
                                NetworkOptions options); void switchAddWithHistory(HistoryFacts history); void switchEvent(SwitchInfoData payload); void switchManagerResponse(SwitchSyncResponse payload, String key); void switchManagerErrorResponse(SwitchSyncErrorData payload, String key); void switchManagerTimeout(SwitchId switchId, String key); void switchBecomeUnmanaged(SwitchId datapath); void switchBecomeManaged(SpeakerSwitchView switchView); void switchPortEvent(PortInfoData payload); void remove(SwitchId datapath);  }### Answer:
@Test public void switchFromHistoryToOffline() { when(switchRepository.findById(alphaDatapath)).thenReturn( Optional.of(Switch.builder().switchId(alphaDatapath) .build())); HistoryFacts history = new HistoryFacts(alphaDatapath); Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build(); Switch betaSwitch = Switch.builder().switchId(betaDatapath).build(); Isl islAtoB = Isl.builder() .srcSwitch(alphaSwitch) .srcPort(1) .destSwitch(betaSwitch) .destPort(1).build(); Isl islAtoB2 = Isl.builder() .srcSwitch(alphaSwitch) .srcPort(2) .destSwitch(betaSwitch) .destPort(2).build(); history.addLink(islAtoB); history.addLink(islAtoB2); NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options); service.switchAddWithHistory(history); verify(carrier).setupPortHandler(Endpoint.of(alphaDatapath, 1), islAtoB); verify(carrier).setupPortHandler(Endpoint.of(alphaDatapath, 2), islAtoB2); verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, 1), OnlineStatus.OFFLINE); verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, 2), OnlineStatus.OFFLINE); }