List of usage examples for java.time ZonedDateTime minusDays
public ZonedDateTime minusDays(long days)
From source file:org.apache.geode.management.internal.cli.commands.ExportLogsDUnitTest.java
@Test public void startAndEndDateCanIncludeLogs() throws Exception { ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault()); ZonedDateTime yesterday = now.minusDays(1); ZonedDateTime tomorrow = now.plusDays(1); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT); CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs"); commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday)); commandStringBuilder.addOption("end-time", dateTimeFormatter.format(tomorrow)); commandStringBuilder.addOption("log-level", "debug"); gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString()); Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet()); verifyZipFileContents(acceptedLogLevels); }
From source file:org.apache.geode.management.internal.cli.commands.ExportLogsDUnitTest.java
@Test public void testExportWithStartAndEndDateTimeFiltering() throws Exception { ZonedDateTime cutoffTime = LocalDateTime.now().atZone(ZoneId.systemDefault()); String messageAfterCutoffTime = "[this message should not show up since it is after cutoffTime]"; LogLine logLineAfterCutoffTime = new LogLine(messageAfterCutoffTime, "info", true); server1.invoke(() -> {//from ww w . ja v a2 s . c o m Logger logger = LogService.getLogger(); logLineAfterCutoffTime.writeLog(logger); }); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(FORMAT); String cutoffTimeString = dateTimeFormatter.format(cutoffTime); CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs"); commandStringBuilder.addOption("start-time", dateTimeFormatter.format(cutoffTime.minusDays(1))); commandStringBuilder.addOption("end-time", cutoffTimeString); commandStringBuilder.addOption("log-level", "debug"); gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString()); expectedMessages.get(server1).add(logLineAfterCutoffTime); Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet()); verifyZipFileContents(acceptedLogLevels); }