Java Code Examples for java.time.OffsetDateTime#minusMinutes()

The following examples show how to use java.time.OffsetDateTime#minusMinutes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultAuditUtilityTest.java    From blackduck-alert with Apache License 2.0 6 votes vote down vote up
@Test
public void findFirstByJobIdNotNullTest() {
    OffsetDateTime timeLastSent = DateUtils.createCurrentDateTimestamp();
    OffsetDateTime timeCreated = timeLastSent.minusMinutes(10L);
    AuditEntryStatus status = AuditEntryStatus.PENDING;
    UUID testUUID = UUID.randomUUID();

    AuditEntryRepository auditEntryRepository = Mockito.mock(AuditEntryRepository.class);
    AuditEntryEntity auditEntryEntity = new AuditEntryEntity(testUUID, timeCreated, timeLastSent, status.name(), null, null);
    Mockito.when(auditEntryRepository.findFirstByCommonConfigIdOrderByTimeLastSentDesc(Mockito.any(UUID.class))).thenReturn(Optional.of(auditEntryEntity));

    DefaultAuditUtility auditUtility = new DefaultAuditUtility(auditEntryRepository, null, null, null, null);
    AuditJobStatusModel auditJobStatusModel = auditUtility.findFirstByJobId(testUUID).get();

    String testTimeAuditCreated = auditJobStatusModel.getTimeAuditCreated();
    String testTimeLastSent = auditJobStatusModel.getTimeLastSent();
    String testStatus = auditJobStatusModel.getStatus();

    assertTrue(auditUtility.findFirstByJobId(testUUID).isPresent());
    assertEquals(DateUtils.formatDate(timeCreated, DateUtils.AUDIT_DATE_FORMAT), testTimeAuditCreated);
    assertEquals(DateUtils.formatDate(timeLastSent, DateUtils.AUDIT_DATE_FORMAT), testTimeLastSent);
    assertEquals(status.getDisplayName(), testStatus);
}
 
Example 2
Source File: SystemMessageUtilityTestIT.java    From blackduck-alert with Apache License 2.0 6 votes vote down vote up
@Test
public void testFindBetweenDateRange() {
    List<SystemMessageEntity> expectedMessages = createSystemMessageList();
    Collections.reverse(expectedMessages);
    OffsetDateTime currentDateTime = DateUtils.createCurrentDateTimestamp();
    OffsetDateTime startTime = currentDateTime.minusMinutes(10);
    List<SystemMessageEntity> savedMessages = new ArrayList<>(expectedMessages);
    savedMessages.add(new SystemMessageEntity(currentDateTime, SEVERITY, "content", TYPE));
    savedMessages.add(new SystemMessageEntity(startTime.minusMinutes(15), SEVERITY, "content", TYPE));
    savedMessages.add(new SystemMessageEntity(currentDateTime.plusMinutes(5), SEVERITY, "content", TYPE));
    systemMessageRepository.saveAll(savedMessages);
    DateRange dateRange = DateRange.of(startTime, currentDateTime);
    List<SystemMessageModel> actualMessageList = defaultSystemMessageUtility.findBetween(dateRange);
    assertNotNull(actualMessageList);
    assertEquals(MESSAGE_COUNT, actualMessageList.size());
    assertEquals(expectedMessages.size(), actualMessageList.size());
}
 
Example 3
Source File: UpdateCheckerTest.java    From blackduck-alert with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1 })
public void testAlertIsNewerButCloseBothSnapshot(String versionSuffix) {
    UpdateChecker updateChecker = getEmptyUpdateChecker();

    OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
    OffsetDateTime dockerTagDate = alertTime.minusMinutes(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());
}
 
Example 4
Source File: UpdateCheckerTest.java    From blackduck-alert with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1 })
public void testAlertIsNewerDateBothSnapshot(String versionSuffix) {
    UpdateChecker updateChecker = getEmptyUpdateChecker();

    OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
    OffsetDateTime dockerTagDate = alertTime.minusMinutes(80);

    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());
}
 
Example 5
Source File: SystemMessageUtilityTestIT.java    From blackduck-alert with Apache License 2.0 5 votes vote down vote up
private List<SystemMessageEntity> createSystemMessageList() {
    List<SystemMessageEntity> messages = new ArrayList<>(MESSAGE_COUNT);
    OffsetDateTime dateTime = DateUtils.createCurrentDateTimestamp();
    for (int index = 0; index < MESSAGE_COUNT; index++) {
        dateTime = dateTime.minusMinutes(1);
        messages.add(new SystemMessageEntity(dateTime, "severity_" + index, "content_" + index, TYPE + "_" + index));
    }
    return messages;
}
 
Example 6
Source File: TCKOffsetDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes() {
    OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(30);
    assertEquals(test, OffsetDateTime.of(2008, 6, 30, 11, 0, 59, 0, OFFSET_PONE));
}
 
Example 7
Source File: TCKOffsetDateTime.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes() {
    OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(30);
    assertEquals(test, OffsetDateTime.of(2008, 6, 30, 11, 0, 59, 0, OFFSET_PONE));
}
 
Example 8
Source File: TestOffsetDateTime.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(0);
    assertSame(test, base);
}
 
Example 9
Source File: TCKOffsetDateTime.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes() {
    OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(30);
    assertEquals(test, OffsetDateTime.of(2008, 6, 30, 11, 0, 59, 0, OFFSET_PONE));
}
 
Example 10
Source File: TestOffsetDateTime.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test
public void test_minusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(0);
    assertSame(test, base);
}
 
Example 11
Source File: TCKOffsetDateTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes() {
    OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(30);
    assertEquals(test, OffsetDateTime.of(2008, 6, 30, 11, 0, 59, 0, OFFSET_PONE));
}
 
Example 12
Source File: TestOffsetDateTime.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(0);
    assertSame(test, base);
}
 
Example 13
Source File: TestOffsetDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(0);
    assertSame(test, base);
}
 
Example 14
Source File: TestOffsetDateTime.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(0);
    assertSame(test, base);
}
 
Example 15
Source File: TCKOffsetDateTime.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes() {
    OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(30);
    assertEquals(test, OffsetDateTime.of(2008, 6, 30, 11, 0, 59, 0, OFFSET_PONE));
}
 
Example 16
Source File: TestOffsetDateTime.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(0);
    assertSame(test, base);
}
 
Example 17
Source File: TCKOffsetDateTime.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes() {
    OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(30);
    assertEquals(test, OffsetDateTime.of(2008, 6, 30, 11, 0, 59, 0, OFFSET_PONE));
}
 
Example 18
Source File: TestOffsetDateTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(0);
    assertSame(test, base);
}
 
Example 19
Source File: TestOffsetDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(0);
    assertSame(test, base);
}
 
Example 20
Source File: TestOffsetDateTime.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_minusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.minusMinutes(0);
    assertSame(test, base);
}