### Question:
RequestReserveNowJsonCommandHandler extends JsonCommandHandler { @Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStationId csId = new ChargingStationId(chargingStationId); if (!commandAuthorizationService.isAuthorized(csId, identityContext.getUserIdentity(), RequestReserveNowCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestReserveNowCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { RequestReserveNowApiCommand command = gson.fromJson(commandObject, RequestReserveNowApiCommand.class); commandGateway.send(new RequestReserveNowCommand(csId, command.getEvseId(), command.getIdentifyingToken(), command.getExpiryDate(), null, identityContext), new CorrelationToken()); } else { throw new IllegalStateException("It is not possible to request a reservation on a charging station that is not registered"); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Reserve now command is not able to parse the payload, is your json correctly formatted?", ex); } }  @Override String getCommandName(); @Override void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext);  }### Answer:
@Test public void testCommand() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{evseId:'1',identifyingToken:{token:'1'},expiryDate:'2014-02-24T12:00:00Z'}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }
@Test(expected = NullPointerException.class) public void testCommandNoDate() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{evseId:'1',identifyingToken:{token:'1'}}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }
@Test(expected = IllegalArgumentException.class) public void testCommandInvalidDate() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{evseId:'1',identifyingToken:{token:'1'},expiryDate:'2014-02-24'}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }
@Test(expected = IllegalArgumentException.class) public void testCommandInvalidStatus() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{evseId:'1',identifyingToken:{token:'1',status:'NEW'},expiryDate:'2014-02-24'}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }