### Question:
RerouteService { public void processManualRerouteRequest(MessageSender sender, String correlationId, FlowRerouteRequest request) { Optional<Flow> flow = flowRepository.findById(request.getFlowId()); FlowThrottlingData flowThrottlingData = getFlowThrottlingDataBuilder(flow.orElse(null)) .correlationId(correlationId) .affectedIsl(request.getAffectedIsl()) .force(request.isForce()) .effectivelyDown(request.isEffectivelyDown()) .reason(request.getReason()) .build(); sender.emitManualRerouteCommand(request.getFlowId(), flowThrottlingData); } RerouteService(PersistenceManager persistenceManager); void rerouteAffectedFlows(MessageSender sender, String correlationId, RerouteAffectedFlows command); void rerouteInactiveAffectedFlows(MessageSender sender, String correlationId,
                                             SwitchId switchId); void rerouteInactiveFlows(MessageSender sender, String correlationId, RerouteInactiveFlows command); Collection<FlowPath> getAffectedFlowPaths(SwitchId switchId, int port); List<FlowPath> getPathsForSwapping(Collection<FlowPath> paths); List<FlowWithAffectedPaths> groupPathsForRerouting(Collection<FlowPath> paths); Set<Flow> groupAffectedPinnedFlows(Collection<FlowPath> paths); Map<Flow, Set<PathId>> getInactiveFlowsForRerouting(); Set<Flow> getAffectedInactiveFlowsForRerouting(SwitchId switchId); void processManualRerouteRequest(MessageSender sender, String correlationId, FlowRerouteRequest request); void processSingleSwitchFlowStatusUpdate(SwitchStateChanged request);  }### Answer:
@Test public void processManualRerouteRequest() { FlowRepository flowRepository = mock(FlowRepository.class); when(flowRepository.findById(regularFlow.getFlowId())) .thenReturn(Optional.of(regularFlow)); RepositoryFactory repositoryFactory = mock(RepositoryFactory.class); when(repositoryFactory.createFlowRepository()) .thenReturn(flowRepository); PersistenceManager persistenceManager = mock(PersistenceManager.class); when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory); when(persistenceManager.getTransactionManager()).thenReturn(transactionManager); RerouteService rerouteService = new RerouteService(persistenceManager); FlowRerouteRequest request = new FlowRerouteRequest(regularFlow.getFlowId(), true, true, false, Collections.emptySet(), "reason"); rerouteService.processManualRerouteRequest(carrier, CORRELATION_ID, request); FlowThrottlingData expected = FlowThrottlingData.builder() .correlationId(CORRELATION_ID) .priority(regularFlow.getPriority()) .timeCreate(regularFlow.getTimeCreate()) .affectedIsl(Collections.emptySet()) .force(true) .effectivelyDown(true) .reason("reason") .build(); verify(carrier).emitManualRerouteCommand(eq(regularFlow.getFlowId()), eq(expected)); }