예제 #1
0
  @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);
  }