Package com.avaje.tests.model.basic

Examples of com.avaje.tests.model.basic.Cat


public class TestInheritanceOnMany extends BaseTestCase {

  @Test
  public void test() {
   
    Cat cat = new Cat();
    cat.setName("Puss");
    Ebean.save(cat);
   
    Dog dog = new Dog();
    dog.setRegistrationNumber("DOGGIE");
    Ebean.save(dog);
View Full Code Here


public class TestJsonInheritanceDiscriminator extends BaseTestCase {

  @Test
  public void testNoDiscriminator() throws IOException {

    Cat cat = new Cat();
    cat.setName("Gemma");

    Ebean.save(cat);

    JsonContext json = Ebean.json();
    String jsonContent = json.toJson(cat);

    Cat cat2 = json.toBean(Cat.class, jsonContent);

    Assert.assertEquals(cat.getId(), cat2.getId());
    Assert.assertEquals(cat.getName(), cat2.getName());
    Assert.assertEquals(cat.getVersion(), cat2.getVersion());

    String noDiscriminator = "{\"id\":1,\"name\":\"Gemma\",\"version\":1}";

    Cat cat3 = json.toBean(Cat.class, noDiscriminator);

    Assert.assertEquals(1L, cat3.getId().longValue());
    Assert.assertEquals("Gemma", cat3.getName());
    Assert.assertEquals(1L, cat3.getVersion().longValue());

    Dog dog = new Dog();
    dog.setRegistrationNumber("ABC123");
    dog.setDateOfBirth(new Date(System.currentTimeMillis()));
View Full Code Here

TOP

Related Classes of com.avaje.tests.model.basic.Cat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.