<commit_before>package crawler.service.impl;

import static org.mockito.BDDMockito.*;

import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;

import crawler.dao.NovelDao;
import crawler.domain.Novel;
import crawler.service.NovelChapterManager;
import crawler.service.NovelInfoManager;

public class NovelManagerImplTest extends BaseManagerMockTestCase {

    @Mock
    private Logger log;

    @Mock
    private NovelDao novelDao;

    @Mock
    private NovelInfoManager novelInfoManager;

    @Mock
    private NovelChapterManager novelChapterManager;

    @InjectMocks
    private NovelManagerImpl novelManager = new NovelManagerImpl();

    @Test
    public void testAddAndDelete() throws Exception {
        String filePath = this.getClass().getClassLoader().getResource("novel/20160924/test.html").getPath();

        // 登録対象有り
        novelManager.add("file://" + filePath);

        Novel novel = new Novel();
        novel.setUrl("file://" + filePath);
        novel.setTitle("Test小説のタイトル");
        novel.setWritername("Test作者名");
        novel.setDescription("Test小説の説明");
        novel.setBody("Test本文");

        given(novelDao.getByUrl("file://" + filePath)).willReturn(novel);

        // 登録済み
        novelManager.add("file://" + filePath);

        // 削除
        novelManager.delete("file://" + filePath);

        // 登録対象無し
        novelManager.add("file://" + filePath + "test");
    }

    @Test
    public void testCheckForUpdatesAndSaveHistory() throws Exception {
        String filePath = this.getClass().getClassLoader().getResource("novel/20160924/test.html").getPath();

        Novel novel = new Novel();
        novel.setUrl("file://" + filePath);
        novel.setTitle("Test小説のタイトル");
        novel.setWritername("Test作者名");
        novel.setDescription("Test小説の説明");
        novel.setBody("Test本文");

        given(novelDao.get(1L)).willReturn(novel);

        // 更新対象有り
        novelManager.checkForUpdatesAndSaveHistory(1L);

        // 更新対象無し
        novelManager.checkForUpdatesAndSaveHistory(2L);

        novel.setUrl("file://" + filePath + "test");
        // 更新対象無し
        novelManager.checkForUpdatesAndSaveHistory(novel);
    }

    @Test
    public void testSendReport() throws Exception {
        novelManager.sendReport();
    }
}
<commit_msg>Unit Testの実装 #1<commit_after>package crawler.service.impl;

import static org.mockito.BDDMockito.*;

import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;

import crawler.dao.NovelDao;
import crawler.domain.Novel;
import crawler.service.NovelChapterManager;
import crawler.service.NovelInfoManager;

public class NovelManagerImplTest extends BaseManagerMockTestCase {

    @Mock
    private Logger log;

    @Mock
    private NovelDao novelDao;

    @Mock
    private NovelInfoManager novelInfoManager;

    @Mock
    private NovelChapterManager novelChapterManager;

    @InjectMocks
    private NovelManagerImpl novelManager = new NovelManagerImpl();

    @Test
    public void testAddAndDelete() {
        String filePath = this.getClass().getClassLoader().getResource("novel/20160924/test.html").getPath();

        // 登録対象有り
        novelManager.add("file://" + filePath);

        Novel novel = new Novel();
        novel.setUrl("file://" + filePath);
        novel.setTitle("Test小説のタイトル");
        novel.setWritername("Test作者名");
        novel.setDescription("Test小説の説明");
        novel.setBody("Test本文");

        given(novelDao.getByUrl("file://" + filePath)).willReturn(novel);

        // 登録済み
        novelManager.add("file://" + filePath);

        // 削除
        novelManager.delete("file://" + filePath);

        // 登録対象無し
        novelManager.add("file://" + filePath + "test");
    }

    @Test
    public void testCheckForUpdatesAndSaveHistory() {
        String filePath = this.getClass().getClassLoader().getResource("novel/20160924/test.html").getPath();

        Novel novel = new Novel();
        novel.setUrl("file://" + filePath);
        novel.setTitle("Test小説のタイトル");
        novel.setWritername("Test作者名");
        novel.setDescription("Test小説の説明");
        novel.setBody("Test本文");

        given(novelDao.get(1L)).willReturn(novel);

        // 更新対象有り
        novelManager.checkForUpdatesAndSaveHistory(1L);

        // 更新対象無し
        novelManager.checkForUpdatesAndSaveHistory(2L);

        novel.setUrl("file://" + filePath + "test");
        // 更新対象無し
        novelManager.checkForUpdatesAndSaveHistory(novel);
    }

    @Test
    public void testSendReport() {
        novelManager.sendReport();
    }
}

{'fraction_non_alphanumeric': 0.12067894845787622, 'fraction_numerical': 0.008486855723452702, 'mean_word_length': 2.5660516605166053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6645726', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1552, 'n_words': 232}