Search in sources :

Example 26 with Widget

use of org.minijax.db.test.Widget in project minijax by minijax.

the class BaseEntityTest method testCopyPropertiesDifferentClass.

@Test(expected = IllegalArgumentException.class)
public void testCopyPropertiesDifferentClass() {
    final Widget w = new Widget();
    w.copyNonNullProperties(new DifferentEntity());
}
Also used : Widget(org.minijax.db.test.Widget) Test(org.junit.Test)

Example 27 with Widget

use of org.minijax.db.test.Widget in project minijax by minijax.

the class BaseEntityTest method testSortByCreatedDate.

@Test
public void testSortByCreatedDate() {
    final Widget w1 = new Widget();
    w1.setCreatedDateTime(Instant.now().minusSeconds(3L));
    final Widget w2 = new Widget();
    w2.setCreatedDateTime(Instant.now().minusSeconds(2L));
    final Widget w3 = new Widget();
    w3.setCreatedDateTime(Instant.now().minusSeconds(1L));
    final List<Widget> w = new ArrayList<>(Arrays.asList(w3, w2, w1));
    BaseEntity.sortByCreatedDateTime(w);
    assertEquals(w1, w.get(0));
    assertEquals(w2, w.get(1));
    assertEquals(w3, w.get(2));
}
Also used : Widget(org.minijax.db.test.Widget) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 28 with Widget

use of org.minijax.db.test.Widget in project minijax by minijax.

the class BaseEntityTest method testCopyPropertiesNull.

@Test(expected = NullPointerException.class)
public void testCopyPropertiesNull() {
    final Widget w = new Widget();
    w.copyNonNullProperties(null);
}
Also used : Widget(org.minijax.db.test.Widget) Test(org.junit.Test)

Example 29 with Widget

use of org.minijax.db.test.Widget in project minijax by minijax.

the class BaseEntityTest method testToJson.

@Test
public void testToJson() throws IOException {
    final Widget w = new Widget();
    w.setId(UUID.fromString("00000000-0000-0000-0000-000000000000"));
    w.setCreatedDateTime(ZonedDateTime.of(2017, 10, 30, 4, 38, 0, 0, ZoneId.of("America/Los_Angeles")).toInstant());
    w.setName("foo");
    assertEquals("{\"id\":\"00000000-0000-0000-0000-000000000000\",\"createdDateTime\":\"2017-10-30T11:38:00Z\",\"name\":\"foo\"}", w.toJson());
}
Also used : Widget(org.minijax.db.test.Widget) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)29 Widget (org.minijax.db.test.Widget)29 MinijaxTest (org.minijax.test.MinijaxTest)6 ArrayList (java.util.ArrayList)1 Minijax (org.minijax.Minijax)1 MinijaxApplication (org.minijax.MinijaxApplication)1 MinijaxRequestContext (org.minijax.MinijaxRequestContext)1 MockHttpServletRequest (org.minijax.test.MockHttpServletRequest)1