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()));