Search in sources :

Example 96 with ImmutablePair

use of org.apache.commons.lang3.tuple.ImmutablePair in project Asqatasun by Asqatasun.

the class Rgaa32016Rule080801Test method setProcess.

@Override
protected void setProcess() {
    //----------------------------------------------------------------------
    //---------------------------1Passed-01---------------------------------
    //----------------------------------------------------------------------
    checkResultIsPassed(processPageTest("Rgaa32016.Test.08.08.01-1Passed-01"), 4);
    //----------------------------------------------------------------------
    //---------------------------1Passed-02---------------------------------
    //----------------------------------------------------------------------
    checkResultIsPassed(processPageTest("Rgaa32016.Test.08.08.01-1Passed-02"), 4);
    //----------------------------------------------------------------------
    //---------------------------1Passed-03---------------------------------
    //----------------------------------------------------------------------
    checkResultIsPassed(processPageTest("Rgaa32016.Test.08.08.01-1Passed-03"), 4);
    //----------------------------------------------------------------------
    //---------------------------1Passed-04---------------------------------
    //----------------------------------------------------------------------
    checkResultIsPassed(processPageTest("Rgaa32016.Test.08.08.01-1Passed-04"), 4);
    //----------------------------------------------------------------------
    //------------------------------2Failed-01------------------------------
    //----------------------------------------------------------------------
    ProcessResult processResult = processPageTest("Rgaa32016.Test.08.08.01-2Failed-01");
    checkResultIsFailed(processResult, 4, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, RemarkMessageStore.MALFORMED_LANGUAGE_DECLARATION_MSG, HtmlElementStore.DIV_ELEMENT, 1, new ImmutablePair(EvidenceStore.LANGUAGE_EE, "fren-FR"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-02------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.08.08.01-2Failed-02");
    checkResultIsFailed(processResult, 4, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, RemarkMessageStore.WRONG_LANGUAGE_DECLARATION_MSG, HtmlElementStore.DIV_ELEMENT, 1, new ImmutablePair(EvidenceStore.LANGUAGE_EE, "aq"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-03------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.08.08.01-2Failed-03");
    checkResultIsFailed(processResult, 4, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, RemarkMessageStore.MALFORMED_LANGUAGE_DECLARATION_MSG, HtmlElementStore.DIV_ELEMENT, 1, new ImmutablePair(EvidenceStore.LANGUAGE_EE, "french"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-04------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.08.08.01-2Failed-04");
    checkResultIsFailed(processResult, 4, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, RemarkMessageStore.MALFORMED_LANGUAGE_DECLARATION_MSG, HtmlElementStore.DIV_ELEMENT, 1, new ImmutablePair(EvidenceStore.LANGUAGE_EE, "fr-F"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-05------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.08.08.01-2Failed-05");
    checkResultIsFailed(processResult, 4, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, RemarkMessageStore.MALFORMED_LANGUAGE_DECLARATION_MSG, HtmlElementStore.DIV_ELEMENT, 1, new ImmutablePair(EvidenceStore.LANGUAGE_EE, "fr/FR"));
    //----------------------------------------------------------------------
    //------------------------------4NA-01----------------------------------
    //----------------------------------------------------------------------
    checkResultIsNotApplicable(processPageTest("Rgaa32016.Test.08.08.01-4NA-01"));
    //----------------------------------------------------------------------
    //------------------------------4NA-02----------------------------------
    //----------------------------------------------------------------------
    checkResultIsNotApplicable(processPageTest("Rgaa32016.Test.08.08.01-4NA-02"));
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Example 97 with ImmutablePair

use of org.apache.commons.lang3.tuple.ImmutablePair in project Asqatasun by Asqatasun.

the class Rgaa32016Rule100102Test method setProcess.

@Override
protected void setProcess() {
    //----------------------------------------------------------------------
    //------------------------------1Passed-01------------------------------
    //----------------------------------------------------------------------
    checkResultIsPassed(processPageTest("Rgaa32016.Test.10.01.02-1Passed-01"), 12);
    //----------------------------------------------------------------------
    //------------------------------1Passed-02------------------------------
    //----------------------------------------------------------------------
    checkResultIsPassed(processPageTest("Rgaa32016.Test.10.01.02-1Passed-02"), 13);
    //----------------------------------------------------------------------
    //------------------------------1Passed-03------------------------------
    //----------------------------------------------------------------------
    checkResultIsPassed(processPageTest("Rgaa32016.Test.10.01.02-1Passed-03"), 13);
    //----------------------------------------------------------------------
    //------------------------------1Passed-04------------------------------
    //----------------------------------------------------------------------
    checkResultIsPassed(processPageTest("Rgaa32016.Test.10.01.02-1Passed-04"), 18);
    //----------------------------------------------------------------------
    //------------------------------1Passed-05------------------------------
    //----------------------------------------------------------------------
    checkResultIsPassed(processPageTest("Rgaa32016.Test.10.01.02-1Passed-05"), 15);
    //----------------------------------------------------------------------
    //------------------------------2Failed-01------------------------------
    //----------------------------------------------------------------------
    ProcessResult processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-01");
    checkResultIsFailed(processResult, 12, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", HtmlElementStore.H1_ELEMENT, 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "align"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-02------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-02");
    checkResultIsFailed(processResult, 12, 2);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", HtmlElementStore.BODY_ELEMENT, 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "background"));
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", HtmlElementStore.DIV_ELEMENT, 2, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "background"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-03------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-03");
    checkResultIsFailed(processResult, 11, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", HtmlElementStore.BODY_ELEMENT, 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "bgcolor"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-04------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-04");
    checkResultIsFailed(processResult, 12, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", HtmlElementStore.IMG_ELEMENT, 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "border"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-05------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-05");
    checkResultIsFailed(processResult, 13, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", "font", 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "color"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-06------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-06");
    checkResultIsFailed(processResult, 11, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", HtmlElementStore.BODY_ELEMENT, 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "link"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-07------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-07");
    checkResultIsFailed(processResult, 11, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", HtmlElementStore.BODY_ELEMENT, 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "alink"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-08------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-08");
    checkResultIsFailed(processResult, 11, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", HtmlElementStore.BODY_ELEMENT, 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "vlink"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-09------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-09");
    checkResultIsFailed(processResult, 11, 1);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", HtmlElementStore.BODY_ELEMENT, 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "text"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-10------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.10.01.02-2Failed-10");
    checkResultIsFailed(processResult, 14, 2);
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", "hr", 1, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "width"));
    checkRemarkIsPresent(processResult, TestSolution.FAILED, "PresentationAttrFound", "hr", 2, new ImmutablePair(EvidenceStore.ELEMENT_NAME_EE, "height"));
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ProcessResult(org.asqatasun.entity.audit.ProcessResult)

Example 98 with ImmutablePair

use of org.apache.commons.lang3.tuple.ImmutablePair in project Asqatasun by Asqatasun.

the class Rgaa32016Rule130201Test method setProcess.

@Override
protected void setProcess() {
    //----------------------------------------------------------------------
    //------------------------------3NMI-01---------------------------------
    //----------------------------------------------------------------------
    ProcessResult processResult = processPageTest("Rgaa32016.Test.13.02.01-3NMI-01");
    checkResultIsPreQualified(processResult, 0, 1);
    checkRemarkIsPresent(processResult, TestSolution.NEED_MORE_INFO, RemarkMessageStore.CHECK_JS_PROMPT_A_NEW_WINDOW_MSG, HtmlElementStore.EMBED_ELEMENT, 1);
    //----------------------------------------------------------------------
    //------------------------------3NMI-02---------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.13.02.01-3NMI-02");
    checkResultIsPreQualified(processResult, 0, 1);
    checkRemarkIsPresent(processResult, TestSolution.NEED_MORE_INFO, RemarkMessageStore.CHECK_JS_PROMPT_A_NEW_WINDOW_MSG, HtmlElementStore.EMBED_ELEMENT, 1);
    //----------------------------------------------------------------------
    //------------------------------3NMI-03---------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.13.02.01-3NMI-03");
    checkResultIsPreQualified(processResult, 0, 1);
    checkRemarkIsPresent(processResult, TestSolution.NEED_MORE_INFO, RemarkMessageStore.CHECK_JS_PROMPT_A_NEW_WINDOW_MSG, HtmlElementStore.EMBED_ELEMENT, 1);
    //----------------------------------------------------------------------
    //------------------------------3NMI-04---------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.13.02.01-3NMI-04");
    checkResultIsPreQualified(processResult, 1, 1);
    checkRemarkIsPresent(processResult, TestSolution.NEED_MORE_INFO, RemarkMessageStore.CHECK_USER_IS_WARNED_WHEN_NEW_WINDOW_OPEN_MSG, HtmlElementStore.A_ELEMENT, 1, new ImmutablePair(HtmlElementStore.TEXT_ELEMENT2, "My link"), new ImmutablePair(AttributeStore.TITLE_ATTR, "attribute-absent"));
    //----------------------------------------------------------------------
    //------------------------------3NMI-05---------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.13.02.01-3NMI-05");
    checkResultIsPreQualified(processResult, 4, 4);
    checkRemarkIsPresent(processResult, TestSolution.NEED_MORE_INFO, RemarkMessageStore.CHECK_USER_IS_WARNED_WHEN_NEW_WINDOW_OPEN_MSG, HtmlElementStore.A_ELEMENT, 1, new ImmutablePair(HtmlElementStore.TEXT_ELEMENT2, "My link 1"), new ImmutablePair(AttributeStore.TITLE_ATTR, "attribute-absent"));
    checkRemarkIsPresent(processResult, TestSolution.NEED_MORE_INFO, RemarkMessageStore.CHECK_USER_IS_WARNED_WHEN_NEW_WINDOW_OPEN_MSG, HtmlElementStore.A_ELEMENT, 2, new ImmutablePair(HtmlElementStore.TEXT_ELEMENT2, "My link 2"), new ImmutablePair(AttributeStore.TITLE_ATTR, "attribute-absent"));
    checkRemarkIsPresent(processResult, TestSolution.NEED_MORE_INFO, RemarkMessageStore.CHECK_USER_IS_WARNED_WHEN_NEW_WINDOW_OPEN_MSG, HtmlElementStore.A_ELEMENT, 3, new ImmutablePair(HtmlElementStore.TEXT_ELEMENT2, "My link 3"), new ImmutablePair(AttributeStore.TITLE_ATTR, "Link 3 title"));
    checkRemarkIsPresent(processResult, TestSolution.NEED_MORE_INFO, RemarkMessageStore.CHECK_USER_IS_WARNED_WHEN_NEW_WINDOW_OPEN_MSG, HtmlElementStore.A_ELEMENT, 4, new ImmutablePair(HtmlElementStore.TEXT_ELEMENT2, "My link 4"), new ImmutablePair(AttributeStore.TITLE_ATTR, "attribute-absent"));
    //----------------------------------------------------------------------
    //------------------------------3NMI-06---------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("Rgaa32016.Test.13.02.01-3NMI-06");
    checkResultIsPreQualified(processResult, 0, 1);
    checkRemarkIsPresent(processResult, TestSolution.NEED_MORE_INFO, RemarkMessageStore.CHECK_JS_PROMPT_A_NEW_WINDOW_MSG, HtmlElementStore.EMBED_ELEMENT, 1);
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Example 99 with ImmutablePair

use of org.apache.commons.lang3.tuple.ImmutablePair in project asterixdb by apache.

the class LicenseMojo method addDependencyToLicenseMap.

private void addDependencyToLicenseMap(MavenProject depProject, List<Pair<String, String>> depLicenses, String depLocation) {
    final String depGav = toGav(depProject);
    getLog().debug("adding " + depGav + ", location: " + depLocation);
    final MutableBoolean usedMetric = new MutableBoolean(false);
    if (depLicenses.size() > 1) {
        Collections.sort(depLicenses, (o1, o2) -> {
            final int metric1 = getLicenseMetric(o1.getLeft());
            final int metric2 = getLicenseMetric(o2.getLeft());
            usedMetric.setValue(usedMetric.booleanValue() || metric1 != LicenseSpec.UNDEFINED_LICENSE_METRIC || metric2 != LicenseSpec.UNDEFINED_LICENSE_METRIC);
            return Integer.compare(metric1, metric2);
        });
        if (usedMetric.booleanValue()) {
            getLog().info("Multiple licenses for " + depGav + ": " + depLicenses + "; taking lowest metric: " + depLicenses.get(0));
        } else {
            getLog().warn("Multiple licenses for " + depGav + ": " + depLicenses + "; taking first listed: " + depLicenses.get(0));
        }
    } else if (depLicenses.isEmpty()) {
        getLog().info("no license defined in model for " + depGav);
        depLicenses.add(new ImmutablePair<>("MISSING_LICENSE", null));
    }
    Pair<String, String> key = depLicenses.get(0);
    String licenseUrl = key.getLeft();
    final String displayName = key.getRight();
    if (!urlToLicenseMap.containsKey(licenseUrl)) {
        // assuming we've not already mapped it, annotate the URL with artifact info, if not an actual URL
        try {
            getLog().debug("- URL: " + new URL(licenseUrl));
        // life is good
        } catch (MalformedURLException e) {
            // we encounter this a lot.  Log a warning, and use an annotated key
            final String fakeLicenseUrl = depGav.replaceAll(":", "--") + "_" + licenseUrl;
            getLog().info("- URL for " + depGav + " is malformed: " + licenseUrl + "; using: " + fakeLicenseUrl);
            licenseUrl = fakeLicenseUrl;
        }
    }
    addProject(new Project(depProject, depLocation, depProject.getArtifact().getFile()), new LicenseSpec(licenseUrl, displayName), true);
}
Also used : Project(org.apache.hyracks.maven.license.project.Project) MavenProject(org.apache.maven.project.MavenProject) MalformedURLException(java.net.MalformedURLException) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) URL(java.net.URL)

Example 100 with ImmutablePair

use of org.apache.commons.lang3.tuple.ImmutablePair in project asterixdb by apache.

the class LicenseMojo method gatherProjectDependencies.

private void gatherProjectDependencies(MavenProject project, Map<MavenProject, List<Pair<String, String>>> dependencyLicenseMap, Map<String, MavenProject> dependencyGavMap) throws ProjectBuildingException {
    final Set dependencyArtifacts = project.getArtifacts();
    if (dependencyArtifacts != null) {
        for (Object depArtifactObj : dependencyArtifacts) {
            final Artifact depArtifact = (Artifact) depArtifactObj;
            if (!excludedScopes.contains(depArtifact.getScope())) {
                MavenProject dep = resolveDependency(depArtifact);
                dep.setArtifact(depArtifact);
                dependencyGavMap.put(toGav(dep), dep);
                List<Pair<String, String>> licenseUrls = new ArrayList<>();
                for (Object license : dep.getLicenses()) {
                    final License license1 = (License) license;
                    String url = license1.getUrl() != null ? license1.getUrl() : (license1.getName() != null ? license1.getName() : "LICENSE_EMPTY_NAME_URL");
                    licenseUrls.add(new ImmutablePair<>(url, license1.getName()));
                }
                dependencyLicenseMap.put(dep, licenseUrls);
            }
        }
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) License(org.apache.maven.model.License) Artifact(org.apache.maven.artifact.Artifact) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Aggregations

ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)234 ProcessResult (org.asqatasun.entity.audit.ProcessResult)109 Pair (org.apache.commons.lang3.tuple.Pair)28 ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)19 Collectors (java.util.stream.Collectors)18 IntStream (java.util.stream.IntStream)18 File (java.io.File)17 IOException (java.io.IOException)16 java.util (java.util)16 ArrayList (java.util.ArrayList)15 UserException (org.broadinstitute.hellbender.exceptions.UserException)15 ParamUtils (org.broadinstitute.hellbender.utils.param.ParamUtils)14 INDArray (org.nd4j.linalg.api.ndarray.INDArray)14 Nonnull (javax.annotation.Nonnull)12 Logger (org.apache.logging.log4j.Logger)12 VisibleForTesting (com.google.common.annotations.VisibleForTesting)10 HashMap (java.util.HashMap)10 Nullable (javax.annotation.Nullable)10 ImmutableTriple (org.apache.commons.lang3.tuple.ImmutableTriple)10 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)10