### Question:
ColorService { @PUT @Path("/{id}") public Response setColor(@PathParam("id") String id, ColorBean bean) { Response response = null; UUID uuid = null; ElisDataObject data = null; PlatformUser user = null; logRequest("", id); response = ElisResponseBuilder.buildBadRequestResponse(); try { uuid = UUID.fromString(id); } catch (Exception e) { log(LogService.LOG_WARNING, "Bad UUID"); } if (userService != null && storage != null && uuid != null) { if (storage.objectExists(uuid)) { try { data = storage.readData(uuid); } catch (StorageException e) { try { user = (PlatformUser) storage.readUser(uuid); } catch (StorageException | ClassCastException e1) {} } try { if (data instanceof ColoredLamp) { ColoredLamp lamp = (ColoredLamp) data; lamp.setColor(fromJsonHex(bean.color)); bean.device = uuid; bean.color = toJsonHex(lamp.getColor()); response = ElisResponseBuilder.buildOKResponse(bean); } else if (data instanceof DeviceSet) { DeviceSet set = (DeviceSet) data; ColoredLamp lamp = null; int count = 0; for (Device device : set) { if (device instanceof ColoredLamp) { lamp = (ColoredLamp) device; lamp.setColor(fromJsonHex(bean.color)); ++count; } } if (count == 0) { throw new UnsupportedFunctionalityException(); } bean.color = bean.color.toUpperCase(); bean.deviceset = uuid; response = ElisResponseBuilder.buildOKResponse(bean); } else if (user != null) { List<ColoredLamp> lamps = utils.getDevices(user, ColoredLamp.class); if (lamps.size() == 0) { throw new UnsupportedFunctionalityException(); } for (ColoredLamp lamp : lamps) { lamp.setColor(fromJsonHex(bean.color)); } bean.color = bean.color.toUpperCase(); bean.user = uuid; response = ElisResponseBuilder.buildOKResponse(bean); } else { throw new UnsupportedFunctionalityException(); } } catch (ClassCastException | UnsupportedFunctionalityException e) { log(LogService.LOG_INFO, "Tried to perform a getPowerstate on a non-power switch object: " + uuid); response = ElisResponseBuilder.buildMethodNotAllowedResponse(); } catch (ActuatorFailedException e) { log(LogService.LOG_WARNING, "Couldn't read device status from: " + uuid); response = ElisResponseBuilder.buildServiceUnavailableResponse(); } } else { response = ElisResponseBuilder.buildNotFoundResponse(); } } return response; } ColorService();  ColorService(UserService us, Storage storage, EndpointUtils utils); @GET @Path("/{id}") Response getColor(@PathParam("id") String id); @PUT @Path("/{id}") Response setColor(@PathParam("id") String id,
			ColorBean bean);  }### Answer:
@Test public void testSetColor() { try { when(device.getColor()).thenReturn(255); } catch (ActuatorFailedException e1) {} final Entity<String> requestBody = Entity.entity("{\"color\": \"#0000ff\"}", MediaType.APPLICATION_JSON_TYPE); final String response = target("/color/" + DID + "/").request(MediaType.APPLICATION_JSON_TYPE).put(requestBody, String.class); EnvelopeBean envelope = gson.fromJson(response, EnvelopeBean.class); ColorBean bean = gson.fromJson(gson.toJson(envelope.response), ColorBean.class); assertEquals(DID, bean.device); assertEquals("#0000FF", bean.color); }