PlanetsXMLGenerator { public void generate() { try { ObjectFactory objFactory = new ObjectFactory(); FileProfileType fileProfileType = objFactory .createFileProfileType(); JAXBElement<FileProfileType> fileProfile = objFactory .createFileProfile(fileProfileType); PathsProcessedType pathProcessedType = getPathProcessed(objFactory); ByFormatType byFormatType = getGroupByPuid(objFactory); ByYearType byYearType = getGroupByYear(objFactory); getFileProfileType(fileProfileType, pathProcessedType, byFormatType, byYearType); JAXBContext jaxbContext = JAXBContext .newInstance("uk.gov.nationalarchives.droid.report.planets.domain"); Marshaller m = jaxbContext.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); if (observer != null) { observer.onProgress(HUNDRED); } m.marshal(fileProfile, Paths.get(filePath).toFile()); } catch (JAXBException ex) { throw new RuntimeException("Error while writing to an xml file."); } catch (InterruptedException e) { throw new RuntimeException("Error while writing to an xml file."); } } PlanetsXMLGenerator(ProgressObserver observer,
            String filePath, PlanetsXMLData planetsData);  PlanetsXMLGenerator(String filePath, PlanetsXMLData planetsData);  PlanetsXMLGenerator(); void generate();  }
@Ignore @Test public void testPlanetsXMLEndToEnd() { String[] topLevelItems = new String[] {"foo", "bar"}; PlanetsXMLData data = new PlanetsXMLData(); data.setTopLevelItems(Arrays.asList(topLevelItems)); List<GroupByYearSizeAndCountRow> dataList = new ArrayList<GroupByYearSizeAndCountRow>(); GroupByYearSizeAndCountRow groupByYearSizeAndCountRow = new GroupByYearSizeAndCountRow(); groupByYearSizeAndCountRow.setYear(1990); groupByYearSizeAndCountRow.setCount(new BigInteger("20")); groupByYearSizeAndCountRow.setSize(new BigDecimal("5000")); dataList.add(groupByYearSizeAndCountRow); data.setGroupByYear(dataList); List<GroupByPuidSizeAndCountRow> dataList1 = new ArrayList<GroupByPuidSizeAndCountRow>(); GroupByPuidSizeAndCountRow groupByPuidSizeAndCountRow = new GroupByPuidSizeAndCountRow(); groupByPuidSizeAndCountRow.setPuid("Xfmt/doc"); groupByPuidSizeAndCountRow.setCount(new BigInteger("20")); groupByPuidSizeAndCountRow.setSize(new BigDecimal("50000")); dataList1.add(groupByPuidSizeAndCountRow); data.setGroupByPuid(dataList1); ProfileStat profileStat = new ProfileStat(); profileStat.setProfileEndDate(new Date()); profileStat.setProfileSaveDate(new Date()); profileStat.setProfileStartDate(new Date()); profileStat.setProfileLargestSize(new BigInteger("20")); profileStat.setProfileMeanSize(new BigDecimal("50000")); profileStat.setProfileSmallestSize(new BigInteger("20")); profileStat.setProfileTotalSize(new BigInteger("20")); profileStat.setProfileTotalReadableFiles(new BigInteger("20")); profileStat.setProfileTotalUnReadableFiles(new BigInteger("20")); profileStat.setProfileTotalUnReadableFolders(new BigInteger("20")); data.setProfileStat(profileStat); planetsGenerator = new PlanetsXMLGenerator(filename, data); planetsGenerator.generate(); assertTrue(Files.exists(destination)); }
@Ignore @Test public void testPlanetsWithNoElement() { String[] topLevelItems = new String[] {}; PlanetsXMLData data = new PlanetsXMLData(); data.setTopLevelItems(Arrays.asList(topLevelItems)); List<GroupByYearSizeAndCountRow> dataList = new ArrayList<GroupByYearSizeAndCountRow>(); data.setGroupByYear(dataList); List<GroupByPuidSizeAndCountRow> dataList1 = new ArrayList<GroupByPuidSizeAndCountRow>(); GroupByPuidSizeAndCountRow groupByPuidSizeAndCountRow = new GroupByPuidSizeAndCountRow(); groupByPuidSizeAndCountRow.setPuid("Xfmt/doc"); groupByPuidSizeAndCountRow.setCount(new BigInteger("20")); groupByPuidSizeAndCountRow.setSize(new BigDecimal("50000")); dataList1.add(groupByPuidSizeAndCountRow); data.setGroupByPuid(dataList1); ProfileStat profileStat = new ProfileStat(); profileStat.setProfileEndDate(new Date()); profileStat.setProfileSaveDate(new Date()); profileStat.setProfileStartDate(new Date()); profileStat.setProfileLargestSize(new BigInteger("20")); profileStat.setProfileMeanSize(new BigDecimal("50000")); profileStat.setProfileSmallestSize(new BigInteger("20")); profileStat.setProfileTotalSize(new BigInteger("20")); profileStat.setProfileTotalReadableFiles(new BigInteger("20")); profileStat.setProfileTotalUnReadableFiles(new BigInteger("20")); profileStat.setProfileTotalUnReadableFolders(new BigInteger("20")); data.setProfileStat(profileStat); planetsGenerator = new PlanetsXMLGenerator(filename, data); planetsGenerator.generate(); assertTrue(Files.exists(destination)); }