List of usage examples for java.nio.file Path toFile
default File toFile()
From source file:io.github.swagger2markup.internal.component.PathOperationComponentTest.java
@Test public void testPathOperationComponent() throws URISyntaxException { String COMPONENT_NAME = "path_operation"; Path outputDirectory = getOutputFile(COMPONENT_NAME); FileUtils.deleteQuietly(outputDirectory.toFile()); //Given/*w w w . j av a 2 s. c o m*/ Path file = Paths.get(PathOperationComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI()); Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build(); Swagger swagger = converter.getContext().getSwagger(); io.swagger.models.Path path = swagger.getPaths().get("/pets"); List<PathOperation> pathOperations = PathUtils.toPathOperationsList("/pets", path); Swagger2MarkupConverter.Context context = converter.getContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); //When markupDocBuilder = new PathOperationComponent(context, new DefinitionDocumentResolverFromOperation(context), new SecurityDocumentResolver(context)).apply(markupDocBuilder, PathOperationComponent.parameters(pathOperations.get(0))); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); //Then Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); }
From source file:com.compomics.colims.core.io.headers.ProteinGroupHeaders.java
/** * Parse protein group file headers. Find the SILAC label headers and add to the proteinGroupHeaders list. * @param proteinGroupsFile// ww w. j av a 2 s . co m * @throws IOException */ public void parseProteinGroupHeaders(Path proteinGroupsFile) throws IOException { proteinGroupHeaders = new ArrayList<>(); readFileHeaders(proteinGroupsFile.toFile()); ProteinGroupIntensityHeadersEnum.getHeaderValues().entrySet().stream().filter( (header) -> (headersInProteinGroupFile.stream().anyMatch(s -> s.startsWith(header.getKey())))) .forEach((header) -> { proteinGroupHeaders.add(header.getValue()); }); }
From source file:PatternFinder.java
private List<String> getFileNames(String search, List<String> fileNames, Path dir) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (Path path : stream) { if (path.toFile().isDirectory()) { getFileNames(search, fileNames, path); } else { String fileName = path.toAbsolutePath().getFileName().toString(); String[] data = search.split("-"); if (data[0] != null && (data[0].equals("atoms") || data[0].equals("molecules") || data[0].equals("organisms"))) data = (String[]) ArrayUtils.remove(data, 0); String differentSearchTerm = String.join("-", data).toLowerCase(); //Search for patternlab identifier in filesystem if (fileName.contains(differentSearchTerm) || fileName.contains(search)) { fileNames.add(path.toAbsolutePath().toString()); }/* w w w . j a v a 2 s.co m*/ } } } catch (IOException e) { //e.printStackTrace(); } return fileNames; }
From source file:io.github.swagger2markup.internal.component.PathOperationComponentTest.java
@Test public void testInlineSchema() throws URISyntaxException { String COMPONENT_NAME = "path_operation_inline_schema"; Path outputDirectory = getOutputFile(COMPONENT_NAME); FileUtils.deleteQuietly(outputDirectory.toFile()); //Given/*w ww . j a va 2 s. c o m*/ Path file = Paths .get(PathOperationComponentTest.class.getResource("/yaml/swagger_inlineSchema.yaml").toURI()); Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build(); Swagger swagger = converter.getContext().getSwagger(); io.swagger.models.Path path = swagger.getPaths().get("/LaunchCommand"); List<PathOperation> pathOperations = PathUtils.toPathOperationsList("/LaunchCommand", path); Swagger2MarkupConverter.Context context = converter.getContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); //When markupDocBuilder = new PathOperationComponent(context, new DefinitionDocumentResolverFromOperation(context), new SecurityDocumentResolver(context)).apply(markupDocBuilder, PathOperationComponent.parameters(pathOperations.get(0))); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); //Then Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); }
From source file:com.elemenopy.backupcopy.filesystem.RootFolderSynchronizer.java
public void synchronize() throws IOException { Path sourceRoot = fileSystem.getPath(sourceRootFolder.getPath()); if (!sourceRoot.toFile().isDirectory()) { throw new IllegalArgumentException("Source path " + sourceRootFolder.getPath() + " is not a directory"); }//from w w w . j av a2 s .c om EnumSet<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS); Files.walkFileTree(sourceRoot, opts, Integer.MAX_VALUE, new SyncingFileVisitor(sourceRoot, destination)); }
From source file:com.indoqa.osgi.embedded.test.integration.OSGiEmbeddedIntegrationTest.java
private Path prepareDirectory(String dir) throws IOException { Path path = Paths.get(dir); Files.createDirectories(path); FileUtils.cleanDirectory(path.toFile()); return path;//from w ww . j av a 2s .c om }
From source file:fr.jetoile.hadoopunit.HadoopBootstrapRemoteStarter.java
private void deleteLogFile(Path hadoopLogFilePath) { getLog().info("is going to delete log file"); if (hadoopLogFilePath.toFile().exists() && hadoopLogFilePath.toFile().canWrite()) { if (!hadoopLogFilePath.toFile().delete()) { getLog().warn("unable to delete log file"); }//from w w w . ja v a 2 s. c o m getLog().info("delete log file done"); } }
From source file:io.github.swagger2markup.extensions.SpringRestDocsExtensionsTest.java
@Test public void testSwagger2AsciiDocConversionWithSpringRestDocsExtension() throws IOException, URISyntaxException { //Given/*from w w w . ja va 2 s .c om*/ Path file = Paths .get(SpringRestDocsExtensionsTest.class.getResource("/yaml/swagger_petstore.yaml").toURI()); Path outputDirectory = Paths.get("build/test/asciidoc/spring_rest_docs"); FileUtils.deleteQuietly(outputDirectory.toFile()); //When Swagger2MarkupExtensionRegistry registry = new Swagger2MarkupExtensionRegistryBuilder() //.withPathsDocumentExtension(new SpringRestDocsExtension(Paths.get("src/test/resources/docs/asciidoc/paths").toUri()).withDefaultSnippets()) .build(); Properties properties = new Properties(); properties.load(SpringRestDocsExtensionsTest.class.getResourceAsStream("/config/config.properties")); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder(properties).build(); Swagger2MarkupConverter.from(file).withConfig(config).withExtensionRegistry(registry).build() .toFolder(outputDirectory); //Then String[] files = outputDirectory.toFile().list(); assertThat(files).hasSize(4).containsAll(expectedFiles); Path expectedFilesDirectory = Paths.get(SpringRestDocsExtensionsTest.class .getResource("/expected_results/asciidoc/spring_rest_docs").toURI()); DiffUtils.assertThatAllFilesAreEqual(outputDirectory, expectedFilesDirectory, "testSwagger2AsciiDocConversionWithSpringRestDocsExtension.html"); }
From source file:data.NeustarDatabaseUpdaterTest.java
@Before public void before() throws Exception { initMocks(this); when(neustarOldDatabaseDirectory.isDirectory()).thenReturn(true); when(neustarOldDatabaseDirectory.lastModified()).thenReturn(1425236082000L); mockTmpDir = mock(File.class); when(mockTmpDir.getName()).thenReturn("123-abc-tmp"); when(mockTmpDir.getParentFile()).thenReturn(neustarDatabaseDirectory); when(neustarDatabaseDirectory.listFiles()) .thenReturn(new File[] { neustarOldDatabaseDirectory, mockTmpDir }); Path path = mock(Path.class); when(path.toFile()).thenReturn(mockTmpDir); mockStatic(Files.class); when(Files.createTempDirectory(any(Path.class), eq("neustar-"))).thenReturn(path); when(tarExtractor.extractTo(eq(mockTmpDir), any(GZIPInputStream.class))).thenReturn(true); }
From source file:com.seleniumtests.driver.DriverExtractor.java
public void copyDriver(String driverName) { InputStream driver = Thread.currentThread().getContextClassLoader().getResourceAsStream(String .format("drivers/%s/%s%s", os, driverName, OSUtilityFactory.getInstance().getProgramExtension())); if (driver == null) { throw new DriverExceptions(String.format("Driver %s does not exist in resources", driverName)); }//from www .j a v a2 s . c o m Path driverPath = getDriverPath(driverName); driverPath.toFile().getParentFile().mkdirs(); try { Files.copy(driver, driverPath, StandardCopyOption.REPLACE_EXISTING); driverPath.toFile().setExecutable(true); logger.info(String.format("Driver %s copied to %s", driverName, driverPath)); } catch (IOException e) { logger.info(String.format("Driver not copied: %s - it may be in use", driverName)); } }