<commit_before>package ca.sukhsingh.actions.on.google.response.data.google.richresponse;

import ca.sukhsingh.actions.on.google.AssertHelper;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnitRunner;

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

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

/**
 * Created by sukhsingh on 2017-09-06.
 */
@RunWith(MockitoJUnitRunner.class)
public class RichResponseTest extends AssertHelper {

    @InjectMocks
    private RichResponse richResponse;

    /*
    addSimpleResponse(Object)
        1. Item count is more then 2
        2. null object
        3. param as string
            a. textToSpeech String
            b. ssml string
            c. empty string
            d. null
        4. param as SimpleResponse
            a. SimpleResponse with textToSpeech
            b. SimpleResponse with SSML
            c. SimpleResponse with both empty strings
            d. SimpleResponse with one empty string
            e. SimpleResponse with both null string
        5. param as int/or any other object
     */

    @Test
    public void addSimpleResponseTestWithItemMoreThenTwo() throws Exception {
        RichResponse response = new RichResponse();
        List<Item> itemList = new ArrayList<>();
        itemList.add(new Item(new SimpleResponse("Hello", "hi")));
        itemList.add(new Item(new SimpleResponse("hello","hi")));
        response.setItems(itemList);
        RichResponse richResponse = new RichResponse(response);
        richResponse.addSimpleResponse(new SimpleResponse("sukh", "singh"));

        assertEquals("Item size should be 2", 2, richResponse.getItems().size());
        assertEquals("Items should be exactly same as itemList", itemList, richResponse.getItems());
    }
    @Test
    public void addSimpleResponseTestWithNullParam() throws Exception {
        RichResponse response = richResponse.addSimpleResponse(null);
        assertNull(response);
    }

    @Test
    public void simpleResponseParamWithTextToSpeechString() {
        richResponse.addSimpleResponse("Hello");
        assertTextToSpeech(richResponse, "Hello");
    }

    @Test
    public void simpleResponseParamWithSSSMLString() {
        final String SSML = "<speak>Hello</speak>";
        richResponse.addSimpleResponse(SSML);
        assertSsmlText(richResponse, SSML);
    }

//    public void simpleResponseParamWithEmptyString() {
//
//    }

    @Test
    public void simpleResponseParamWithNullParam() {
        richResponse.addSimpleResponse(null);
        assertEquals("Rich response should not have any item",0,richResponse.getItems().size());
    }
    @Test
    public void simpleResponseObjWithTextToSpeech() {
        richResponse.addSimpleResponse(new SimpleResponse("Hello", "hi"));
        assertTextToSpeech(richResponse,"Hello");
        assertDisplayText(richResponse, "hi");
    }

    @Test
    public void simpleResponseObjWithSSML() {
        richResponse.addSimpleResponse(new SimpleResponse("<speak>Hello</speak>", "hi"));
        assertSsmlText(richResponse,"<speak>Hello</speak>");
        assertDisplayText(richResponse, "hi");
    }

    @Test
    public void simpleResponseObjWithBothEmptyParams() {
        richResponse.addSimpleResponse(new SimpleResponse("", ""));
        assertEquals("Rich response should not have any item",0,richResponse.getItems().size());
    }


//    public void simpleResponseObjWithOnlyOneEmptyParam() {}

//    public void simpleResponseObjWithBothNullParams() {}
    @Test
    public void addSimpleResponseTestWithInvalidObj() throws Exception {
        richResponse.addSimpleResponse(new Object());
        assertNull(richResponse.getItems().get(0).getSimpleResponse());
    }
    
    /*
    addSimpleResponse(string, string)
        1. Item count is more then 2
        2. Both strings null<commit_msg>unit tests for : addSimpleResponse<commit_after>package ca.sukhsingh.actions.on.google.response.data.google.richresponse;

import ca.sukhsingh.actions.on.google.AssertHelper;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnitRunner;

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

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

/**
 * Created by sukhsingh on 2017-09-06.
 */
@RunWith(MockitoJUnitRunner.class)
public class RichResponseTest extends AssertHelper {

    @InjectMocks
    private RichResponse richResponse;

    /*
    addSimpleResponse(Object)
        1. Item count is more then 2
        2. null object
        3. param as string
            a. textToSpeech String
            b. ssml string
            c. empty string
            d. null
        4. param as SimpleResponse
            a. SimpleResponse with textToSpeech
            b. SimpleResponse with SSML
            c. SimpleResponse with both empty strings
            d. SimpleResponse with one empty string
            e. SimpleResponse with both null string
        5. param as int/or any other object
     */

    @Test
    public void addSimpleResponseTestWithItemMoreThenTwo() throws Exception {
        RichResponse response = new RichResponse();
        List<Item> itemList = new ArrayList<>();
        itemList.add(new Item(new SimpleResponse("Hello", "hi")));
        itemList.add(new Item(new SimpleResponse("hello","hi")));
        response.setItems(itemList);
        RichResponse richResponse = new RichResponse(response);
        richResponse.addSimpleResponse(new SimpleResponse("sukh", "singh"));

        assertEquals("Item size should be 2", 2, richResponse.getItems().size());
        assertEquals("Items should be exactly same as itemList", itemList, richResponse.getItems());
    }
    @Test
    public void addSimpleResponseTestWithNullParam() throws Exception {
        RichResponse response = richResponse.addSimpleResponse(null);
        assertNull(response);
    }

    @Test
    public void simpleResponseParamWithTextToSpeechString() {
        richResponse.addSimpleResponse("Hello");
        assertTextToSpeech(richResponse, "Hello");
    }

    @Test
    public void simpleResponseParamWithSSSMLString() {
        final String SSML = "<speak>Hello</speak>";
        richResponse.addSimpleResponse(SSML);
        assertSsmlText(richResponse, SSML);
    }

//    public void simpleResponseParamWithEmptyString() {
//
//    }

    @Test
    public void simpleResponseParamWithNullParam() {
        richResponse.addSimpleResponse(null);
        assertEquals("Rich response should not have any item",0,richResponse.getItems().size());
    }
    @Test
    public void simpleResponseObjWithTextToSpeech() {
        richResponse.addSimpleResponse(new SimpleResponse("Hello", "hi"));
        assertTextToSpeech(richResponse,"Hello");
        assertDisplayText(richResponse, "hi");
    }

    @Test
    public void simpleResponseObjWithSSML() {
        richResponse.addSimpleResponse(new SimpleResponse("<speak>Hello</speak>", "hi"));
        assertSsmlText(richResponse,"<speak>Hello</speak>");
        assertDisplayText(richResponse, "hi");
    }

//    @Test
//    public void simpleResponseObjWithBothEmptyParams() {
//        richResponse.addSimpleResponse(new SimpleResponse("", ""));
//        assertEquals("Rich response should not have any item",0,richResponse.getItems().size());
//    }


//    public void simpleResponseObjWithOnlyOneEmptyParam() {}

//    public void simpleResponseObjWithBothNullParams() {}
    @Test
    public void addSimpleResponseTestWithInvalidObj() throws Exception {
        richResponse.addSimpleResponse(new Object());
        assertNull(richResponse.getItems().get(0).getSimpleResponse());
    }
    
    /*
    addSimpleResponse(string, string)
        1. Item count is more then 2
        2. Both strings null
{'fraction_non_alphanumeric': 0.09973916283691467, 'fraction_numerical': 0.005465159607502173, 'mean_word_length': 3.1915668922436233, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4050190', 'n_tokens_mistral': 2172, 'n_tokens_neox': 2136, 'n_words': 510}