package seedu.todo.controllers;

import java.util.HashMap;
import java.util.Map;

import org.junit.*;
import static org.junit.Assert.*;

import seedu.todo.commons.exceptions.UnmatchedQuotesException;
import seedu.todo.controllers.concerns.Tokenizer;

public class ControllerConcernsTests {
    
    private static Map<String, String[]> getTokenDefinitions() {
        Map<String, String[]> tokenDefinitions = new HashMap<String, String[]>();
        tokenDefinitions.put("tokenType1", new String[] {"token11"});
        tokenDefinitions.put("tokenType2", new String[] {"token21", "token22"});
        tokenDefinitions.put("tokenType3", new String[] {"token31", "token32", "token33"});
        return tokenDefinitions;
    }
    
    @Test
    public void tokenizer_no_matches() throws Exception {
        String input = "abcdefg hijklmnop";
        Map<String, String[]> output = Tokenizer.tokenize(getTokenDefinitions(), input);
        assertTrue(output.isEmpty());
    }
    
    @Test
    public void tokenizer_empty_string() throws Exception {
        String input = "";
        Map<String, String[]> output = Tokenizer.tokenize(getTokenDefinitions(), input);
        assertTrue(output == null);
    }
    
    @Test
    public void tokenizer_single_match() throws Exception {
        String input = "token11 answer";
        Map<String, String[]> output = Tokenizer.tokenize(getTokenDefinitions(), input);
        assertEquals(output.get("tokenType1")[0], "token11");
        assertEquals(output.get("tokenType1")[1], "answer");
    }
    
    @Test
    public void tokenizer_empty_match() throws Exception {
        String input = "token11 token21";
        Map<String, String[]> output = Tokenizer.tokenize(getTokenDefinitions(), input);
        assertEquals(output.get("tokenType1")[0], "token11");
        assertEquals(output.get("tokenType1")[1], null);
        assertEquals(output.get("tokenType2")[0], "token21");
        assertEquals(output.get("tokenType2")[1], null);
    }
    
    @Test(expected=UnmatchedQuotesException.class)
    public void tokenizer_unmatched_quotes() throws Exception {
        String input = "\"\"\"";
        Tokenizer.tokenize(getTokenDefinitions(), input);
    }
    
}

@@ -1624,32 +1624,39 @@
 String input = %22
+alamak 
 token11 token21%22
@@ -1987,32 +1987,285 @@
 ll);%0A    %7D%0A    %0A
+    @Test%0A    public void tokenizer_match_quotes() throws Exception %7B%0A        String input = %22%5C%22token11%5C%22 answer%22;%0A        Map%3CString, String%5B%5D%3E output = Tokenizer.tokenize(getTokenDefinitions(), input);%0A        assertTrue(output.isEmpty());%0A    %7D%0A    %0A
     @Test(expect

Test match quotes