private BookMetadata createMetadata() { BookMetadata metadata = new BookMetadata(); metadata.setCommonName("Common Name"); metadata.setTitle("Title"); metadata.setCurrentLocation("Current Location"); metadata.setDate("Today's date."); metadata.setWidth(1000); metadata.setHeight(2000); metadata.setNumberOfIllustrations(42); metadata.setNumberOfPages(100); metadata.setDimensions("1000x2000"); metadata.setMaterial("Some Material"); metadata.setOrigin("Origin"); metadata.setRepository("Repository"); metadata.setShelfmark("On the shelf"); metadata.setYearEnd(300); metadata.setYearStart(100); metadata.setType("The type"); metadata.setDimensionUnits("mm"); List<BookText> bookTextList = new ArrayList<>(); for (int i = 0; i < 3; i++) { BookText text = new BookText(); text.setId("ID" + i); text.setFirstPage("Page " + i); text.setLastPage("Page " + (i + 1)); text.setColumnsPerPage(2); text.setLeavesPerGathering(6); text.setLinesPerColumn(45); text.setNumberOfIllustrations(42); text.setNumberOfPages(36); text.setTitle("Title Title"); bookTextList.add(text); } metadata.setTexts(bookTextList.toArray(new BookText[bookTextList.size()])); return metadata; }
@Test public void readTest() throws IOException { final String testFile = "LudwigXV7.description_en.xml"; List<String> errors = new ArrayList<>(); BookMetadata metadata = loadResource(COLLECTION_NAME, BOOK_NAME, testFile, errors); assertNotNull(metadata); assertEquals("15th century", metadata.getDate()); assertEquals(1400, metadata.getYearStart()); assertEquals(1500, metadata.getYearEnd()); assertEquals("Los Angeles", metadata.getCurrentLocation()); assertEquals("J. Paul Getty Museum", metadata.getRepository()); assertNotNull(metadata.getShelfmark()); assertNotNull(metadata.getOrigin()); assertEquals("manuscript", metadata.getType()); assertNotNull(metadata.getDimensions()); assertEquals(260, metadata.getWidth()); assertEquals(370, metadata.getHeight()); assertTrue(metadata.getNumberOfIllustrations() > -1); assertTrue(metadata.getNumberOfPages() > -1); assertNotNull(metadata.getCommonName()); assertNotNull(metadata.getMaterial()); assertNotNull(metadata.getTexts()); assertEquals(1, metadata.getTexts().length); }