CWLHandler implements LanguageHandlerInterface { public static void setImportsBasedOnMapValue(ParsedInformation parsedInformation, String mapValue) { String[] schemes = {"http", "https"}; UrlValidator urlValidator = new UrlValidator(schemes); if (urlValidator.isValid(mapValue)) { parsedInformation.setHasHTTPImports(true); } else { parsedInformation.setHasLocalImports(true); } }  @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 testURLHandler() { ParsedInformation parsedInformation = new ParsedInformation(); CWLHandler.setImportsBasedOnMapValue(parsedInformation, "https: Assert.assertTrue(parsedInformation.isHasHTTPImports()); Assert.assertFalse(parsedInformation.isHasLocalImports()); ParsedInformation parsedInformation2 = new ParsedInformation(); CWLHandler.setImportsBasedOnMapValue(parsedInformation2, "http: Assert.assertTrue(parsedInformation2.isHasHTTPImports()); Assert.assertFalse(parsedInformation2.isHasLocalImports()); ParsedInformation parsedInformation3 = new ParsedInformation(); CWLHandler.setImportsBasedOnMapValue(parsedInformation3, "ftp: Assert.assertFalse(parsedInformation3.isHasHTTPImports()); Assert.assertTrue(parsedInformation3.isHasLocalImports()); ParsedInformation parsedInformation4 = new ParsedInformation(); CWLHandler.setImportsBasedOnMapValue(parsedInformation4, "potato.cwl"); Assert.assertFalse(parsedInformation4.isHasHTTPImports()); Assert.assertTrue(parsedInformation4.isHasLocalImports()); ParsedInformation parsedInformation5 = new ParsedInformation(); CWLHandler.setImportsBasedOnMapValue(parsedInformation5, "httppotato.cwl"); Assert.assertFalse(parsedInformation5.isHasHTTPImports()); Assert.assertTrue(parsedInformation5.isHasLocalImports()); }