JoinTableParser { public JoinTables parseJoinTables(JoinTables joinTables) throws XMLStreamException { LOG.info("Join tables found, parsing"); while (xmlReader.hasNext()) { XMLEvent containerEvent = xmlReader.nextTag(); if (containerEvent.isEndElement()) { break; } parseJoinTable(joinTables); } LOG.info("Join tables parsed"); return joinTables; } JoinTableParser(XMLEventReader xmlReader, BackupConfig backupConfig); JoinTables parseJoinTables(JoinTables joinTables);  }
@Test public void should_parse_join_table() throws IOException, XMLStreamException { EhourBackupConfig locator = new EhourBackupConfig(); XMLEventReader reader = BackupFileUtil.createXmlReaderFromFile("src/test/resources/import/join_table.xml"); JoinTableParser parser = new JoinTableParser(reader, locator); reader.nextTag(); JoinTables joinTables = parser.parseJoinTables(new JoinTables()); assertEquals(2, joinTables.size()); assertEquals(4, joinTables.getTarget("USER_TO_USERROLE", "1").size()); assertEquals(3, joinTables.getTarget("USER_TO_USERROLE", "2").size()); assertEquals(2, joinTables.getTarget("USER_TO_USERROLE", "3").size()); assertEquals(2, joinTables.getTarget("USER_TO_DEPARTMENT", "1").size()); assertEquals(1, joinTables.getTarget("USER_TO_DEPARTMENT", "2").size()); }