### Question:
RequestFirmwareUpdateJsonCommandHandler 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(), RequestFirmwareUpdateCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestFirmwareUpdateCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { UpdateFirmwareApiCommand command = gson.fromJson(commandObject, UpdateFirmwareApiCommand.class); Map<String, String> optionalAttributes = Maps.newHashMap(); if (command.getNumRetries() != null) { optionalAttributes.put(FirmwareUpdateAttributeKey.NUM_RETRIES, command.getNumRetries().toString()); } if (command.getRetryInterval() != null) { optionalAttributes.put(FirmwareUpdateAttributeKey.RETRY_INTERVAL, command.getRetryInterval().toString()); } commandGateway.send(new RequestFirmwareUpdateCommand(csId, command.getLocation(), command.getRetrieveDate(), optionalAttributes, identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Update firmware command 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 testUpdateFirmwareCommand() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{location:'DEURNE',retrieveDate:'2014-02-03T12:00:00Z'}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }
@Test public void testUpdateFirmwareCommandWithOptionalParams() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{location:'DEURNE',retrieveDate:'2014-02-03T12:00:00Z',numRetries:3,retryInterval:60}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }
@Test(expected = IllegalArgumentException.class) public void testInvalidUpdateCommandInvalidDate() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{location:'DEURNE',retrieveDate:'2014-02-03'}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }
@Test(expected = NullPointerException.class) public void testInvalidUpdateCommandInvalidLocation() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{loc:'DEURNE',retrieveDate:'2014-02-03T12:00:00Z'}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }