package cc.redpen.validator.sentence;

import cc.redpen.RedPen;
import cc.redpen.RedPenException;
import cc.redpen.ValidationError;
import cc.redpen.config.Configuration;
import cc.redpen.config.ValidatorConfiguration;
import cc.redpen.distributor.FakeResultDistributor;
import cc.redpen.model.DocumentCollection;
import cc.redpen.model.Sentence;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;

public class StartWithCapitalLetterValidatorTest {
    @Test
    public void testDetectStartWithSmallCharacter() {
        StartWithCapitalLetterValidator validator = new StartWithCapitalLetterValidator();
        assertEquals(1, validator.validate(new Sentence("this is it.", 0)).size());
    }

    @Test
    public void testDetectStartWithCapitalCharacter() {
        StartWithCapitalLetterValidator validator = new StartWithCapitalLetterValidator();
        assertEquals(0, validator.validate(new Sentence("This is it.", 0)).size());
    }

    @Test
    public void testStartWithElementOfWhiteList() {
        StartWithCapitalLetterValidator validator = new StartWithCapitalLetterValidator();
        validator.addWhiteList("iPhone");
        assertEquals(0, validator.validate(new Sentence("iPhone is a mobile computer.", 0)).size());
    }

    @Test
    public void testLoadDefaultDictionary() throws RedPenException {
        Configuration config = new Configuration.Builder()
                .addValidatorConfig(new ValidatorConfiguration("StartWithCapitalLetter"))
                .setSymbolTable("en").build();

        DocumentCollection documents = new DocumentCollection.Builder()
                .addDocument("")
                .addSection(1, new ArrayList<>())
                .addParagraph()
                .addSentence(
                        "mixi is a Japanese company.",
                        1)
                .build();

        RedPen validator = new RedPen.Builder()
                .setConfiguration(config)
                .setResultDistributor(new FakeResultDistributor())
                .build();

        List<ValidationError> errors = validator.check(documents);
        assertEquals(0, errors.size());
    }
}

@@ -1302,32 +1302,334 @@
 size());%0A    %7D%0A%0A
+    @Test%0A    public void testStartWithWhiteListItemInJapaneseSentence() %7B%0A        StartWithCapitalLetterValidator validator = new StartWithCapitalLetterValidator();%0A        validator.addWhiteList(%22iPhone%22);%0A        assertEquals(0, validator.validate(new Sentence(%22iPhone %E3%81%AF%E3%82%AB%E3%83%83%E3%82%B3%E3%82%A4%E3%82%A4%EF%BC%8E%22, 0)).size());%0A    %7D%0A%0A
     @Test%0A    pu

Add a test case with Japanese input sentence