<commit_before>/*
 * Copyright 2013 ait.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package eu.scape_project.pt.util;

import eu.scape_project.pt.util.PipedArgsParser.Command;
import java.io.IOException;
import static org.junit.Assert.assertEquals;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.*;

/**
 *
 * @author ait
 */
public class PipedArgsParserTest {
    
    private static Log LOG = LogFactory.getLog(PipedArgsParserTest.class);
    public PipedArgsParserTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    /**
     * Test of parse method, of class PipedArgsParser.
     */
    @Test
    public void testParse() throws IOException {
        LOG.info("TEST parse");
        PipedArgsParser parser = new PipedArgsParser();

        LOG.info("TEST good input");
        String strCmdLine = "\"file.in\" > a-tool a-action --input1=\"bla\" --input3=\"5\" > \"file with spaces.out\"";
        parser.parse(strCmdLine);

        Command command1 = parser.new Command();
        command1.action = "a-action";
        command1.tool = "a-tool";
        command1.pairs = new HashMap<String, String>() {{
            put("input1", "bla");
            put("input3", "5");
        }};

        Command[] commandsExp = {
            command1
        };
        assertEquals(commandsExp, parser.getCommands());
        assertEquals("file.in", parser.getStdinFile() );
        assertEquals("file with spaces.out", parser.getStdoutFile() );

        LOG.info("TEST good input, stdin only");
        strCmdLine = "file.in > a-tool a-action --input1=\"bla\" --input3=\"5\"";<commit_msg>Added a valid url in input test data<commit_after>/*
 * Copyright 2013 ait.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package eu.scape_project.pt.util;

import eu.scape_project.pt.util.PipedArgsParser.Command;
import java.io.IOException;
import static org.junit.Assert.assertEquals;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.*;

/**
 *
 * @author ait
 */
public class PipedArgsParserTest {
    
    private static Log LOG = LogFactory.getLog(PipedArgsParserTest.class);
    public PipedArgsParserTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    /**
     * Test of parse method, of class PipedArgsParser.
     */
    @Test
    public void testParse() throws IOException {
        LOG.info("TEST parse");
        PipedArgsParser parser = new PipedArgsParser();

        LOG.info("TEST good input");
        String strCmdLine = "\"hdfs:///file.in\" > a-tool a-action --input1=\"bla\" --input3=\"5\" > \"file with spaces.out\"";
        parser.parse(strCmdLine);

        Command command1 = parser.new Command();
        command1.action = "a-action";
        command1.tool = "a-tool";
        command1.pairs = new HashMap<String, String>() {{
            put("input1", "bla");
            put("input3", "5");
        }};

        Command[] commandsExp = {
            command1
        };
        assertEquals(commandsExp, parser.getCommands());
        assertEquals("hdfs:///file.in", parser.getStdinFile() );
        assertEquals("file with spaces.out", parser.getStdoutFile() );

        LOG.info("TEST good input, stdin only");
        strCmdLine = "file.in > a-tool a-action --input1=\"bla\" --input3=\"5\"";
{'fraction_non_alphanumeric': 0.12092092092092092, 'fraction_numerical': 0.00880880880880881, 'mean_word_length': 2.7677224736048265, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5219312', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1425, 'n_words': 426}