@Test void testDeactivateAlarm() { List<Alarm> returnedAlarms = createAlarms(3, true); when(this.acl.getAlarm(1)).thenReturn(returnedAlarms.get(0)); Entity<Alarm> entity = Entity.entity(returnedAlarms.get(0), MediaType.APPLICATION_JSON); Response response = this.target.path("alarms/de.activate/1").request().post(entity); assertThat(response, status(204)); verify(this.acl).deactivateAlarm(1); }
@GET @Path("alarms/{pathid}") @Produces(MediaType.APPLICATION_JSON) public Alarm getAlarm(@PathParam("pathid") int alarmnumber) { Alarm alarm; try { alarm = this.logic.getAlarm(alarmnumber); } catch (NoSuchElementException e) { throw new WebApplicationException("there is no alarm" + alarmnumber, e, Status.NOT_FOUND); } alarm.setLink(createAlarmPath(alarmnumber)); return alarm; }
AlarmClockResource implements Resource { @GET @Path("alarms/{pathid}") @Produces(MediaType.APPLICATION_JSON) public Alarm getAlarm(@PathParam("pathid") int alarmnumber) { Alarm alarm; try { alarm = this.logic.getAlarm(alarmnumber); } catch (NoSuchElementException e) { throw new WebApplicationException("there is no alarm" + alarmnumber, e, Status.NOT_FOUND); } alarm.setLink(createAlarmPath(alarmnumber)); return alarm; } }
AlarmClockResource implements Resource { @GET @Path("alarms/{pathid}") @Produces(MediaType.APPLICATION_JSON) public Alarm getAlarm(@PathParam("pathid") int alarmnumber) { Alarm alarm; try { alarm = this.logic.getAlarm(alarmnumber); } catch (NoSuchElementException e) { throw new WebApplicationException("there is no alarm" + alarmnumber, e, Status.NOT_FOUND); } alarm.setLink(createAlarmPath(alarmnumber)); return alarm; }  }
AlarmClockResource implements Resource { @GET @Path("alarms/{pathid}") @Produces(MediaType.APPLICATION_JSON) public Alarm getAlarm(@PathParam("pathid") int alarmnumber) { Alarm alarm; try { alarm = this.logic.getAlarm(alarmnumber); } catch (NoSuchElementException e) { throw new WebApplicationException("there is no alarm" + alarmnumber, e, Status.NOT_FOUND); } alarm.setLink(createAlarmPath(alarmnumber)); return alarm; }  @GET @Path("alarms") @Produces(MediaType.APPLICATION_JSON) List<Alarm> getAllAlarms(); @GET @Path("alarms/{pathid}") @Produces(MediaType.APPLICATION_JSON) Alarm getAlarm(@PathParam("pathid") int alarmnumber); @POST @Path("alarms/{pathid}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Alarm editAlarm(@PathParam("pathid") int alarmNumber, Alarm alarmInc); @POST @Path("alarms/de.activate/{pathid}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Alarm activatedeactivateAlarm(@PathParam("pathid") int alarmNumber, Alarm alarmInc); @POST @Path("alarms/delete/{pathid}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Alarm deleteAlarm(@PathParam("pathid") int alarmNumber); @POST @Path("alarms/new") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Alarm newAlarm(Alarm alarm); @POST @Path("alarms/reset") void resetAlarms(); @Override ResourceEntity getPluginDescripion(); }
AlarmClockResource implements Resource { @GET @Path("alarms/{pathid}") @Produces(MediaType.APPLICATION_JSON) public Alarm getAlarm(@PathParam("pathid") int alarmnumber) { Alarm alarm; try { alarm = this.logic.getAlarm(alarmnumber); } catch (NoSuchElementException e) { throw new WebApplicationException("there is no alarm" + alarmnumber, e, Status.NOT_FOUND); } alarm.setLink(createAlarmPath(alarmnumber)); return alarm; }  @GET @Path("alarms") @Produces(MediaType.APPLICATION_JSON) List<Alarm> getAllAlarms(); @GET @Path("alarms/{pathid}") @Produces(MediaType.APPLICATION_JSON) Alarm getAlarm(@PathParam("pathid") int alarmnumber); @POST @Path("alarms/{pathid}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Alarm editAlarm(@PathParam("pathid") int alarmNumber, Alarm alarmInc); @POST @Path("alarms/de.activate/{pathid}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Alarm activatedeactivateAlarm(@PathParam("pathid") int alarmNumber, Alarm alarmInc); @POST @Path("alarms/delete/{pathid}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Alarm deleteAlarm(@PathParam("pathid") int alarmNumber); @POST @Path("alarms/new") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Alarm newAlarm(Alarm alarm); @POST @Path("alarms/reset") void resetAlarms(); @Override ResourceEntity getPluginDescripion(); static final String PATH; }