package ru.matevosyan.models;

import org.junit.Test;
import ru.matevosyan.start.Input;
import ru.matevosyan.start.StartUI;
import ru.matevosyan.start.StubInput;
import ru.matevosyan.start.Tracker;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Arrays;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

/**
 * Class CommentsTest created for testing Comments class.
 * Created on 30.11.2016.
 * @author Matevosyan Vardan
 * @since 1.0
 * @version 1.0
 */

public class CommentsTest {

    /**
     * Method whenAddCommentThanGetCommentName created for testing getCommentName method, that give us the Comments name.
     * it's may the specific type of item, for example: new Task or new Bug.
     */

    @Test
    public void whenAddCommentThanGetCommentName() {
        String commentName = "comment";
        Comments comment = new Comments(commentName);
        String actual = comment.getCommentName();
        assertThat(actual, is(commentName));
    }

    /**
     * Method whenSetCommentThanFormatOutput created for testing getCommentName method, that output all with comments.
     * it's may the specific type of item, for example: new Task or new Bug.
     */

    @Test
    public void whenSetCommentThanFormatOutput() {

        Tracker tracker = new Tracker();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        System.setOut(new PrintStream(out));

        Item item = new Task("task 3", "task desc 3");
        item.addComment("comment");
        String[] answer = {
                "8",
                "n"
        };

        Input stub = new StubInput(answer);
        new StartUI(stub, tracker).init();
        Item[] items = tracker.getAll();
        String s = System.getProperty("line.separator");

        assertThat(out.toString(), is("___M_E_N_U___ " + s + "1. Add Item " + s + "2. Edit Item " + s
                + "3. Remove Item " + s + "4. Add comment" + s + "5. Find by id " + s + "6. Find by name " + s
                + "7. Find by date " + s + "8. Get all items" + s + "9. Exit" + s + s +  Arrays.toString(items) + s));
    }

}

@@ -50,244 +50,8 @@
 est;
-%0Aimport ru.matevosyan.start.Input;%0Aimport ru.matevosyan.start.StartUI;%0Aimport ru.matevosyan.start.StubInput;%0Aimport ru.matevosyan.start.Tracker;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.PrintStream;%0Aimport java.util.Arrays;
 %0A%0Aim
@@ -801,1130 +801,6 @@
  %7D%0A%0A
-    /**%0A     * Method whenSetCommentThanFormatOutput created for testing getCommentName method, that output all with comments.%0A     * it's may the specific type of item, for example: new Task or new Bug.%0A     */%0A%0A    @Test%0A    public void whenSetCommentThanFormatOutput() %7B%0A%0A        Tracker tracker = new Tracker();%0A        ByteArrayOutputStream out = new ByteArrayOutputStream();%0A        System.setOut(new PrintStream(out));%0A%0A        Item item = new Task(%22task 3%22, %22task desc 3%22);%0A        item.addComment(%22comment%22);%0A        String%5B%5D answer = %7B%0A                %228%22,%0A                %22n%22%0A        %7D;%0A%0A        Input stub = new StubInput(answer);%0A        new StartUI(stub, tracker).init();%0A        Item%5B%5D items = tracker.getAll();%0A        String s = System.getProperty(%22line.separator%22);%0A%0A        assertThat(out.toString(), is(%22___M_E_N_U___ %22 + s + %221. Add Item %22 + s + %222. Edit Item %22 + s%0A                + %223. Remove Item %22 + s + %224. Add comment%22 + s + %225. Find by id %22 + s + %226. Find by name %22 + s%0A                + %227. Find by date %22 + s + %228. Get all items%22 + s + %229. Exit%22 + s + s +  Arrays.toString(items) + s));%0A    %7D%0A%0A
 %7D%0A

edit commentsTest.xml