本文整理汇总了Java中org.joda.time.DateMidnight.now方法的典型用法代码示例。如果您正苦于以下问题:Java DateMidnight.now方法的具体用法?Java DateMidnight.now怎么用?Java DateMidnight.now使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateMidnight
的用法示例。
在下文中一共展示了DateMidnight.now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureThrowsIfEndDateIsBeforeStartDate
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void ensureThrowsIfEndDateIsBeforeStartDate() {
DateMidnight startDate = DateMidnight.now();
DateMidnight endDateBeforeStartDate = startDate.minusDays(1);
new Period(startDate, endDateBeforeStartDate, DayLength.FULL);
}
示例2: ensureSetLastModificationDateOnInitialization
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureSetLastModificationDateOnInitialization() {
Person person = TestDataCreator.createPerson();
DateMidnight now = DateMidnight.now();
Overtime overtime = new Overtime(person, now.minusDays(2), now.plusDays(4), BigDecimal.ONE);
Assert.assertNotNull("Should not be null", overtime.getLastModificationDate());
Assert.assertEquals("Wrong last modification date", now, overtime.getLastModificationDate());
}
示例3: ensureThrowsIfGettingStartDateOnACorruptedOvertime
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test(expected = IllegalStateException.class)
public void ensureThrowsIfGettingStartDateOnACorruptedOvertime() throws IllegalAccessException {
Person person = TestDataCreator.createPerson();
DateMidnight now = DateMidnight.now();
Overtime overtime = new Overtime(person, now.minusDays(2), now, BigDecimal.ONE);
Field startDateField = ReflectionUtils.findField(Overtime.class, "startDate");
startDateField.setAccessible(true);
startDateField.set(overtime, null);
overtime.getStartDate();
}
示例4: ensureCountsTotalHoursCorrectly
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
@Rollback
@Ignore("Currently disabled as integration tests broke during the migration to Spring Boot.")
public void ensureCountsTotalHoursCorrectly() {
Person person = TestDataCreator.createPerson();
personDAO.save(person);
Person otherPerson = TestDataCreator.createPerson();
personDAO.save(otherPerson);
DateMidnight now = DateMidnight.now();
// Overtime for person
overtimeDAO.save(new Overtime(person, now, now.plusDays(2), new BigDecimal("3")));
overtimeDAO.save(new Overtime(person, now.plusDays(5), now.plusDays(10), new BigDecimal("0.5")));
overtimeDAO.save(new Overtime(person, now.minusDays(8), now.minusDays(4), new BigDecimal("-1")));
// Overtime for other person
overtimeDAO.save(new Overtime(otherPerson, now.plusDays(5), now.plusDays(10), new BigDecimal("5")));
BigDecimal totalHours = overtimeDAO.calculateTotalHoursForPerson(person);
Assert.assertNotNull("Should not be null", totalHours);
Assert.assertEquals("Total hours calculated wrongly", new BigDecimal("2.5").setScale(1,
BigDecimal.ROUND_UNNECESSARY), totalHours.setScale(1, BigDecimal.ROUND_UNNECESSARY));
}
示例5: ensureReturnsCorrectEndDate
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureReturnsCorrectEndDate() {
Person person = TestDataCreator.createPerson();
DateMidnight now = DateMidnight.now();
Overtime overtime = new Overtime(person, now.minusDays(2), now, BigDecimal.ONE);
Assert.assertNotNull("Should not be null", overtime.getEndDate());
Assert.assertEquals("Wrong end date", now, overtime.getEndDate());
}
示例6: ensureCanBeInitializedWithFullDay
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureCanBeInitializedWithFullDay() {
DateMidnight startDate = DateMidnight.now();
DateMidnight endDate = startDate.plusDays(1);
Period period = new Period(startDate, endDate, DayLength.FULL);
Assert.assertEquals("Wrong start date", startDate, period.getStartDate());
Assert.assertEquals("Wrong end date", endDate, period.getEndDate());
Assert.assertEquals("Wrong day length", DayLength.FULL, period.getDayLength());
}
示例7: ensureReturnsCorrectStartDate
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureReturnsCorrectStartDate() {
Person person = TestDataCreator.createPerson();
DateMidnight now = DateMidnight.now();
Overtime overtime = new Overtime(person, now, now.plusDays(2), BigDecimal.ONE);
Assert.assertNotNull("Should not be null", overtime.getStartDate());
Assert.assertEquals("Wrong start date", now, overtime.getStartDate());
}
示例8: ensureCanBeInitializedWithHalfDay
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureCanBeInitializedWithHalfDay() {
DateMidnight date = DateMidnight.now();
Period period = new Period(date, date, DayLength.MORNING);
Assert.assertEquals("Wrong start date", date, period.getStartDate());
Assert.assertEquals("Wrong end date", date, period.getEndDate());
Assert.assertEquals("Wrong day length", DayLength.MORNING, period.getDayLength());
}
示例9: createApplication
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
private Application createApplication(Person person) {
DateMidnight now = DateMidnight.now();
Application application = new Application();
application.setPerson(person);
application.setVacationType(TestDataCreator.createVacationType(VacationCategory.HOLIDAY, "Erholungsurlaub"));
application.setDayLength(DayLength.FULL);
application.setApplicationDate(now);
application.setStartDate(now);
application.setEndDate(now);
application.setApplier(person);
return application;
}
示例10: addUpdateDeleteAbsence
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void addUpdateDeleteAbsence() throws GeneralSecurityException, IOException {
CalendarSettings calendarSettings = settingsService.getSettings().getCalendarSettings();
Person person = new Person("testUser", "Hans", "Wurst", "[email protected]");
Period period = new Period(DateMidnight.now(), DateMidnight.now(), DayLength.MORNING);
AbsenceTimeConfiguration config = new AbsenceTimeConfiguration(Mockito.mock(CalendarSettings.class));
Absence absence = new Absence(person, period, EventType.WAITING_APPLICATION, config);
int eventsBeforeAdd = getCalendarEventCount();
String eventId = googleCalendarSyncProvider.add(absence, calendarSettings).get();
int eventsAfterAdd = getCalendarEventCount();
Absence absenceUpdate = new Absence(person, period, EventType.SICKNOTE, config);
googleCalendarSyncProvider.update(absenceUpdate, eventId, calendarSettings);
int eventsAfterUpdate = getCalendarEventCount();
googleCalendarSyncProvider.delete(eventId, calendarSettings);
int eventsAfterDelete = getCalendarEventCount();
assertTrue(!eventId.isEmpty());
assertEquals(eventsBeforeAdd + 1, eventsAfterAdd);
assertEquals(eventsAfterAdd, eventsAfterUpdate);
assertEquals(eventsAfterDelete, eventsBeforeAdd);
}
示例11: ensureReturnsOnlyWaitingAndAllowedDepartmentApplicationsForLeave
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureReturnsOnlyWaitingAndAllowedDepartmentApplicationsForLeave() {
Person person = Mockito.mock(Person.class);
DateMidnight date = DateMidnight.now();
Person admin1 = TestDataCreator.createPerson("admin1");
Person marketing1 = TestDataCreator.createPerson("marketing1");
Department admins = TestDataCreator.createDepartment("admins");
admins.setMembers(Arrays.asList(admin1, person));
Department marketing = TestDataCreator.createDepartment("marketing");
marketing.setMembers(Arrays.asList(marketing1, person));
Application waitingApplication = Mockito.mock(Application.class);
Mockito.when(waitingApplication.hasStatus(ApplicationStatus.WAITING)).thenReturn(true);
Mockito.when(waitingApplication.hasStatus(ApplicationStatus.ALLOWED)).thenReturn(false);
Application allowedApplication = Mockito.mock(Application.class);
Mockito.when(allowedApplication.hasStatus(ApplicationStatus.WAITING)).thenReturn(false);
Mockito.when(allowedApplication.hasStatus(ApplicationStatus.ALLOWED)).thenReturn(true);
Application otherApplication = Mockito.mock(Application.class);
Mockito.when(otherApplication.hasStatus(ApplicationStatus.WAITING)).thenReturn(false);
Mockito.when(otherApplication.hasStatus(ApplicationStatus.ALLOWED)).thenReturn(false);
Mockito.when(departmentDAO.getAssignedDepartments(person)).thenReturn(Arrays.asList(admins, marketing));
Mockito.when(applicationService.getApplicationsForACertainPeriodAndPerson(Mockito.any(DateMidnight.class),
Mockito.any(DateMidnight.class), Mockito.eq(admin1)))
.thenReturn(Arrays.asList(waitingApplication, otherApplication));
Mockito.when(applicationService.getApplicationsForACertainPeriodAndPerson(Mockito.any(DateMidnight.class),
Mockito.any(DateMidnight.class), Mockito.eq(marketing1)))
.thenReturn(Collections.singletonList(allowedApplication));
List<Application> applications = sut.getApplicationsForLeaveOfMembersInDepartmentsOfPerson(person, date, date);
Assert.assertEquals("Wrong number of applications", 2, applications.size());
Assert.assertTrue("Should contain the waiting application", applications.contains(waitingApplication));
Assert.assertTrue("Should contain the allowed application", applications.contains(allowedApplication));
Assert.assertFalse("Should not contain an application with other status",
applications.contains(otherApplication));
}
示例12: ensureSendWaitingApplicationsReminderNotification
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureSendWaitingApplicationsReminderNotification() throws Exception {
boolean isActive = true;
prepareSettingsWithRemindForWaitingApplications(isActive);
Application shortWaitingApplication = TestDataCreator.createApplication(TestDataCreator.createPerson("leo"), TestDataCreator.createVacationType(VacationCategory.HOLIDAY));
shortWaitingApplication.setApplicationDate(DateMidnight.now());
Application longWaitingApplicationA = TestDataCreator.createApplication(TestDataCreator.createPerson("lea"), TestDataCreator.createVacationType(VacationCategory.HOLIDAY));
longWaitingApplicationA.setApplicationDate(DateMidnight.now().minusDays(3));
Application longWaitingApplicationB = TestDataCreator.createApplication(TestDataCreator.createPerson("heinz"), TestDataCreator.createVacationType(VacationCategory.HOLIDAY));
longWaitingApplicationB.setApplicationDate(DateMidnight.now().minusDays(3));
Application longWaitingApplicationAlreadyRemindedToday = TestDataCreator.createApplication(TestDataCreator.createPerson("heinz"), TestDataCreator.createVacationType(VacationCategory.HOLIDAY));
longWaitingApplicationAlreadyRemindedToday.setApplicationDate(DateMidnight.now().minusDays(3));
DateMidnight today = DateMidnight.now();
longWaitingApplicationAlreadyRemindedToday.setRemindDate(today);
Application longWaitingApplicationAlreadyRemindedEalier = TestDataCreator.createApplication(TestDataCreator.createPerson("heinz"), TestDataCreator.createVacationType(VacationCategory.HOLIDAY));
longWaitingApplicationAlreadyRemindedEalier.setApplicationDate(DateMidnight.now().minusDays(5));
DateMidnight oldRemindDateEarlier = DateMidnight.now().minusDays(3);
longWaitingApplicationAlreadyRemindedEalier.setRemindDate(oldRemindDateEarlier);
List<Application> waitingApplications = Arrays.asList(shortWaitingApplication,
longWaitingApplicationA,
longWaitingApplicationB,
longWaitingApplicationAlreadyRemindedToday,
longWaitingApplicationAlreadyRemindedEalier);
when(applicationService.getApplicationsForACertainState(ApplicationStatus.WAITING)).thenReturn(waitingApplications);
sut.sendWaitingApplicationsReminderNotification();
verify(mailService).sendRemindForWaitingApplicationsReminderNotification(Arrays.asList(longWaitingApplicationA, longWaitingApplicationB, longWaitingApplicationAlreadyRemindedEalier));
assertTrue(longWaitingApplicationA.getRemindDate().isAfter(longWaitingApplicationA.getApplicationDate()));
assertTrue(longWaitingApplicationB.getRemindDate().isAfter(longWaitingApplicationB.getApplicationDate()));
assertTrue(longWaitingApplicationAlreadyRemindedEalier.getRemindDate().isAfter(oldRemindDateEarlier));
assertTrue(longWaitingApplicationAlreadyRemindedToday.getRemindDate().isEqual(today));
}
示例13: ensureThrowsOnNullStartDate
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void ensureThrowsOnNullStartDate() {
new Period(null, DateMidnight.now(), DayLength.FULL);
}
示例14: createOvertimeRecord
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public static Overtime createOvertimeRecord() {
DateMidnight startDate = DateMidnight.now();
DateMidnight endDate = startDate.plusDays(7);
return new Overtime(createPerson(), startDate, endDate, BigDecimal.ONE);
}
示例15: ensureSameDateAsStartAndEndDateIsValidForFullDayPeriod
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureSameDateAsStartAndEndDateIsValidForFullDayPeriod() {
DateMidnight date = DateMidnight.now();
appForm.setDayLength(DayLength.FULL);
appForm.setStartDate(date);
appForm.setEndDate(date);
validator.validate(appForm, errors);
Mockito.verify(errors, Mockito.never()).reject(Mockito.anyString());
}