@Test public void testWriteRead() throws Exception { Page page = new Page(); page.setIndex("1"); page.setNumber("[1]"); page.setType("normalPage"); page.setNote("note"); page.setIdentifiers(Arrays.asList(new IdentifierItem(null, "uuid", "1"))); PageMapper handler = new PageMapper(); ModsDefinition mods = new ModsDefinition(); handler.map(mods, page); String dump = ModsUtils.toXml(mods, true); ModsDefinition resultMods = ModsUtils.unmarshal(dump, ModsDefinition.class); PageMapper resultHandler = new PageMapper(); Page result = resultHandler.map(resultMods); assertNotNull(result); assertEquals(page.getIndex(), result.getIndex()); assertEquals(page.getNumber(), result.getNumber()); assertEquals(page.getType(), result.getType()); assertEquals(page.getNote(), result.getNote()); assertEquals(Arrays.asList(new IdentifierItem(0, "uuid", "1")), result.getIdentifiers()); }
@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);  }