@Test public void simple() throws IOException, ParseException { TikXml xml = new TikXml.Builder().exceptionOnUnreadXml(true).build(); CatalogueConstructor catalogue = xml.read(TestUtils.sourceForFile("books.xml"), CatalogueConstructor.class); Assert.assertEquals(10, catalogue.getBooks().size()); for (int i = 1; i <= 10; i++) { BookConstructor book = catalogue.getBooks().get(i - 1); Date date = DateConverter.format.parse("2000-09-0" + i); Assert.assertEquals(i, book.getId()); Assert.assertEquals("author" + i, book.getAuthor()); Assert.assertEquals("genre" + i, book.getGenre()); Assert.assertEquals(i, book.getPrice(), 0); Assert.assertEquals(date, book.getPublishDate()); Assert.assertEquals("description" + i, book.getDescription()); } }
@Test public void simple() throws IOException, ParseException { TikXml xml = new TikXml.Builder().exceptionOnUnreadXml(true).build(); Company company = xml.read(TestUtils.sourceForFile("company.xml"), Company.class); Assert.assertEquals("Tickaroo", company.name); Assert.assertEquals(4, company.persons.size()); Assert.assertTrue(company.persons.get(0) instanceof Boss); Boss boss = (Boss) company.persons.get(0); Assert.assertEquals("Naomi", boss.firstName); Assert.assertEquals("Owusu", boss.lastName); Employee employee = (Employee) company.persons.get(1); Assert.assertEquals("Hannes", employee.name); employee = (Employee) company.persons.get(2); Assert.assertEquals("Lukas", employee.name); employee = (Employee) company.persons.get(3); Assert.assertEquals("Bodo", employee.name); }