### Question:
StateManager { public CompletableFuture<UserMessageResult> authorized(int evseId, String tokenId) { return getState(evseId).onAuthorize(evseId, tokenId); } StateManager(Station station, StationStore stationStore, StationMessageSender stationMessageSender); void setStateForEvse(int evseId, AbstractEvseState state); AbstractEvseState getStateForEvse(int eveseId); CompletableFuture<UserMessageResult> cablePlugged(int evseId, int connectorId); CompletableFuture<UserMessageResult> authorized(int evseId, String tokenId); CompletableFuture<UserMessageResult> cableUnplugged(int evseId, int connectorId); void remoteStart(int evseId, int remoteStartId, String tokenId, Connector connector); void remoteStop(int evseId); Station getStation(); StationMessageSender getStationMessageSender(); StationStore getStationStore();  }### Answer:
@Test void verifyDeathorizeInChargingStateSwitchToStopped() { when(evseMock.getEvseState()).thenReturn(new ChargingState()); when(evseMock.hasOngoingTransaction()).thenReturn(true); when(evseMock.getTokenId()).thenReturn(DEFAULT_TOKEN_ID); when(stationStoreMock.getTxStopPointValues()).thenReturn(new OptionList<>(Collections.singletonList(TxStartStopPointVariableValues.AUTHORIZED))); stateManager.authorized(DEFAULT_EVSE_ID, DEFAULT_TOKEN_ID); verify(stationMessageSenderMock).sendAuthorizeAndSubscribe(anyString(), anyList(), subscriberCaptor.capture()); subscriberCaptor.getValue().onResponse(new AuthorizeRequest(), notAuthorizeResponse); verify(evseMock).setEvseState(any(StoppedState.class)); verify(evseMock).tryUnlockConnector(); }
@Test void verifyDeathorizeInChargingStateSwitchToWaitingForAutorization() { when(evseMock.getEvseState()).thenReturn(new ChargingState()); when(evseMock.hasOngoingTransaction()).thenReturn(true); when(evseMock.getTokenId()).thenReturn(DEFAULT_TOKEN_ID); when(stationStoreMock.getTxStopPointValues()).thenReturn(new OptionList<>(Collections.emptyList())); stateManager.authorized(DEFAULT_EVSE_ID, DEFAULT_TOKEN_ID); verify(stationMessageSenderMock).sendAuthorizeAndSubscribe(anyString(), anyList(), subscriberCaptor.capture()); subscriberCaptor.getValue().onResponse(new AuthorizeRequest(), notAuthorizeResponse); verify(evseMock).setEvseState(any(WaitingForAuthorizationState.class)); verify(evseMock).tryUnlockConnector(); }