private void compare(final Atlas beforeAtlas, final Atlas afterAtlas, final Path outputDirectory) { final String name = FilenameUtils.removeExtension(beforeAtlas.getName()); final AtlasDelta delta = new AtlasDelta(beforeAtlas, afterAtlas).generate(); final String text = delta.toDiffViewFriendlyString(); final File textFile = new File( outputDirectory.resolve(name + FileSuffix.TEXT.toString()).toFile()); textFile.writeAndClose(text); this.logger.info("Saved text file {}", textFile); final String geoJson = delta.toGeoJson(); final File geoJsonFile = new File( outputDirectory.resolve(name + FileSuffix.GEO_JSON.toString()).toFile()); geoJsonFile.writeAndClose(geoJson); this.logger.info("Saved GeoJSON file {}", geoJsonFile); final String relationsGeoJson = delta.toRelationsGeoJson(); final String relationsGeoJsonFileName = name + "_relations" + FileSuffix.GEO_JSON.toString(); final File relationsGeoJsonFile = new File( outputDirectory.resolve(relationsGeoJsonFileName).toFile()); relationsGeoJsonFile.writeAndClose(relationsGeoJson); this.logger.info("Saved Relations GeoJSON file {}", relationsGeoJsonFile); }
temporaryFile.writeAndClose(string);
@Override protected void processAtlas(final String atlasName, final Atlas atlas, final String folder) { final File file = new File(folder).child(atlasName + "-statistics.csv"); final AtlasStatistics statistics = processAtlas(atlas); file.writeAndClose(statistics.toString()); }
@Test public void multipleFiles() { final File parent = File.temporaryFolder(); try { final File atlas1 = parent.child("iAmAn.atlas"); atlas1.writeAndClose("1"); final File atlas2 = parent.child("iTooAmAn.atlas"); atlas2.writeAndClose("2"); final File other = parent.child("iAmNotAnAtlas.txt"); other.writeAndClose("3"); final List<Resource> selected = new AtlasFileSelector().select(parent); // This one does not filter on an Atlas. Assert.assertEquals(3, selected.size()); } finally { parent.deleteRecursively(); } }
output.writeAndClose(changeJSON);
@Test public void oneFile() { File temporary = null; try { temporary = File.temporary(); temporary.writeAndClose("1"); final List<Resource> selected = new AtlasFileSelector().select(temporary); Assert.assertEquals(1, selected.size()); Assert.assertTrue(temporary == selected.get(0)); } finally { temporary.delete(); } }