use of annis.test.CsvResultSetProvider in project ANNIS by korpling.
the class SaltAnnotateExtractorTest method setUp.
@Before
public void setUp() throws SQLException {
initMocks(this);
solutionKey.setKeyColumnName("key");
resultSetProviderSingleText = new CsvResultSetProvider(getClass().getResourceAsStream("SampleAnnotateResult.csv"));
resultSetProviderMultiText = new CsvResultSetProvider(getClass().getResourceAsStream("SampleAnnotateResult_MultiText.csv"));
instance = new SaltAnnotateExtractor() {
protected SolutionKey<?> createSolutionKey() {
return solutionKey;
}
};
CorpusPathExtractor corpusPathExtractor = new ArrayCorpusPathExtractor();
instance.setCorpusPathExtractor(corpusPathExtractor);
TestAnnotateSqlGenerator.setupOuterQueryFactsTableColumnAliases(instance);
}
use of annis.test.CsvResultSetProvider in project ANNIS by korpling.
the class LegacyGraphConverterTest method testConvertToAOM.
/**
* Test of convertToAOM method, of class LegacyGraphConverter.
*/
@Test
public void testConvertToAOM() throws SQLException {
SaltAnnotateExtractor saltExtractor = new SaltAnnotateExtractor() {
@Override
protected SolutionKey<?> createSolutionKey() {
PostgreSqlArraySolutionKey<Long> key = new PostgreSqlArraySolutionKey<>();
key.setKeyColumnName("key");
key.setIdColumnName("id");
return key;
}
};
CorpusPathExtractor corpusPathExtractor = new ArrayCorpusPathExtractor();
saltExtractor.setCorpusPathExtractor(corpusPathExtractor);
TestAnnotateSqlGenerator.setupOuterQueryFactsTableColumnAliases(saltExtractor);
List<Match> matches = new ArrayList<>();
matches.add(Match.parseFromString("salt:/pcc2/4282/#tok_155 tiger::pos::salt:/pcc2/4282#tok_156"));
MatchGroup matchGroup = new MatchGroup(matches);
SaltProject p = saltExtractor.extractData(new CsvResultSetProvider(annis.sqlgen.SaltAnnotateExtractorTest.class.getResourceAsStream("SampleAnnotateResult.csv")).getResultSet());
SaltAnnotateExtractor.addMatchInformation(p, matchGroup);
List<AnnotationGraph> expected = aomSqlGen.extractData(new CsvResultSetProvider(annis.sqlgen.SaltAnnotateExtractorTest.class.getResourceAsStream("SampleAnnotateResult.csv")).getResultSet());
List<AnnotationGraph> result = LegacyGraphConverter.convertToAOM(p);
assertEquals(expected.size(), result.size());
Iterator<AnnotationGraph> itGraphExpected = expected.iterator();
Iterator<AnnotationGraph> itGraphResult = result.iterator();
while (itGraphExpected.hasNext() && itGraphResult.hasNext()) {
AnnotationGraph graphExpected = itGraphExpected.next();
AnnotationGraph graphResult = itGraphResult.next();
List<AnnisNode> nodeListExpected = graphExpected.getNodes();
List<AnnisNode> nodeListResult = graphResult.getNodes();
assertEquals(nodeListExpected.size(), nodeListResult.size());
Collections.sort(nodeListExpected, new Comparator<AnnisNode>() {
@Override
public int compare(AnnisNode arg0, AnnisNode arg1) {
return Long.valueOf(arg0.getId()).compareTo(Long.valueOf(arg1.getId()));
}
});
Collections.sort(nodeListResult, new Comparator<AnnisNode>() {
@Override
public int compare(AnnisNode arg0, AnnisNode arg1) {
return Long.valueOf(arg0.getId()).compareTo(Long.valueOf(arg1.getId()));
}
});
Iterator<AnnisNode> itNodeExpected = nodeListExpected.iterator();
Iterator<AnnisNode> itNodeResult = nodeListResult.iterator();
while (itNodeExpected.hasNext() && itNodeResult.hasNext()) {
checkAnnisNodeEqual(itNodeExpected.next(), itNodeResult.next());
}
}
}
Aggregations