Search in sources :

Example 6 with Event

use of io.requery.test.model2.Event in project requery by requery.

the class TimeConversionsTest method testInsertReadLocalTime.

@Test
public void testInsertReadLocalTime() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    LocalTime localTimeNow = LocalTime.now();
    event.setId(id);
    event.setLocalTime(localTimeNow);
    data.insert(event);
    event = data.findByKey(Event.class, id);
    Assert.assertEquals(localTimeNow.withNano(0), event.getLocalTime());
}
Also used : LocalTime(java.time.LocalTime) Event(io.requery.test.model2.Event) UUID(java.util.UUID) Test(org.junit.Test)

Example 7 with Event

use of io.requery.test.model2.Event in project requery by requery.

the class TimeConversionsTest method testInsertReadDate.

@Test
public void testInsertReadDate() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    LocalDate localDateNow = LocalDate.now();
    event.setId(id);
    event.setLocalDate(localDateNow);
    data.insert(event);
    event = data.findByKey(Event.class, id);
    Assert.assertEquals(localDateNow, event.getLocalDate());
}
Also used : Event(io.requery.test.model2.Event) UUID(java.util.UUID) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 8 with Event

use of io.requery.test.model2.Event in project requery by requery.

the class UpsertTest method testUpsertUpdate.

@Test
public void testUpsertUpdate() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    event.setId(id);
    event.setName("event1");
    data.insert(event);
    Event event2 = new Event();
    event2.setId(id);
    event2.setName("event2");
    data.upsert(event2);
    List<Event> events = data.select(Event.class).get().toList();
    assertTrue(events.size() == 1);
    assertEquals("event2", events.iterator().next().getName());
}
Also used : Event(io.requery.test.model3.Event) UUID(java.util.UUID) Test(org.junit.Test)

Example 9 with Event

use of io.requery.test.model2.Event in project requery by requery.

the class UpsertTest method testUpsertOneToManyEmptyCollection.

@Test
public void testUpsertOneToManyEmptyCollection() {
    Event event1 = new Event();
    event1.setId(UUID.randomUUID());
    Place place = new Place();
    place.setId(UUID.randomUUID().toString());
    place.setName("place");
    place.getEvents().add(event1);
    place.getEvents().clear();
    data.upsert(place);
}
Also used : Event(io.requery.test.model3.Event) Place(io.requery.test.model3.Place) Test(org.junit.Test)

Example 10 with Event

use of io.requery.test.model2.Event in project requery by requery.

the class UpsertTest method testUpsertOneToMany.

@Test
public void testUpsertOneToMany() {
    Event event = new Event();
    event.setId(UUID.randomUUID());
    Place place = new Place();
    place.setId(UUID.randomUUID().toString());
    place.setName("place");
    place.getEvents().add(event);
    data.upsert(place);
}
Also used : Event(io.requery.test.model3.Event) Place(io.requery.test.model3.Place) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 Event (io.requery.test.model3.Event)9 UUID (java.util.UUID)9 Place (io.requery.test.model3.Place)4 Tag (io.requery.test.model3.Tag)4 Event (io.requery.test.model2.Event)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 EntityMapper (io.requery.jackson.EntityMapper)2 IOException (java.io.IOException)2 StringWriter (java.io.StringWriter)2 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 OffsetDateTime (java.time.OffsetDateTime)1 ZonedDateTime (java.time.ZonedDateTime)1 HashSet (java.util.HashSet)1