List of usage examples for java.time Instant now
public static Instant now()
From source file:com.pw.ism.heartbeat.InMemoryHeartbeatRepositoryTest.java
@Test public void shouldAddHeartBeat() throws Exception { Heartbeat hb1 = new Heartbeat(); hb1.setCustomer("TEST1"); hb1.setNetwork("NETWORK1"); Heartbeat hb2 = new Heartbeat(); hb2.setCustomer("CUST2"); hb2.setNetwork("NETWORK2"); repo.addHeartbeat(hb1, Instant.now().minusSeconds(5)); repo.addHeartbeat(hb2, Instant.now().minusSeconds(2)); List<Heartbeat> list = repo.getExpiredHeartbeats(6); Assert.isTrue(list.isEmpty());//from w w w . j a va 2s .com list = repo.getExpiredHeartbeats(3); Assert.isTrue(list.contains(hb1)); list = repo.getExpiredHeartbeats(1); Assert.isTrue(list.contains(hb2)); Assert.isTrue(list.contains(hb1)); }
From source file:nl.ctrlaltdev.harbinger.filter.BlacklistFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!ctx.isBlacklisted(request.getRemoteAddr(), Instant.now())) { chain.doFilter(request, response); } else if (response instanceof HttpServletResponse) { ((HttpServletResponse) response).sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); }//from w ww . ja v a2s . c o m }
From source file:cn.edu.zjnu.acm.judge.domain.Contest.java
@JsonIgnore @XmlTransient public boolean isStarted() { return startTime == null || startTime.isBefore(Instant.now()); }
From source file:com.vmware.photon.controller.api.client.resource.TasksApiTest.java
@Test public void testGetTask() throws Throwable { Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_OK); TasksApi tasksApi = new TasksApi(this.restClient); Task task = tasksApi.getTask("foo"); assertEquals(task, responseTask);/* ww w. ja v a2 s . c o m*/ }
From source file:com.vmware.photon.controller.api.client.resource.TasksRestApiTest.java
@Test public void testGetTask() throws Throwable { Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_OK); TasksApi tasksApi = new TasksRestApi(this.restClient); Task task = tasksApi.getTask("foo"); assertEquals(task, responseTask);/* w w w . jav a 2 s . c om*/ }
From source file:cloudfoundry.norouter.f5.PoolMemberDescription.java
public PoolMemberDescription(RouteDetails route) { created = modified = Instant.now(); setApplicationGuid(route.getApplicationGuid()); setApplicationIndex(route.getApplicationIndex()); setPrivateInstanceId(route.getPrivateInstanceId()); }
From source file:io.cfp.auth.service.TokenService.java
/** * Create a Token for a user//from ww w.j a v a 2 s. co m * @param email Email of the token owner * @param isSuperAdmin True if the user is a super admin * @return Token value */ public String create(String email, boolean isSuperAdmin) { JwtBuilder builder = Jwts.builder().setSubject(email) .setExpiration(Date.from(Instant.now().plus(TOKEN_EXPIRATION, ChronoUnit.HOURS))) .signWith(SignatureAlgorithm.HS512, signingKey); if (isSuperAdmin) { builder.claim("superAdmin", true); } return builder.compact(); }
From source file:com.netflix.genie.web.util.UnixProcessCheckerTest.java
/** * Setup for the tests./*from w w w . ja v a 2 s . c o m*/ */ @Before public void setup() { Assume.assumeTrue(SystemUtils.IS_OS_UNIX); this.executor = Mockito.mock(Executor.class); this.tomorrow = Instant.now().plus(1, ChronoUnit.DAYS); // For standard tests this will keep it from dying }
From source file:nl.ctrlaltdev.harbinger.response.BlacklistIpActionTest.java
@Test public void shouldBlacklist() { assertTrue(action.perform(ctx));//from w w w . j a v a2s . c om assertTrue(ctx.isBlacklisted("8.8.8.8", Instant.now())); assertFalse(ctx.isBlacklisted("8.8.8.8", Instant.now().plusSeconds(61))); }
From source file:nl.ctrlaltdev.harbinger.evidence.Evidence.java
public Evidence() { this.timestamp = Instant.now(); }