<commit_before>package org.intermine.web;

/*
 * Copyright (C) 2002-2004 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import org.intermine.objectstore.query.Query;

import servletunit.struts.MockStrutsTestCase;

public class IqlQueryActionTest extends MockStrutsTestCase {

    public IqlQueryActionTest(String testName) {
        super(testName);
    }

    public void setUp() throws Exception {
        super.setUp();
    }

    public void tearDown() throws Exception {
        super.tearDown();
    }

    public void testSubmitSuccessfulQuery() {
        setRequestPathInfo("/iqlquery");
        addRequestParameter("querystring","select a1_ from Company as a1_");
        addRequestParameter("action", "Run query");
        actionPerform();
        verifyForward("runquery");
        assertNotNull(getSession().getAttribute(Constants.QUERY));
        verifyNoActionErrors();
    }

    public void testSubmitEmptyQuery() {
        setRequestPathInfo("/iqlquery");
        addRequestParameter("querystring","");
        addRequestParameter("action", "Run query");
        actionPerform();
        verifyForward("error");
        assertNull(getSession().getAttribute(Constants.QUERY));
    }

    public void testSubmitRubbishQuery() {
        setRequestPathInfo("/iqlquery");
        addRequestParameter("querystring","some rubbish");
        addRequestParameter("action", "Run query");
        actionPerform();
        verifyForward("error");
        assertNull(getSession().getAttribute(Constants.QUERY));
    }

    public void testViewSuccessfulQuery() {
        setRequestPathInfo("/iqlquery");
        addRequestParameter("querystring","select a1_ from Company as a1_");
        addRequestParameter("action", "Query composer");
        actionPerform();
        verifyForward("buildquery");
        assertEquals("SELECT a1_ FROM org.intermine.model.testmodel.Company AS a1_",
                     ((Query) getSession().getAttribute(Constants.QUERY)).toString());
        verifyNoActionErrors();
    }

    public void testViewEmptyQuery() {
        setRequestPathInfo("/iqlquery");
        addRequestParameter("querystring","");
        addRequestParameter("action", "Query composer");
        actionPerform();
        verifyForward("error");
        assertNull((String) getSession().getAttribute(Constants.QUERY));
    }

    public void testViewRubbishQuery() {
        setRequestPathInfo("/iqlquery");
        addRequestParameter("querystring","some rubbish");
        addRequestParameter("action", "Query composer");
        actionPerform();
        verifyForward("error");
        assertNull((String) getSession().getAttribute(Constants.QUERY));
    }
}<commit_msg>/iqlquery is now /iqlQuery<commit_after>package org.intermine.web;

/*
 * Copyright (C) 2002-2004 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import org.intermine.objectstore.query.Query;

import servletunit.struts.MockStrutsTestCase;

public class IqlQueryActionTest extends MockStrutsTestCase {

    public IqlQueryActionTest(String testName) {
        super(testName);
    }

    public void setUp() throws Exception {
        super.setUp();
    }

    public void tearDown() throws Exception {
        super.tearDown();
    }

    public void testSubmitSuccessfulQuery() {
        setRequestPathInfo("/iqlQueryAction");
        addRequestParameter("querystring","select a1_ from Company as a1_");
        addRequestParameter("action", "Run query");
        actionPerform();
        verifyNoActionErrors();
        verifyForward("results");
        assertNotNull(getSession().getAttribute(Constants.RESULTS_TABLE));
        verifyNoActionErrors();
    }

    public void testSubmitEmptyQuery() {
        setRequestPathInfo("/iqlQueryAction");
        addRequestParameter("querystring","");
        addRequestParameter("action", "Run query");
        actionPerform();
        verifyActionErrors(new String[] {"errors.iqlquery.illegalargument"});
        verifyForward("iqlQuery");
        assertNull(getSession().getAttribute(Constants.RESULTS_TABLE));
    }

    public void testSubmitRubbishQuery() {
        setRequestPathInfo("/iqlQueryAction");
        addRequestParameter("querystring","some rubbish");
        addRequestParameter("action", "Run query");
        actionPerform();
        verifyActionErrors(new String[] {"errors.iqlquery.illegalargument"});
        verifyForward("iqlQuery");
        assertNull(getSession().getAttribute(Constants.RESULTS_TABLE));
    }
}
{'fraction_non_alphanumeric': 0.11593317033414834, 'fraction_numerical': 0.004889975550122249, 'mean_word_length': 3.3987455197132617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2767000', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1257, 'n_words': 269}