### Question:
DimlevelService { @PUT @Path("/{id}") public Response setDimlevel(@PathParam("id") String id, DimlevelBean 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 (bean.dimlevel < 0 || bean.dimlevel > 100) { log(LogService.LOG_INFO, "Tried to perform a dim level operation on a non-dimmer object: " + uuid); response = ElisResponseBuilder.buildMethodNotAllowedResponse(); } else 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 Dimmer) { Dimmer dimmer = (Dimmer) data; dimmer.setDimLevel(bean.dimlevel / 100); bean.device = uuid; bean.dimlevel = (int) (dimmer.getDimLevel() * 100); response = ElisResponseBuilder.buildOKResponse(bean); } else if (data instanceof DeviceSet) { DeviceSet set = (DeviceSet) data; Dimmer dimmer = null; int count = 0; for (Device device : set) { if (device instanceof Dimmer) { dimmer = (Dimmer) device; dimmer.setDimLevel(bean.dimlevel / 100); ++count; } } if (count == 0) { throw new UnsupportedFunctionalityException(); } bean.deviceset = uuid; response = ElisResponseBuilder.buildOKResponse(bean); } else if (user != null) { List<Dimmer> dimmers = utils.getDevices(user, Dimmer.class); if (dimmers.size() == 0) { throw new UnsupportedFunctionalityException(); } for (Dimmer dimmer : dimmers) { dimmer.setDimLevel(bean.dimlevel / 100); } bean.user = uuid; response = ElisResponseBuilder.buildOKResponse(bean); } else { throw new UnsupportedFunctionalityException(); } } catch (ClassCastException | UnsupportedFunctionalityException e) { log(LogService.LOG_INFO, "Tried to perform a dim level operation on a non-dimmer 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; } DimlevelService();  DimlevelService(UserService us, Storage storage, EndpointUtils utils); @GET @Path("/{id}") Response getDimlevel(@PathParam("id") String id); @PUT @Path("/{id}") Response setDimlevel(@PathParam("id") String id,
			DimlevelBean bean);  }### Answer:
@Test public void testSetDimlevel() { try { when(device.getDimLevel()).thenReturn((float) 0.13); } catch (ActuatorFailedException e) {} final Entity<String> requestBody = Entity.entity("{\"dimlevel\": 13}", MediaType.APPLICATION_JSON_TYPE); final String response = target("/dimlevel/" + DID + "/").request(MediaType.APPLICATION_JSON_TYPE).put(requestBody, String.class); EnvelopeBean envelope = gson.fromJson(response, EnvelopeBean.class); DimlevelBean bean = gson.fromJson(gson.toJson(envelope.response), DimlevelBean.class); assertEquals(DID, bean.device); assertEquals(13, bean.dimlevel); }