Example usage for java.time Instant EPOCH

List of usage examples for java.time Instant EPOCH

Introduction

In this page you can find the example usage for java.time Instant EPOCH.

Prototype

Instant EPOCH

To view the source code for java.time Instant EPOCH.

Click Source Link

Document

Constant for the 1970-01-01T00:00:00Z epoch instant.

Usage

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.EPOCH;
    System.out.println(instant.getEpochSecond());

}

From source file:io.pivotal.strepsirrhini.chaosloris.web.EventResourceAssemblerTest.java

@Test
public void toResource() {
    Application application = new Application(UUID.randomUUID());
    application.setId(-1L);/*from   w ww. j a  v  a  2 s  .co  m*/

    Schedule schedule = new Schedule("0 0 * * * *", "hourly");
    schedule.setId(-2L);

    Chaos chaos = new Chaos(application, 0.2, schedule);
    chaos.setId(-3L);

    Event event = new Event(chaos, Instant.EPOCH, Collections.emptyList(), Integer.MIN_VALUE);
    event.setId(-4L);

    EventResourceAssembler.EventResource resource = this.resourceAssembler.toResource(event);

    assertThat(resource.getContent()).isSameAs(event);
    assertThat(resource.getLinks()).hasSize(2);
    assertThat(resource.getLink("chaos")).isNotNull();
}

From source file:io.pivotal.strepsirrhini.chaosloris.web.ChaosResourceAssemblerTest.java

@Test
public void toResource() {
    Application application = new Application(UUID.randomUUID());
    application.setId(-1L);/*from ww w . j  a v a2s.co  m*/

    Schedule schedule = new Schedule("0 0 * * * *", "hourly");
    schedule.setId(-2L);

    Chaos chaos = new Chaos(application, 0.2, schedule);
    chaos.setId(-3L);

    Event event = new Event(chaos, Instant.EPOCH, Collections.emptyList(), Integer.MIN_VALUE);
    event.setId(-4L);

    when(this.eventRepository.findByChaos(chaos)).thenReturn(Collections.singletonList(event));

    ChaosResourceAssembler.ChaosResource resource = this.resourceAssembler.toResource(chaos);

    assertThat(resource.getContent()).isSameAs(chaos);
    assertThat(resource.getLinks()).hasSize(4);
    assertThat(resource.getLink("application")).isNotNull();
    assertThat(resource.getLink("event")).isNotNull();
    assertThat(resource.getLink("schedule")).isNotNull();
}

From source file:org.ulyssis.ipp.snapshot.TestSnapshot.java

@Test
public void testSerializeToJson_DefaultObject() throws Exception {
    Snapshot snapshot = Snapshot.builder(Instant.EPOCH, null).withStartTime(Instant.EPOCH)
            .withEndTime(Instant.EPOCH).build();
    MatcherAssert.assertThat(objectMapper.writeValueAsString(snapshot),
            SameJSONAs.sameJSONAs("{snapshotTime:0,startTime:0,endTime:0,teamTagMap:{},"
                    + "teamStates:{},publicTeamStates:{},statusMessage:\"\",status:NoResults,updateFrequency:3}"));
}

From source file:org.ulyssis.ipp.snapshot.TestSnapshot.java

@Test
public void testSerializeToJson_ComplexerObject() throws Exception {
    Snapshot snapshot = Snapshot.builder(Instant.EPOCH, null).withStartTime(Instant.EPOCH)
            .withEndTime(Instant.EPOCH)
            .withTeamStates(new TeamStates().setStateForTeam(0,
                    new TeamState()
                            .addTagSeenEvent(new Snapshot(Instant.EPOCH),
                                    new TagSeenEvent(Instant.EPOCH, new TagId("ABCD"), 0, 0L))
                            .addTagSeenEvent(null, // TODO: It's not really clean that we're passing null here,
                                    //       but it should work fine nonetheless
                                    new TagSeenEvent(Instant.EPOCH.plus(1000, ChronoUnit.SECONDS),
                                            new TagId("ABCD"), 0, 1L))))
            .withTeamTagMap(new TeamTagMap().addTagToTeam("ABCD", 0)).withStatusMessage("foo").build();
    MatcherAssert.assertThat(objectMapper.writeValueAsString(snapshot), SameJSONAs.sameJSONAs(
            "{\"snapshotTime\":0,statusMessage:foo,\"startTime\":0,\"endTime\":0,\"teamTagMap\":{\"0\":[\"ABCD\"]},"
                    + "\"teamStates\":{\"0\":{\"lastTagSeenEvent\":{\"type\":\"TagSeen\",\"time\":1000,"
                    + "\"tag\":\"ABCD\",\"readerId\":0}, \"tagFragmentCount\":3}}}")
            .allowingExtraUnexpectedFields());
}

