package models;

import static org.fest.assertions.Assertions.assertThat;

import models.enumeration.Direction;
import models.enumeration.IssueState;

import org.junit.Test;

import utils.JodaDateUtil;

import com.avaje.ebean.Page;

public class IssueTest extends ModelTest {

    @Test
    public void create() throws Exception {
        // Given
        Issue issue = new Issue();
        issue.title = "불필요한 로그 출력 코드 제거";
        issue.date = JodaDateUtil.today();
        issue.status = Issue.STATUS_ENROLLED;
        issue.reporter = getTestUser();
        // When
        // Then
        assertThat(Issue.create(issue)).isEqualTo(5l);
    }

    @Test
    public void findById() throws Exception {
        // Given
        Issue issue = new Issue();
        issue.title = "불필요한 로그 출력 코드 제거";
        issue.date = JodaDateUtil.today();
        issue.status = Issue.STATUS_ENROLLED;
        issue.reporter = getTestUser();
        Long id = Issue.create(issue);
        // When
        Issue issueTest = Issue.findById(id);
        // Then
        assertThat(issueTest).isNotNull();
    }

    @Test
    public void delete() {
        // Given
        // When
        Issue.delete(4l);
        // Then
        assertThat(Issue.findById(4l)).isNull();
    }

    @Test
    public void findOpenIssues() throws Exception {
        // Given
        // When
        Page<Issue> issues = Issue.findOpenIssues(1l);
        // Then
        assertThat(issues.getTotalRowCount()).isEqualTo(1);
    }

    @Test
    public void findClosedIssues() throws Exception {
        // Given
        // When
        Page<Issue> issues = Issue.findClosedIssues(1l);
        // Then
        assertThat(issues.getTotalRowCount()).isEqualTo(1);
    }

    @Test
    public void findFilterIssues() throws Exception {

        // Given
        // When
        Page<Issue> issues = Issue.findFilteredIssues(1l, "로그",
                IssueState.OPEN, true, true);
        // Then
        assertThat(issues.getTotalRowCount()).isEqualTo(1);

    }

    @Test
    public void findCommentedIssue() throws Exception {
        // Given
        // When
        Page<Issue> issues = Issue.findCommentedIssues(1l, "");
        // Then
        assertThat(issues.getTotalRowCount()).isEqualTo(1);
    }

    @Test
    public void findFileAttachedIssue() throws Exception {
        // Given
        // When
        Page<Issue> issues = Issue.findFileAttachedIssues(1l, "");
        // Then
        assertThat(issues.getTotalRowCount()).isEqualTo(1);
    }

}

@@ -1396,26 +1396,37 @@
 dOpenIssues(
-1l
+%22nForge4java%22
 );%0A        /
@@ -1648,18 +1648,29 @@
 dIssues(
-1l
+%22nForge4java%22
 );%0A     
@@ -1899,18 +1899,29 @@
 dIssues(
-1l
+%22nForge4java%22
 , %22%EB%A1%9C%EA%B7%B8%22,%0A
@@ -2196,34 +2196,45 @@
 CommentedIssues(
-1l
+%22nForge4java%22
 , %22%22);%0A        /
@@ -2471,10 +2471,21 @@
 ues(
-1l
+%22nForge4java%22
 , %22%22

fix test failure