package models;

import org.junit.Test;
import utils.JodaDateUtil;
import org.apache.commons.lang.StringUtils;
import static org.fest.assertions.Assertions.assertThat;


/**
 * @author Changsung Kim
 */
public class CodeCommentThreadTest extends ModelTest<CodeCommentThread>  {
    @Test
    public void checkDefaultValueForPrevCommitId() {
        // given
        String commitId = "1234568";

        CodeCommentThread codeCommentThread = new CodeCommentThread();
        codeCommentThread.createdDate = JodaDateUtil.before(2);
        codeCommentThread.commitId = commitId;
        codeCommentThread.save();

        // when
        CodeCommentThread savedCodeCommentThread = CodeCommentThread.find.byId(1l);

        // then
        assertThat(savedCodeCommentThread.prevCommitId).isEqualTo(StringUtils.EMPTY);
    }
}

@@ -363,35 +363,101 @@
     
-String commitId = %221234568%22
+Project project = new Project();%0A        project.name = %22testProject%22;%0A        project.save()
 ;%0A%0A 
@@ -583,16 +583,12 @@
 til.
-before(2
+now(
 );%0A 
@@ -627,50 +627,136 @@
 d = 
-commitId;%0A        codeCommentThread.save()
+%221234568%22;%0A        codeCommentThread.project = project;%0A        codeCommentThread.save();%0A        Long id = codeCommentThread.id
 ;%0A%0A 
@@ -853,10 +853,10 @@
 yId(
-1l
+id
 );%0A%0A

fix errors and modify test logics for prevCommitId.