From source file:RESTClient.java

@Test
public void hello() throws UnsupportedEncodingException, IOException {

    HistoryDao dao = new HistoryDao();
    dao.setDate(Date.from(Instant.EPOCH));
    dao.setPack("1");
    HistoryListDao dao1 = new HistoryListDao();
    dao1.setDepartement("1");
    ArrayList<HistoryDao> arrayList = new ArrayList<>();
    arrayList.add(dao);/*from  ww w .  j a v a  2s .com*/
    dao1.setHistory(arrayList);
    dao1.setDepartement("1");

    Gson g = new Gson();
    String toJson = g.toJson(dao1);
    logger.log(Level.INFO, "Gson: {0}", toJson);

    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost("http://localhost:8080/sync");
    StringEntity input = new StringEntity(toJson);
    post.setEntity(input);
    HttpResponse response = client.execute(post);
    BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

    String line;
    int statusCode = response.getStatusLine().getStatusCode();
    assertTrue(statusCode == 200);

    while ((line = rd.readLine()) != null) {
        System.out.println(line);
    }

}

From source file:org.pdfsam.ui.StatefullPreferencesStageServiceTest.java

@Test
public void getLatestNewsStageDisplayInstant() {
    assertEquals(Instant.EPOCH, victim.getLatestNewsStageDisplayInstant());
    victim.newsStageDisplayed();//from   w w w. j  a v  a  2s . c  o  m
    assertNotEquals(Instant.EPOCH, victim.getLatestNewsStageDisplayInstant());
}

From source file:com.spotify.apollo.http.server.AsyncContextOngoingRequestTest.java

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    response = new MockHttpServletResponse();

    when(asyncContext.getResponse()).thenReturn(response);

    ongoingRequest = new AsyncContextOngoingRequest(REQUEST, asyncContext, logger,
            RequestMetadataImpl.create(Instant.EPOCH, Optional.empty(), Optional.empty()));
}

From source file:org.pdfsam.ui.StatefullPreferencesStageService.java

public Instant getLatestNewsStageDisplayInstant() {
    return Instant.ofEpochMilli(Preferences.userRoot().node(STAGE_PATH).getLong(NEWS_STAGE_DISPLAY_TIME_KEY,
            Instant.EPOCH.toEpochMilli()));
}

From source file:io.pivotal.strepsirrhini.chaosloris.web.EventControllerTest.java

@Test
public void list() throws Exception {
    Application application = new Application(UUID.randomUUID());
    application.setId(-1L);/*from ww  w  .  j a  v a  2 s  .c  o  m*/

    Schedule schedule = new Schedule("0 0 * * * *", "hourly");
    schedule.setId(-2L);

    Chaos chaos = new Chaos(application, 0.2, schedule);
    chaos.setId(-3L);

    Event event = new Event(chaos, Instant.EPOCH, Collections.emptyList(), Integer.MIN_VALUE);
    event.setId(-4L);

    when(this.eventRepository.findAll(new PageRequest(0, 20)))
            .thenReturn(new PageImpl<>(Collections.singletonList(event)));

    this.mockMvc.perform(get("/events").accept(HAL_JSON)).andExpect(status().isOk())
            .andExpect(jsonPath("$.page").exists()).andExpect(jsonPath("$._embedded.events").value(hasSize(1)))
            .andExpect(jsonPath("$._links.self").exists());
}