@Test public void testGenerate() throws IOException { Random r = new Random(); for (int i = 0; i < r.nextInt(20) + 10; i++) { FileEntry e = tool.generate(paths); FileEntryToolTest.assertFileEntry(e); list.add(e); } }
public FileEntry generate(Path... resources) throws IOException { Path curDir = Paths.get(rootDir.toString(), "iteration-" + r.nextInt()); Files.createDirectory(curDir); Address add = new Address(r.nextDouble() * 100, r.nextDouble() * 100, randomString(5), randomString(5), randomString(10), randomString(10), randomInteger(3), randomInteger(5)); Speed sp = new Speed(r.nextDouble() * 100); NumberPlate np = new NumberPlate(randomString(5).toUpperCase(), randomString(2).toUpperCase()); CarData cd = new CarData(sp, add, np, new Date(r.nextLong())); ArrayList<FileCarImage> images = new ArrayList<>(); for (int i = 0; i < resources.length; i++) { Path p = resources[i]; if (!Files.exists(p)) { continue; } Path path = Paths.get(curDir.toString(), i + "-" + p.hashCode() + ".jpg"); Files.copy(p, path); FileCarImage f = new FileCarImage(path); images.add(f); } return new FileEntry(cd, images); }
FileEntryTool implements AutoCloseable { public FileEntry generate(Path... resources) throws IOException { Path curDir = Paths.get(rootDir.toString(), "iteration-" + r.nextInt()); Files.createDirectory(curDir); Address add = new Address(r.nextDouble() * 100, r.nextDouble() * 100, randomString(5), randomString(5), randomString(10), randomString(10), randomInteger(3), randomInteger(5)); Speed sp = new Speed(r.nextDouble() * 100); NumberPlate np = new NumberPlate(randomString(5).toUpperCase(), randomString(2).toUpperCase()); CarData cd = new CarData(sp, add, np, new Date(r.nextLong())); ArrayList<FileCarImage> images = new ArrayList<>(); for (int i = 0; i < resources.length; i++) { Path p = resources[i]; if (!Files.exists(p)) { continue; } Path path = Paths.get(curDir.toString(), i + "-" + p.hashCode() + ".jpg"); Files.copy(p, path); FileCarImage f = new FileCarImage(path); images.add(f); } return new FileEntry(cd, images); } }
FileEntryTool implements AutoCloseable { public FileEntry generate(Path... resources) throws IOException { Path curDir = Paths.get(rootDir.toString(), "iteration-" + r.nextInt()); Files.createDirectory(curDir); Address add = new Address(r.nextDouble() * 100, r.nextDouble() * 100, randomString(5), randomString(5), randomString(10), randomString(10), randomInteger(3), randomInteger(5)); Speed sp = new Speed(r.nextDouble() * 100); NumberPlate np = new NumberPlate(randomString(5).toUpperCase(), randomString(2).toUpperCase()); CarData cd = new CarData(sp, add, np, new Date(r.nextLong())); ArrayList<FileCarImage> images = new ArrayList<>(); for (int i = 0; i < resources.length; i++) { Path p = resources[i]; if (!Files.exists(p)) { continue; } Path path = Paths.get(curDir.toString(), i + "-" + p.hashCode() + ".jpg"); Files.copy(p, path); FileCarImage f = new FileCarImage(path); images.add(f); } return new FileEntry(cd, images); } FileEntryTool(); }
FileEntryTool implements AutoCloseable { public FileEntry generate(Path... resources) throws IOException { Path curDir = Paths.get(rootDir.toString(), "iteration-" + r.nextInt()); Files.createDirectory(curDir); Address add = new Address(r.nextDouble() * 100, r.nextDouble() * 100, randomString(5), randomString(5), randomString(10), randomString(10), randomInteger(3), randomInteger(5)); Speed sp = new Speed(r.nextDouble() * 100); NumberPlate np = new NumberPlate(randomString(5).toUpperCase(), randomString(2).toUpperCase()); CarData cd = new CarData(sp, add, np, new Date(r.nextLong())); ArrayList<FileCarImage> images = new ArrayList<>(); for (int i = 0; i < resources.length; i++) { Path p = resources[i]; if (!Files.exists(p)) { continue; } Path path = Paths.get(curDir.toString(), i + "-" + p.hashCode() + ".jpg"); Files.copy(p, path); FileCarImage f = new FileCarImage(path); images.add(f); } return new FileEntry(cd, images); } FileEntryTool(); FileEntry generate(Path... resources); @Override void close(); }
FileEntryTool implements AutoCloseable { public FileEntry generate(Path... resources) throws IOException { Path curDir = Paths.get(rootDir.toString(), "iteration-" + r.nextInt()); Files.createDirectory(curDir); Address add = new Address(r.nextDouble() * 100, r.nextDouble() * 100, randomString(5), randomString(5), randomString(10), randomString(10), randomInteger(3), randomInteger(5)); Speed sp = new Speed(r.nextDouble() * 100); NumberPlate np = new NumberPlate(randomString(5).toUpperCase(), randomString(2).toUpperCase()); CarData cd = new CarData(sp, add, np, new Date(r.nextLong())); ArrayList<FileCarImage> images = new ArrayList<>(); for (int i = 0; i < resources.length; i++) { Path p = resources[i]; if (!Files.exists(p)) { continue; } Path path = Paths.get(curDir.toString(), i + "-" + p.hashCode() + ".jpg"); Files.copy(p, path); FileCarImage f = new FileCarImage(path); images.add(f); } return new FileEntry(cd, images); } FileEntryTool(); FileEntry generate(Path... resources); @Override void close();  }