@Test
public void thatRelationCrossSentenceBehaviorOnValidateGeneratesErrors() throws Exception
{
TokenBuilder<Token, Sentence> builder = new TokenBuilder<>(Token.class, Sentence.class);
builder.buildTokens(jcas, "This is a test .\nThis is sentence two .");
for (Token t : select(jcas, Token.class)) {
POS pos = new POS(jcas, t.getBegin(), t.getEnd());
t.setPos(pos);
pos.addToIndexes();
}
RelationAdapter sut = new RelationAdapter(featureSupportRegistry, null, depLayer,
FEAT_REL_TARGET, FEAT_REL_SOURCE,
asList(dependencyLayerGovernor, dependencyLayerDependent), behaviors);
List<POS> posAnnotations = new ArrayList<>(select(jcas, POS.class));
POS source = posAnnotations.get(0);
POS target = posAnnotations.get(posAnnotations.size() - 1);
depLayer.setCrossSentence(true);
sut.add(document, username, source, target, jcas, 0, jcas.getDocumentText().length());
depLayer.setCrossSentence(false);
assertThat(sut.validate(jcas))
.extracting(Pair::getLeft)
.usingElementComparatorIgnoringFields("source", "message")
.containsExactly(LogMessage.error(null, ""));
}