下面列出了java.time.OffsetDateTime#plusMinutes ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void findByCreatedAtBetween() {
OffsetDateTime time = DateUtils.createCurrentDateTimestamp();
OffsetDateTime startDate = time.minusHours(1);
OffsetDateTime endDate = time.plusHours(1);
OffsetDateTime createdAt = time.minusHours(3);
AlertNotificationModel entity = createNotificationModel(createdAt);
notificationManager.saveAllNotifications(List.of(entity));
createdAt = time.plusMinutes(1);
AlertNotificationModel entityToFind1 = createNotificationModel(createdAt);
createdAt = time.plusMinutes(5);
AlertNotificationModel entityToFind2 = createNotificationModel(createdAt);
createdAt = time.plusHours(3);
entity = createNotificationModel(createdAt);
notificationManager.saveAllNotifications(List.of(entity));
notificationManager.saveAllNotifications(List.of(entityToFind1));
notificationManager.saveAllNotifications(List.of(entityToFind2));
List<AlertNotificationModel> foundList = notificationManager.findByCreatedAtBetween(startDate, endDate);
assertEquals(2, foundList.size());
assertNotificationModel(entityToFind1, foundList.get(0));
assertNotificationModel(entityToFind2, foundList.get(1));
}
@Test
public void testDeleteNotificationList() {
OffsetDateTime time = DateUtils.createCurrentDateTimestamp();
OffsetDateTime startDate = time.minusHours(1);
OffsetDateTime endDate = time.plusHours(1);
OffsetDateTime createdAt = time.minusHours(3);
AlertNotificationModel entity = createNotificationModel(createdAt);
notificationManager.saveAllNotifications(List.of(entity));
OffsetDateTime createdAtInRange = time.plusMinutes(1);
AlertNotificationModel entityToFind1 = createNotificationModel(createdAtInRange);
createdAtInRange = time.plusMinutes(5);
AlertNotificationModel entityToFind2 = createNotificationModel(createdAtInRange);
OffsetDateTime createdAtLater = time.plusHours(3);
entity = createNotificationModel(createdAtLater);
notificationManager.saveAllNotifications(List.of(entity));
notificationManager.saveAllNotifications(List.of(entityToFind1));
notificationManager.saveAllNotifications(List.of(entityToFind2));
List<AlertNotificationModel> foundList = notificationManager.findByCreatedAtBetween(startDate, endDate);
assertEquals(4, notificationContentRepository.count());
notificationManager.deleteNotificationList(foundList);
assertEquals(2, notificationContentRepository.count());
}
@Test
public void testGetTimes() {
OffsetDateTime start = DateUtils.createCurrentDateTimestamp();
OffsetDateTime end = start.plusMinutes(5);
DateRange dateRange = DateRange.of(start, end);
assertEquals(start, dateRange.getStart());
assertEquals(end, dateRange.getEnd());
}
@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1 })
public void testAlertIsOlderButCloseSnapshot(String versionSuffix) {
UpdateChecker updateChecker = getEmptyUpdateChecker();
OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
OffsetDateTime dockerTagDate = alertTime.plusMinutes(20);
UpdateModel updateModel = updateChecker.getUpdateModel("1.0.0-" + versionSuffix, formatDate(alertTime, DOCKER_DATE_FORMAT), "1.0.0", formatDate(dockerTagDate, DOCKER_DATE_FORMAT), null);
assertTrue(updateModel.getUpdatable());
}
@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1 })
public void testAlertIsOlderSnapshot(String versionSuffix) {
UpdateChecker updateChecker = getEmptyUpdateChecker();
OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
OffsetDateTime dockerTagDate = alertTime.plusMinutes(80);
UpdateModel updateModel = updateChecker.getUpdateModel("1.0.0-" + versionSuffix, formatDate(alertTime, DOCKER_DATE_FORMAT), "1.0.0", formatDate(dockerTagDate, DOCKER_DATE_FORMAT), null);
assertTrue(updateModel.getUpdatable());
}
@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1 })
public void testAlertIsOlderButCloseBothSnapshot(String versionSuffix) {
UpdateChecker updateChecker = getEmptyUpdateChecker();
OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
OffsetDateTime dockerTagDate = alertTime.plusMinutes(20);
UpdateModel updateModel = updateChecker.getUpdateModel("1.0.0-" + versionSuffix, formatDate(alertTime, DOCKER_DATE_FORMAT), "1.0.0-" + versionSuffix, formatDate(dockerTagDate, DOCKER_DATE_FORMAT), null);
assertFalse(updateModel.getUpdatable());
}
@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1 })
public void testAlertIsOlderBothSnapshot(String versionSuffix) {
UpdateChecker updateChecker = getEmptyUpdateChecker();
OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
OffsetDateTime dockerTagDate = alertTime.plusMinutes(80);
UpdateModel updateModel = updateChecker.getUpdateModel("1.0.0-" + versionSuffix, formatDate(alertTime, DOCKER_DATE_FORMAT), "1.0.0-" + versionSuffix, formatDate(dockerTagDate, DOCKER_DATE_FORMAT), null);
assertTrue(updateModel.getUpdatable());
}
@Test
public void test_plusMinutes() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(30);
assertEquals(test, OffsetDateTime.of(2008, 6, 30, 12, 0, 59, 0, OFFSET_PONE));
}
@Test
public void test_plusMinutes_zero() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(0);
assertSame(test, base);
}
@Test
public void test_plusMinutes() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(30);
assertEquals(test, OffsetDateTime.of(2008, 6, 30, 12, 0, 59, 0, OFFSET_PONE));
}
@Test
public void test_plusMinutes_zero() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(0);
assertSame(test, base);
}
@Test
public void test_plusMinutes_zero() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(0);
assertSame(test, base);
}
@Test
public void test_plusMinutes_zero() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(0);
assertSame(test, base);
}
@Test
public void test_plusMinutes_zero() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(0);
assertSame(test, base);
}
@Test
public void test_plusMinutes() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(30);
assertEquals(test, OffsetDateTime.of(2008, 6, 30, 12, 0, 59, 0, OFFSET_PONE));
}
@Test
public void test_plusMinutes_zero() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(0);
assertSame(test, base);
}
@Test
public void test_plusMinutes() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(30);
assertEquals(test, OffsetDateTime.of(2008, 6, 30, 12, 0, 59, 0, OFFSET_PONE));
}
@Test
public void test_plusMinutes() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(30);
assertEquals(test, OffsetDateTime.of(2008, 6, 30, 12, 0, 59, 0, OFFSET_PONE));
}
@Test
public void test_plusMinutes() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(30);
assertEquals(test, OffsetDateTime.of(2008, 6, 30, 12, 0, 59, 0, OFFSET_PONE));
}
@Test
public void test_plusMinutes() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.plusMinutes(30);
assertEquals(test, OffsetDateTime.of(2008, 6, 30, 12, 0, 59, 0, OFFSET_PONE));
}