CWLHandler implements LanguageHandlerInterface { public Set<FileFormat> getFileFormats(String content, String type) { Set<FileFormat> fileFormats = new HashSet<>(); Yaml yaml = new Yaml(); try { Map<String, ?> map = yaml.loadAs(content, Map.class); Object targetType = map.get(type); if (targetType instanceof Map) { Map<String, ?> outputsMap = (Map<String, ?>)targetType; outputsMap.forEach((k, v) -> { handlePotentialFormatEntry(fileFormats, v); }); } else if (targetType instanceof List) { ((List)targetType).forEach(v -> { handlePotentialFormatEntry(fileFormats, v); }); } else { LOG.debug(type + " is not comprehensible."); } } catch (YAMLException | NullPointerException e) { LOG.error("Could not process content from entry as yaml", e); } return fileFormats; }  @Override Version parseWorkflowContent(String filepath, String content, Set<SourceFile> sourceFiles, Version version); @Override Map<String, SourceFile> processImports(String repositoryId, String content, Version version,
        SourceCodeRepoInterface sourceCodeRepoInterface, String workingDirectoryForFile); Set<FileFormat> getFileFormats(String content, String type); @Override @SuppressWarnings("checkstyle:methodlength") //TODO: Occassionally misses dockerpulls. One case is when a dockerPull is nested within a run that's within a step. There are other missed cases though that are TBD. String getContent(String mainDescriptorPath, String mainDescriptor, Set<SourceFile> secondarySourceFiles, LanguageHandlerInterface.Type type,
        ToolDAO dao); static void setImportsBasedOnMapValue(ParsedInformation parsedInformation, String mapValue); @Override VersionTypeValidation validateWorkflowSet(Set<SourceFile> sourcefiles, String primaryDescriptorFilePath); @Override VersionTypeValidation validateToolSet(Set<SourceFile> sourcefiles, String primaryDescriptorFilePath); @Override VersionTypeValidation validateTestParameterSet(Set<SourceFile> sourceFiles); static final Logger LOG; }
@Test public void getInputFileFormats() throws Exception { CWLHandler cwlHandler = new CWLHandler(); String filePath = ResourceHelpers.resourceFilePath("metadata_example4.cwl"); Set<FileFormat> inputs = cwlHandler.getFileFormats(FileUtils.readFileToString(new File(filePath), StandardCharsets.UTF_8), "inputs"); Assert.assertTrue(inputs.stream().anyMatch(input -> input.getValue().equals("http: Set<FileFormat> outputs = cwlHandler.getFileFormats(FileUtils.readFileToString(new File(filePath), StandardCharsets.UTF_8), "outputs"); Assert.assertTrue(outputs.stream().anyMatch(input -> input.getValue().equals("http: }