List of usage examples for java.time Duration ofDays
public static Duration ofDays(long days)
From source file:com.teradata.benchto.service.BenchmarkService.java
public Duration getSuccessfulExecutionAge(String uniqueName) { Timestamp ended = benchmarkRunRepo.findTimeOfLatestSuccessfulExecution(uniqueName); if (ended == null) { return Duration.ofDays(Integer.MAX_VALUE); }//from w ww. j av a 2 s.com ZonedDateTime endedAsZDT = ZonedDateTime.of(ended.toLocalDateTime(), ZoneId.systemDefault()); return Duration.between(endedAsZDT, currentDateTime()); }
From source file:nu.yona.server.analysis.service.AnalysisEngineService_determineRelevantGoalsTest.java
private ActivityPayload makeAppPayload(Set<ActivityCategoryDto> activityCategories) { return makeAppPayload(activityCategories, Duration.ofDays(0)); }
From source file:com.teradata.benchto.driver.loader.BenchmarkLoaderTest.java
@Test public void allBenchmarks_load_only_not_executed_within_two_days() throws IOException { Duration executionAge = Duration.ofDays(2); withBenchmarkExecutionAge(executionAge); withFrequencyCheckEnabled(true);// w w w . j ava2 s.c o m assertLoadedBenchmarksCount(6).forEach(benchmark -> { Optional<Duration> frequency = benchmark.getFrequency(); if (frequency.isPresent()) { assertThat(frequency.get()).isLessThanOrEqualTo(executionAge); } }); }
From source file:nu.yona.server.analysis.service.AnalysisEngineService_determineRelevantGoalsTest.java
private ActivityPayload makeNetworkPayload(Set<ActivityCategoryDto> activityCategories) { return makeNetworkPayload(activityCategories, Duration.ofDays(0)); }
From source file:com.teradata.benchto.driver.loader.BenchmarkLoaderTest.java
@Test public void allBenchmarks_frequency_check_is_disabled() throws IOException { withBenchmarkExecutionAge(Duration.ofDays(2)); withFrequencyCheckEnabled(false);/*from w w w . j a v a 2 s . co m*/ assertLoadedBenchmarksCount(8); }
From source file:com.vmware.vchs.base.DbaasApi.java
protected long getCycleAsSeconds(String cycle) { checkNotNull(cycle);/* w ww.j av a 2s . c o m*/ String[] cycleValues = cycle.split(":"); int length = cycleValues.length; Duration seconds; if (length == 4) { Duration days = Duration.ofDays(Long.parseLong(cycleValues[length - 4])); Duration hours = days.plusHours(Long.parseLong(cycleValues[length - 3])); Duration minutes = hours.plusMinutes(Long.parseLong(cycleValues[length - 2])); seconds = minutes.plusSeconds(Long.parseLong(cycleValues[length - 1])); } else { throw new FailException("Invalid cycle value" + cycle); } return seconds.getSeconds(); }
From source file:org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfigurationTest.java
@Test public void fromShouldReadXMLConfiguration() throws Exception { DefaultConfigurationBuilder xmlConfiguration = new DefaultConfigurationBuilder(); xmlConfiguration.load(toStream("<configuration>\n" + " <thresholds>\n" + " <threshold>" + " <value>0.85</value>" + " <subjectTemplate>" + SUBJECT_TEMPLATE + "</subjectTemplate>\n" + " <bodyTemplate>" + BODY_TEMPLATE + "</bodyTemplate>\n" + " </threshold>\n" + " <threshold>\n" + " <value>0.98</value>\n" + " <subjectTemplate>" + OTHER_SUBJECT_TEMPLATE + "</subjectTemplate>\n" + " <bodyTemplate>" + OTHER_BODY_TEMPLATE + "</bodyTemplate>\n" + " </threshold>\n" + " </thresholds>\n" + " <subjectTemplate>" + YET_ANOTHER_SUBJECT_TEMPLATE + "</subjectTemplate>\n" + " <bodyTemplate>" + YET_ANOTHER_BODY_TEMPLATE + "</bodyTemplate>\n" + " <gracePeriod>3 days</gracePeriod>\n" + " <name>listener-name</name>\n" + "</configuration>")); QuotaMailingListenerConfiguration result = QuotaMailingListenerConfiguration.from(xmlConfiguration); assertThat(result).isEqualTo(QuotaMailingListenerConfiguration.builder() .addThreshold(new QuotaThreshold(0.85), RenderingInformation.from(BODY_TEMPLATE, SUBJECT_TEMPLATE)) .addThreshold(new QuotaThreshold(0.98), RenderingInformation.from(OTHER_BODY_TEMPLATE, OTHER_SUBJECT_TEMPLATE)) .gracePeriod(Duration.ofDays(3)).subjectTemplate(YET_ANOTHER_SUBJECT_TEMPLATE) .bodyTemplate(YET_ANOTHER_BODY_TEMPLATE).name("listener-name").build()); }
From source file:org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfigurationTest.java
@Test public void fromShouldReadXMLConfigurationWhenRenderingInformationPartiallyOmited() throws Exception { DefaultConfigurationBuilder xmlConfiguration = new DefaultConfigurationBuilder(); xmlConfiguration.load(toStream("<configuration>\n" + " <thresholds>\n" + " <threshold>" + " <value>0.85</value>" + " <bodyTemplate>" + BODY_TEMPLATE + "</bodyTemplate>\n" + " </threshold>\n" + " <threshold>\n" + " <value>0.98</value>\n" + " <subjectTemplate>" + OTHER_SUBJECT_TEMPLATE + "</subjectTemplate>\n" + " </threshold>\n" + " <threshold>\n" + " <value>0.99</value>\n" + " </threshold>\n" + " </thresholds>\n" + " <gracePeriod>3 days</gracePeriod>\n" + " <name>listener-name</name>\n" + "</configuration>")); QuotaMailingListenerConfiguration result = QuotaMailingListenerConfiguration.from(xmlConfiguration); assertThat(result).isEqualTo(QuotaMailingListenerConfiguration.builder() .addThreshold(new QuotaThreshold(0.85), RenderingInformation.from(Optional.of(BODY_TEMPLATE), Optional.empty())) .addThreshold(new QuotaThreshold(0.98), RenderingInformation.from(Optional.empty(), Optional.of(OTHER_SUBJECT_TEMPLATE))) .addThreshold(new QuotaThreshold(0.99), RenderingInformation.from(Optional.empty(), Optional.empty())) .gracePeriod(Duration.ofDays(3)).name("listener-name").build()); }
From source file:org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfigurationTest.java
@Test public void fromShouldAcceptEmptyThreshold() throws Exception { DefaultConfigurationBuilder xmlConfiguration = new DefaultConfigurationBuilder(); xmlConfiguration.load(toStream("<configuration>\n" + " <thresholds></thresholds>\n" + " <gracePeriod>3 days</gracePeriod>\n" + "</configuration>")); QuotaMailingListenerConfiguration result = QuotaMailingListenerConfiguration.from(xmlConfiguration); assertThat(result)//from w ww .j a va 2 s. c om .isEqualTo(QuotaMailingListenerConfiguration.builder().gracePeriod(Duration.ofDays(3)).build()); }