<commit_before>/*
 * Tanaguru - Automated webpage assessment
 * Copyright (C) 2008-2013  Open-S Company
 *
 * This file is part of Tanaguru.
 *
 * Tanaguru is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contact us by mail: open-s AT open-s DOT com
 */
package org.opens.tanaguru.ruleimplementation;


import java.util.List;
import org.opens.tanaguru.entity.audit.DefiniteResult;
import org.opens.tanaguru.entity.audit.ProcessResult;
import org.opens.tanaguru.entity.audit.TestSolution;
import org.opens.tanaguru.entity.subject.Site;
import org.opens.tanaguru.processor.SSPHandler;
import org.opens.tanaguru.service.ProcessRemarkService;

/**
 * <p>
 * This class should be overridden by concrete {@link RuleImplementation} 
 * classes which implement tests with site scope.
 * </p>
 * A no process rule implementation that returns NOT_APPLICABLE when the 
 * current audit is a page audit (one page tested) and NOT_TESTED instead. 
 */
public abstract class AbstractNotTestedSiteRuleImplementation 
            extends AbstractSiteRuleImplementation {

    private static final String MOCK_INDEFINITE_RESULT = "mock-result";
    
    /**
     * Default constructor
     */
    public AbstractNotTestedSiteRuleImplementation () {
        super();
    }

    @Override
    protected ProcessResult processImpl(SSPHandler sspHandler) {
        return this.indefiniteResultFactory.create(
                test, 
                sspHandler.getPage(), 
                MOCK_INDEFINITE_RESULT);
    }

    @Override
    protected DefiniteResult consolidateSiteImpl(
            Site group, 
            List<ProcessResult> groupedGrossResultList, 
            ProcessRemarkService processRemarkService) {
        // if only one gross result have been created, that means that only
        // one page is currently tested. The test is then not_applicable
        if (groupedGrossResultList.size() == 1) {
            return this.definiteResultFactory.create(
                test, 
                groupedGrossResultList.iterator().next().getSubject(), 
                TestSolution.NOT_APPLICABLE, 
                null);
        };
        return this.definiteResultFactory.create(
                test, 
                groupedGrossResultList.iterator().next().getSubject(), 
                TestSolution.NOT_TESTED, 
                null);
    }

}<commit_msg>rules-commons : creation of an abstract not tested site rule implementation that returns not applicable when one page is tested, not_tested instead<commit_after>/*
 * Tanaguru - Automated webpage assessment
 * Copyright (C) 2008-2013  Open-S Company
 *
 * This file is part of Tanaguru.
 *
 * Tanaguru is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contact us by mail: open-s AT open-s DOT com
 */
package org.opens.tanaguru.ruleimplementation;


import java.util.List;
import org.opens.tanaguru.entity.audit.DefiniteResult;
import org.opens.tanaguru.entity.audit.ProcessResult;
import org.opens.tanaguru.entity.audit.TestSolution;
import org.opens.tanaguru.entity.subject.Site;
import org.opens.tanaguru.processor.SSPHandler;
import org.opens.tanaguru.service.ProcessRemarkService;

/**
 * <p>
 * This class should be overridden by concrete {@link RuleImplementation} 
 * classes which implement tests with site scope.
 * </p>
 * A no process rule implementation that returns NOT_APPLICABLE when the 
 * current audit is a page audit (one page tested) and NOT_TESTED instead. 
 */
public abstract class AbstractNotTestedSiteRuleImplementation 
            extends AbstractGroupRuleImplementation {

    private static final String MOCK_INDEFINITE_RESULT = "mock-result";
    
    /**
     * Default constructor
     */
    public AbstractNotTestedSiteRuleImplementation () {
        super();
    }

    @Override
    protected ProcessResult processImpl(SSPHandler sspHandler) {
        return this.indefiniteResultFactory.create(
                test, 
                sspHandler.getPage(), 
                MOCK_INDEFINITE_RESULT);
    }

    @Override
    protected DefiniteResult consolidateGroupImpl(
            Site group, 
            List<ProcessResult> groupedGrossResultList, 
            ProcessRemarkService processRemarkService) {
        return this.definiteResultFactory.create(
                test, 
                group, 
                TestSolution.NOT_TESTED, 
                null);
    }

}
{'fraction_non_alphanumeric': 0.07084078711985689, 'fraction_numerical': 0.003398926654740608, 'mean_word_length': 2.9235087719298245, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2568119', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1433, 'n_words': 501}