Ejemplo n.º 1
0
  private void sendReminder(DateTime date) {
    mockStatic(DateTime.class);
    when(DateTime.now()).thenReturn(date);

    Member member = EntityFactory.createMember();
    member.setId(randomLong);
    when(mockMemberService.findActiveMembers()).thenReturn(Lists.newArrayList(member));
    when(mockAbsenceDayService.findByMemberAndMonth(anyLong(), anyInt()))
        .thenReturn(Lists.newArrayListWithExpectedSize(0));

    scheduleService.sendReminderAfternoon();
  }
Ejemplo n.º 2
0
  @Test
  public void generateWorkList() throws Exception {
    DateTime dateTimeMonth = DateTime.now().withDayOfMonth(1).withTimeAtStartOfDay();

    Member member = EntityFactory.createMember();
    member.setId(randomLong);

    List<AbsenceDay> absenceDayList = EntityFactory.createList(EntityFactory::createAbsenceDay);
    List<Task> taskList = EntityFactory.createList(EntityFactory::createTask);

    when(mockMemberService.findActiveMembers()).thenReturn(Collections.singletonList(member));
    when(mockAbsenceDayService.findByMemberAndMonth(randomLong, dateTimeMonth.getMonthOfYear()))
        .thenReturn(absenceDayList);
    when(mockTaskService.findTasksForMember(member)).thenReturn(taskList);

    scheduleService.generateWorkList();

    verify(mockMemberService).findActiveMembers();
    verify(mockAbsenceDayService)
        .findByMemberAndMonth(eq(randomLong), eq(dateTimeMonth.getMonthOfYear()));
    verify(mockWorkService)
        .findOrCreateWorks(eq(member), eq(dateTimeMonth), eq(taskList), eq(absenceDayList));
  }