### Question:
RequestDiagnosticsJsonCommandHandler 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(), RequestDiagnosticsCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestDiagnosticsCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { RequestDiagnosticsApiCommand command = gson.fromJson(commandObject, RequestDiagnosticsApiCommand.class); commandGateway.send(new RequestDiagnosticsCommand(csId, new DiagnosticsUploadSettings(command.getTargetLocation()), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Data transfer 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 testHandler() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{targetLocation:'LOC001'}", JsonObject.class); handler.handle(OperatorApiJsonTestUtils.CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }
@Test(expected = NullPointerException.class) public void testInvalidJsonProperty() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{target:'LOC001'}", JsonObject.class); handler.handle(OperatorApiJsonTestUtils.CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }
@Test(expected = IllegalArgumentException.class) public void testInvalidJsonPropertyType() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{targetLocation:{location:'LOC001'}}", JsonObject.class); handler.handle(OperatorApiJsonTestUtils.CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }