<commit_before>package com.coeligena.service.impl;

import com.coeligena.function.date.DateUtils;
import com.coeligena.model.AnswerCommentsDO;
import com.coeligena.service.AnswerCommentsService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.test.annotation.Rollback;

import java.sql.Timestamp;

/**
 * junit test AnswerCommentsServiceImpl
 * Created by Ellery on 2018/8/25.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"file:src/main/webapp/WEB-INF/configs/application-context.xml"})
@Transactional
@Rollback
public class AnswerCommentsServiceImplTest {

    @Autowired
    private AnswerCommentsService answerCommentsService;

    @Test
    public void testSaveAnswerComments() {
        Timestamp now = DateUtils.currentTime();

        AnswerCommentsDO answerCommentsDO = new AnswerCommentsDO();
        answerCommentsDO.setAnswerId(2);
        answerCommentsDO.setCommentContent("junit test");
        answerCommentsDO.setCommentTime(now);
        answerCommentsService.saveAnswerComment(answerCommentsDO);

        Assert.assertEquals(answerCommentsService.queryAnswerCommentById(
                answerCommentsDO.getId()).getCommentContent(),"junit test");
    }
}<commit_msg>feat: finish answer comments service test<commit_after>package com.coeligena.service.impl;

import com.coeligena.function.date.DateUtils;
import com.coeligena.function.paging.Page;
import com.coeligena.model.AnswerCommentsDO;
import com.coeligena.service.AnswerCommentsService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.test.annotation.Rollback;

import java.sql.Timestamp;

/**
 * junit test AnswerCommentsServiceImpl
 * Created by Ellery on 2018/8/25.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"file:src/main/webapp/WEB-INF/configs/application-context.xml"})
@Transactional
@Rollback
public class AnswerCommentsServiceImplTest {

    @Autowired
    private AnswerCommentsService answerCommentsService;

    @Test
    public void testSaveAnswerComments() {
        Timestamp now = DateUtils.currentTime();

        AnswerCommentsDO answerCommentsDO = new AnswerCommentsDO();
        answerCommentsDO.setAnswerId(2);
        answerCommentsDO.setCommentContent("junit test");
        answerCommentsDO.setCommentTime(now);
        answerCommentsService.saveAnswerComment(answerCommentsDO);

        Assert.assertEquals(answerCommentsService.queryAnswerCommentById(
                answerCommentsDO.getId()).getCommentContent(),"junit test");
    }

    @Test
    public void testQueryAnswerCommentCount() {
        Assert.assertEquals(answerCommentsService
                .queryAnswerCommentsCount(2), 14);
    }

    @Test
    public void testQueryAnswerCommentByPage() {
        // 初始化分页信息
        Page page = new Page(1, 2);
        page.setSize(answerCommentsService.queryAnswerCommentsCount(2));
        page.setNavigatePages(3);
        page.init();

        Assert.assertEquals(answerCommentsService
                .queryAnswerCommentsByPage(page, 2).size(), 2);
    }

    @Test
    public void testQueryAnswerCommentById() {
        AnswerCommentsDO answerCommentsDO = answerCommentsService.queryAnswerCommentById(2);
        Assert.assertEquals(answerCommentsDO.getId(), 2);
    }
}
{'fraction_non_alphanumeric': 0.09389430477167779, 'fraction_numerical': 0.008465879938429965, 'mean_word_length': 4.57, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1118567', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1037, 'n_words': 170}