FolderOutputResult implements OutputResult { boolean isInJavaUserOnlyFolder(String outputFile) { String normalizedOutputFile = normalize(outputFile); boolean isInJava = normalizedOutputFile.contains(JAVA.getFolder()); boolean isInJavaTest = normalizedOutputFile.contains(JAVA_TEST.getFolder()); return isInJava || isInJavaTest; } FolderOutputResult(SourceFile userSource, SourceFile generatedSource);  FolderOutputResult(SourceFile userSource, SourceFile generatedSource, FileTracker fileTracker); @Override void open(); synchronized void close(); @Override void addContent(byte[] contentBytes, String targetFilename, TemplatePack pack, Template template); @Override void addCollisionContent(byte[] contentBytes, String targetFilename, TemplatePack pack, Template template); @Override void addContent(InputStream contentStream, String targetFilename, TemplatePack pack, Template template); @Override SourceFile getUserSource(); @Override SourceFile getGeneratedSource(); @Override boolean sameDirectory(); @Override boolean hasCollision(String pathToFile); @Override String getCollisionName(String targetFilename);  }
@Test public void isInJavaUserOnlyFolder() { FolderOutputResult pe = new FolderOutputResult(new ZipSourceFile(), new ZipSourceFile()); assertTrue(pe.isInJavaUserOnlyFolder("src/main/java/Toto")); assertTrue(pe.isInJavaUserOnlyFolder("src\\main\\java\\Toto")); assertTrue(pe.isInJavaUserOnlyFolder("src\\main/java/toto")); assertFalse(pe.isInJavaUserOnlyFolder("src/main/generated-java/Toto")); assertFalse(pe.isInJavaUserOnlyFolder("src\\main\\generated-java\\Toto")); assertFalse(pe.isInJavaUserOnlyFolder("src\\main/generated-java/toto")); assertTrue(pe.isInJavaUserOnlyFolder("src/test/java/Toto")); assertTrue(pe.isInJavaUserOnlyFolder("src\\test\\java\\Toto")); assertTrue(pe.isInJavaUserOnlyFolder("src\\test/java/toto")); assertFalse(pe.isInJavaUserOnlyFolder("src/test/generated-java/Toto")); assertFalse(pe.isInJavaUserOnlyFolder("src\\test\\generated-java\\Toto")); assertFalse(pe.isInJavaUserOnlyFolder("src\\test/generated-java/toto")); }
@Test public void isInJavaUserOnlyFolderWithJavaSameAsGeneratedJava() { FolderOutputResult pe = new FolderOutputResult(new ZipSourceFile(), new ZipSourceFile()); String oldJavaGenerated = WellKnownFolder.JAVA.getGeneratedFolder(); String oldJavaTestGenerated = WellKnownFolder.JAVA_TEST.getGeneratedFolder(); WellKnownFolder.JAVA.setGeneratedFolder("src/main/java"); WellKnownFolder.JAVA_TEST.setGeneratedFolder("src/test/java"); assertTrue(pe.isInJavaUserOnlyFolder("src/main/java/Toto")); assertTrue(pe.isInJavaUserOnlyFolder("src\\main\\java\\Toto")); assertTrue(pe.isInJavaUserOnlyFolder("src\\main/java/toto")); assertTrue(pe.isInJavaUserOnlyFolder("src/test/java/Toto")); assertTrue(pe.isInJavaUserOnlyFolder("src\\test\\java\\Toto")); assertTrue(pe.isInJavaUserOnlyFolder("src\\test/java/toto")); WellKnownFolder.JAVA.setGeneratedFolder(oldJavaGenerated); WellKnownFolder.JAVA_TEST.setGeneratedFolder(oldJavaTestGenerated); }