@Test void testNewAlarm() { Alarm newAlarm = new Alarm(1, LocalDateTime.of(2018, 7, 21, 21, 21), true); when(this.acl.setAlarm(1, 21, 21)).thenReturn(newAlarm); when(this.environment.getCurrentLocalDateTime()).thenReturn(LocalDateTime.of(2018, 10, 4, 19, 19)); Entity<Alarm> entity = Entity.entity(newAlarm, MediaType.APPLICATION_JSON); Response response = this.target.path("alarms/new").request().post(entity); assertThat(response, status(200)); Alarm alarmread = response.readEntity(Alarm.class); assertThat(response, status(200)); assertThat(alarmread, is(newAlarm)); }
@POST @Path("alarms/new") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Alarm newAlarm(Alarm alarm) { int day; if (this.environment.getCurrentLocalDateTime().getDayOfMonth() == alarm.getAlarmTime().getDayOfMonth()) { day = -1; } else { day = 1; } alarm.setLink(createAlarmPath(alarm.getId())); return this.logic.setAlarm(day, alarm.getAlarmTime().getHour(), alarm.getAlarmTime().getMinute()); }
AlarmClockResource implements Resource { @POST @Path("alarms/new") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Alarm newAlarm(Alarm alarm) { int day; if (this.environment.getCurrentLocalDateTime().getDayOfMonth() == alarm.getAlarmTime().getDayOfMonth()) { day = -1; } else { day = 1; } alarm.setLink(createAlarmPath(alarm.getId())); return this.logic.setAlarm(day, alarm.getAlarmTime().getHour(), alarm.getAlarmTime().getMinute()); } }
AlarmClockResource implements Resource { @POST @Path("alarms/new") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Alarm newAlarm(Alarm alarm) { int day; if (this.environment.getCurrentLocalDateTime().getDayOfMonth() == alarm.getAlarmTime().getDayOfMonth()) { day = -1; } else { day = 1; } alarm.setLink(createAlarmPath(alarm.getId())); return this.logic.setAlarm(day, alarm.getAlarmTime().getHour(), alarm.getAlarmTime().getMinute()); }  }
AlarmClockResource implements Resource { @POST @Path("alarms/new") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Alarm newAlarm(Alarm alarm) { int day; if (this.environment.getCurrentLocalDateTime().getDayOfMonth() == alarm.getAlarmTime().getDayOfMonth()) { day = -1; } else { day = 1; } alarm.setLink(createAlarmPath(alarm.getId())); return this.logic.setAlarm(day, alarm.getAlarmTime().getHour(), alarm.getAlarmTime().getMinute()); }  @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 { @POST @Path("alarms/new") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Alarm newAlarm(Alarm alarm) { int day; if (this.environment.getCurrentLocalDateTime().getDayOfMonth() == alarm.getAlarmTime().getDayOfMonth()) { day = -1; } else { day = 1; } alarm.setLink(createAlarmPath(alarm.getId())); return this.logic.setAlarm(day, alarm.getAlarmTime().getHour(), alarm.getAlarmTime().getMinute()); }  @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; }