@Test public void plagiarismCheckeServiceCheckTest() throws IOException, ParseException { String indexRoot = "index"; List<ContentAnalyzerType> contentAnalizersList = Lists.newArrayList( ContentAnalyzerType.SimpleContentAnalizerWithSimpleTokenizer, ContentAnalyzerType.BagOfWordsContentAnalizerWithOpenNLPTokenizer); IndexBuilderTest.setupIndex(indexRoot, contentAnalizersList); String[] args = { "--articleRepositoryFolders", Joiner.on(',').join(ArticleRepositoryTestUtil.FOLDERS), "--contentAnalyzers", Joiner.on(',').join(contentAnalizersList), "--indexPaths", indexRoot }; PlagiarismCheckerService.setupContext(args); PlagiarismCheckerService plagiarismCheckeService = new PlagiarismCheckerService(); for (int i = 0; i < ArticleRepositoryTestUtil.ARTICLES.length; ++i) { for (int j = 0; j < ArticleRepositoryTestUtil.ARTICLES[i].length; ++j) { Assert.assertEquals( Lists.newArrayList( new CheckResult( i, j, ArticleRepositoryTestUtil.ARTICLES[i][j], contentAnalizersList)), Lists.newArrayList( plagiarismCheckeService.check(ArticleRepositoryTestUtil.ARTICLES[i][j]))); } } IndexBuilderTest.deleteIndex(indexRoot, contentAnalizersList); }
@Test public void setupContextTest() throws ParseException, IOException { String indexRoot = "index"; List<ContentAnalyzerType> contentAnalizersList = Lists.newArrayList( ContentAnalyzerType.SimpleContentAnalizerWithSimpleTokenizer, ContentAnalyzerType.BagOfWordsContentAnalizerWithOpenNLPTokenizer); IndexBuilderTest.setupIndex(indexRoot, contentAnalizersList); String[] args = { "--articleRepositoryFolders", Joiner.on(',').join(ArticleRepositoryTestUtil.FOLDERS), "--contentAnalyzers", Joiner.on(',').join(contentAnalizersList), "--indexPaths", indexRoot }; PlagiarismCheckerService.setupContext(args); Assert.assertEquals( new ArticleRepositoryImpl( Lists.newArrayList( Lists.newArrayList(ArticleRepositoryTestUtil.FOLDERS) .stream() .map( folder -> { return Paths.get(folder); }) .iterator())), PlagiarismCheckerService.Context.ARTICLE_REPOSITORY); Assert.assertEquals(1, PlagiarismCheckerService.Context.CHECKERS.size()); List<FingerprintRepositoryInfo> fingerprintRepositoryInfoList = Lists.newArrayList(); contentAnalizersList.forEach( item -> { fingerprintRepositoryInfoList.add( new FingerprintRepositoryInfo( item, Paths.get(indexRoot).resolve(item.name()).toFile())); }); Assert.assertEquals( new PlagiarismChecker(fingerprintRepositoryInfoList), PlagiarismCheckerService.Context.CHECKERS.get(0)); IndexBuilderTest.deleteIndex(indexRoot, contentAnalizersList); }