@Test public void testWriteUpdate() throws Exception { ModsDefinition mods = ModsUtils.unmarshal(PageMapperTest.class.getResource("page_mods.xml"), ModsDefinition.class); Page page = new Page(); page.setNote("note updated"); page.setIndex("2"); page.setNumber("[2]"); page.setType("TitlePage"); page.setIdentifiers(Arrays.asList( new IdentifierItem(1, "uuid", "1 updated"), new IdentifierItem(0, "issn", "issn value updated"), new IdentifierItem("isbn", "isbn value inserted"))); PageMapper instance = new PageMapper(); ModsDefinition result = instance.map(mods, page); String resultXml = ModsUtils.toXml(result, true); ModsDefinition expectedMods = ModsUtils.unmarshal(PageMapperTest.class.getResource("page_mods_updated.xml"), ModsDefinition.class); String expectedXml = ModsUtils.toXml(expectedMods, true); XMLAssert.assertXMLEqual(expectedXml, resultXml); }
@Override public Page map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Page page = new Page(); page.setIdentifiers(identMap.map(mods)); page.setNumber(MapperUtils.toString(nlookup.getPageNumber(false))); page.setIndex(MapperUtils.toString(nlookup.getPageIndex(false))); Text note = nlookup.getNote(false); page.setNote(note == null ? null : note.getValue()); PartDefinition part = nlookup.getPart(false); page.setType(part == null ? null : part.getType()); return page; }
PageMapper implements Mapping.Mapper<Page> { @Override public Page map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Page page = new Page(); page.setIdentifiers(identMap.map(mods)); page.setNumber(MapperUtils.toString(nlookup.getPageNumber(false))); page.setIndex(MapperUtils.toString(nlookup.getPageIndex(false))); Text note = nlookup.getNote(false); page.setNote(note == null ? null : note.getValue()); PartDefinition part = nlookup.getPart(false); page.setType(part == null ? null : part.getType()); return page; } }
PageMapper implements Mapping.Mapper<Page> { @Override public Page map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Page page = new Page(); page.setIdentifiers(identMap.map(mods)); page.setNumber(MapperUtils.toString(nlookup.getPageNumber(false))); page.setIndex(MapperUtils.toString(nlookup.getPageIndex(false))); Text note = nlookup.getNote(false); page.setNote(note == null ? null : note.getValue()); PartDefinition part = nlookup.getPart(false); page.setType(part == null ? null : part.getType()); return page; }  }
PageMapper implements Mapping.Mapper<Page> { @Override public Page map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Page page = new Page(); page.setIdentifiers(identMap.map(mods)); page.setNumber(MapperUtils.toString(nlookup.getPageNumber(false))); page.setIndex(MapperUtils.toString(nlookup.getPageIndex(false))); Text note = nlookup.getNote(false); page.setNote(note == null ? null : note.getValue()); PartDefinition part = nlookup.getPart(false); page.setType(part == null ? null : part.getType()); return page; }  @Override Page map(ModsDefinition mods); @Override ModsDefinition map(ModsDefinition mods, Page page); void updatePage(ModsDefinition mods, String pageIndex, String pageNumber, String pageType); }
PageMapper implements Mapping.Mapper<Page> { @Override public Page map(ModsDefinition mods) { NodeLookup nlookup = new NodeLookup(mods); Page page = new Page(); page.setIdentifiers(identMap.map(mods)); page.setNumber(MapperUtils.toString(nlookup.getPageNumber(false))); page.setIndex(MapperUtils.toString(nlookup.getPageIndex(false))); Text note = nlookup.getNote(false); page.setNote(note == null ? null : note.getValue()); PartDefinition part = nlookup.getPart(false); page.setType(part == null ? null : part.getType()); return page; }  @Override Page map(ModsDefinition mods); @Override ModsDefinition map(ModsDefinition mods, Page page); void updatePage(ModsDefinition mods, String pageIndex, String pageNumber, String pageType);  }