### Question:
ChargingStationResource { @POST @Path("/{chargingStationId}/commands") @Consumes(ApiVersion.V1_JSON) public Response executeCommand(@PathParam("chargingStationId") String chargingStationId, String jsonCommand, @Context SecurityContext securityContext) { try { commandService.handleCommand(chargingStationId, jsonCommand, new SimpleUserIdentity(securityContext.getUserPrincipal().getName())); } catch (UserIdentityUnauthorizedException e) { LOG.info("UserIdentityUnauthorizedException while handling command.", e); return Response.status(Response.Status.FORBIDDEN).build(); } return Response.status(Response.Status.ACCEPTED).build(); }  @POST @Path("/{chargingStationId}/commands") @Consumes(ApiVersion.V1_JSON) Response executeCommand(@PathParam("chargingStationId") String chargingStationId, String jsonCommand, @Context SecurityContext securityContext); @GET Response getChargingStations(@Context HttpServletRequest request, @QueryParam(OFFSET_PARAMETER) @DefaultValue(OFFSET_DEFAULT) int offset, @QueryParam(LIMIT_PARAMETER) @DefaultValue(LIMIT_DEFAULT) int limit); void setService(OperatorApiService service); void setCommandService(JsonCommandService commandService);  }### Answer:
@Test public void testExecuteCommand() throws UserIdentityUnauthorizedException { Response response = resource.executeCommand(ChargingStationTestUtils.CHARGING_STATION_ID.getId(), "jsonCommand", mockedSecurityContext); verify(commandService).handleCommand(anyString(), anyString(), any(UserIdentity.class)); assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); }
@Test(expected = IllegalArgumentException.class) public void testExecuteCommandThrowsIllegalArgumentException() throws UserIdentityUnauthorizedException { doThrow(mock(IllegalArgumentException.class)).when(commandService).handleCommand(anyString(), anyString(), any(UserIdentity.class)); resource.executeCommand(ChargingStationTestUtils.CHARGING_STATION_ID.getId(), "jsonCommand", mockedSecurityContext); }