@Override public ZonedDateTime seed(SharedSessionContractImplementor session) { return ZonedDateTime.now(); }
@Override public ZonedDateTime next(ZonedDateTime current, SharedSessionContractImplementor session) { return ZonedDateTime.now(); }
AbstractRetryEvent(String name, int numberOfAttempts, Throwable lastThrowable) { this.name = name; this.numberOfAttempts = numberOfAttempts; this.creationTime = ZonedDateTime.now(); this.lastThrowable = lastThrowable; }
AbstractCircuitBreakerEvent(String circuitBreakerName) { this.circuitBreakerName = circuitBreakerName; this.creationTime = ZonedDateTime.now(); }
public static DateTimeValue now( Clock clock ) { return new DateTimeValue( ZonedDateTime.now( clock ) ); }
private static String getWalletFileName(WalletFile walletFile) { DateTimeFormatter format = DateTimeFormatter.ofPattern( "'UTC--'yyyy-MM-dd'T'HH-mm-ss.nVV'--'"); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); return now.format(format) + walletFile.getAddress() + ".json"; }
public String getBearerToken(String subject) { checkState(jwtSigner.isPresent(), "not configured"); JwtBuilder jwt = Jwts.builder() .setSubject(subject) .setExpiration(Date.from(ZonedDateTime.now().plusMinutes(5).toInstant())); jwtSigner.get().accept(jwt); jwtKeyId.ifPresent(keyId -> jwt.setHeaderParam(KEY_ID, keyId)); jwtIssuer.ifPresent(jwt::setIssuer); jwtAudience.ifPresent(jwt::setAudience); return jwt.compact(); }
private void createDashboardConfigFile() throws IOException { try (FileWriter fw = createOrGetFile(webDir, "config")) { fw.write(createConfigJson(DashboardConfiguration.from(webRefreshIntervalMillis, ZonedDateTime.now()))); fw.flush(); } catch (IOException ioe) { LOG.error("Failed to write config file."); throw ioe; } }
@RequirePOST public HttpResponse doGenerateNewToken(@AncestorInPath User u, @QueryParameter String newTokenName) throws IOException { if(!hasCurrentUserRightToGenerateNewToken(u)){ return HttpResponses.forbidden(); } final String tokenName; if (StringUtils.isBlank(newTokenName)) { tokenName = String.format("Token created on %s", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); }else{ tokenName = newTokenName; } ApiTokenProperty p = u.getProperty(ApiTokenProperty.class); if (p == null) { p = forceNewInstance(u, false); u.addProperty(p); } ApiTokenStore.TokenUuidAndPlainValue tokenUuidAndPlainValue = p.tokenStore.generateNewToken(tokenName); u.save(); return HttpResponses.okJSON(new HashMap<String, String>() {{ put("tokenUuid", tokenUuidAndPlainValue.tokenUuid); put("tokenName", tokenName); put("tokenValue", tokenUuidAndPlainValue.plainValue); }}); }
@Test public void shouldFailWhenZonedDateTimeIsSentWithRun() throws Exception { testFailureWithV2Value( ValueUtils.of( ZonedDateTime.now() ), "ZonedDateTime" ); }
@Test public void lastModified() { ZonedDateTime now = ZonedDateTime.now(); String body = "foo"; Mono<EntityResponse<String>> result = EntityResponse.fromObject(body).lastModified(now).build(); Long expected = now.toInstant().toEpochMilli() / 1000; StepVerifier.create(result) .expectNextMatches(response -> expected.equals(response.headers().getLastModified() / 1000)) .expectComplete() .verify(); }
@Test public void lastModified() { ZonedDateTime now = ZonedDateTime.now(); Mono<ServerResponse> result = ServerResponse.ok().lastModified(now).build(); Long expected = now.toInstant().toEpochMilli() / 1000; StepVerifier.create(result) .expectNextMatches(response -> expected.equals(response.headers().getLastModified() / 1000)) .expectComplete() .verify(); }
@Test public void shouldCallExternalErrorOnDateTimeWithZoneName() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( ZonedDateTime.now() ), "ZonedDateTime values cannot be unpacked with this version of bolt." ); }
@Test public void testSerialization() { JsonCodec<AtopSplit> codec = JsonCodec.jsonCodec(AtopSplit.class); ZonedDateTime now = ZonedDateTime.now(ZoneId.of("+01:23")); AtopSplit split = new AtopSplit(AtopTable.DISKS, HostAddress.fromParts("localhost", 123), now.toEpochSecond(), now.getZone()); AtopSplit decoded = codec.fromJson(codec.toJson(split)); assertEquals(decoded.getTable(), split.getTable()); assertEquals(decoded.getHost(), split.getHost()); assertEquals(decoded.getDate(), split.getDate()); assertEquals(decoded.getEpochSeconds(), split.getEpochSeconds()); assertEquals(decoded.getTimeZone(), split.getTimeZone()); } }
@Test @FrozenClockRule.TimeZone( "Europe/Stockholm" ) public void shouldAcquireCurrentDateTime() { assertEqualTemporal( datetime( ZonedDateTime.now( clock ) ), DateTimeValue.now( clock ) ); assertEqualTemporal( // Using the named UTC timezone datetime( ZonedDateTime.now( clock.withZone( "UTC" ) ) ), DateTimeValue.now( clock, "UTC" ) ); assertEqualTemporal( // Using the timezone defined as 0 hours offset from UTC datetime( ZonedDateTime.now( clock.withZone( UTC ) ) ), DateTimeValue.now( clock, "Z" ) ); }
@Test public void notModifiedLastModified() { ZonedDateTime now = ZonedDateTime.now(); ZonedDateTime oneMinuteBeforeNow = now.minus(1, ChronoUnit.MINUTES); RenderingResponse responseMono = RenderingResponse.create("bar") .header(HttpHeaders.LAST_MODIFIED, DateTimeFormatter.RFC_1123_DATE_TIME.format(oneMinuteBeforeNow)) .build() .block(); MockServerHttpRequest request = MockServerHttpRequest.get("http://example.com") .header(HttpHeaders.IF_MODIFIED_SINCE, DateTimeFormatter.RFC_1123_DATE_TIME.format(now)) .build(); MockServerWebExchange exchange = MockServerWebExchange.from(request); responseMono.writeTo(exchange, DefaultServerResponseBuilderTests.EMPTY_CONTEXT); MockServerHttpResponse response = exchange.getResponse(); assertEquals(HttpStatus.NOT_MODIFIED, response.getStatusCode()); StepVerifier.create(response.getBody()) .expectError(IllegalStateException.class) .verify(); }
private static Stream<AnyValue> unsupportedValues() { return Stream.of( nodeValue( 42, stringArray( "Person" ), EMPTY_MAP ), newRelationshipValue(), pointValue( CoordinateReferenceSystem.WGS84, new double[2] ), byteArray( new byte[]{1, 2, 3} ), Values.of( Duration.ofHours( 1 ) ), Values.of( LocalDate.now() ), Values.of( LocalTime.now() ), Values.of( OffsetTime.now() ), Values.of( LocalDateTime.now() ), Values.of( ZonedDateTime.now() ) ); }
@Test public void notModifiedLastModified() { ZonedDateTime now = ZonedDateTime.now(); ZonedDateTime oneMinuteBeforeNow = now.minus(1, ChronoUnit.MINUTES); EntityResponse<String> responseMono = EntityResponse.fromObject("bar") .lastModified(oneMinuteBeforeNow) .build() .block(); MockServerHttpRequest request = MockServerHttpRequest.get("http://example.com") .header(HttpHeaders.IF_MODIFIED_SINCE, DateTimeFormatter.RFC_1123_DATE_TIME.format(now)) .build(); MockServerWebExchange exchange = MockServerWebExchange.from(request); responseMono.writeTo(exchange, DefaultServerResponseBuilderTests.EMPTY_CONTEXT); MockServerHttpResponse response = exchange.getResponse(); assertEquals(HttpStatus.NOT_MODIFIED, response.getStatusCode()); StepVerifier.create(response.getBody()) .expectError(IllegalStateException.class) .verify(); }
@Test public void notModifiedLastModified() { ZonedDateTime now = ZonedDateTime.now(); ZonedDateTime oneMinuteBeforeNow = now.minus(1, ChronoUnit.MINUTES); ServerResponse responseMono = ServerResponse.ok() .lastModified(oneMinuteBeforeNow) .syncBody("bar") .block(); MockServerHttpRequest request = MockServerHttpRequest.get("http://example.com") .header(HttpHeaders.IF_MODIFIED_SINCE, DateTimeFormatter.RFC_1123_DATE_TIME.format(now)) .build(); MockServerWebExchange exchange = MockServerWebExchange.from(request); responseMono.writeTo(exchange, EMPTY_CONTEXT); MockServerHttpResponse response = exchange.getResponse(); assertEquals(HttpStatus.NOT_MODIFIED, response.getStatusCode()); StepVerifier.create(response.getBody()) .expectError(IllegalStateException.class) .verify(); }
@Override public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layoutHandle, SplitSchedulingStrategy splitSchedulingStrategy) { AtopTableLayoutHandle handle = (AtopTableLayoutHandle) layoutHandle; AtopTableHandle table = handle.getTableHandle(); List<ConnectorSplit> splits = new ArrayList<>(); ZonedDateTime end = ZonedDateTime.now(timeZone); for (Node node : nodeManager.getWorkerNodes()) { ZonedDateTime start = end.minusDays(maxHistoryDays - 1).withHour(0).withMinute(0).withSecond(0).withNano(0); while (start.isBefore(end)) { ZonedDateTime splitEnd = start.withHour(23).withMinute(59).withSecond(59).withNano(0); Domain splitDomain = Domain.create(ValueSet.ofRanges(Range.range(TIMESTAMP_WITH_TIME_ZONE, 1000 * start.toEpochSecond(), true, 1000 * splitEnd.toEpochSecond(), true)), false); if (handle.getStartTimeConstraint().overlaps(splitDomain) && handle.getEndTimeConstraint().overlaps(splitDomain)) { splits.add(new AtopSplit(table.getTable(), node.getHostAndPort(), start.toEpochSecond(), start.getZone())); } start = start.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0); } } return new FixedSplitSource(splits); } }