}
public void testRemoveAll() {
AnnotationFS[] fsArray = new AnnotationFS[100];
AnnotationFS[] subFsArray = new AnnotationFS[100];
FSIndexRepository ir = this.cas.getIndexRepository();
addAnnotations(fsArray, ts.getType("Sentence"));
addAnnotations(subFsArray, ts.getType("SubTypeOfSentence"));
FSIndex<FeatureStructure> setIndex = ir.getIndex(CASTestSetup.ANNOT_SET_INDEX, this.sentenceType);
FSIndex<FeatureStructure> bagIndex = ir.getIndex(CASTestSetup.ANNOT_BAG_INDEX, this.sentenceType);
FSIndex<AnnotationFS> sortedIndex = this.cas.getAnnotationIndex(this.sentenceType);
FSIndex<FeatureStructure> subsetIndex = ir.getIndex(CASTestSetup.ANNOT_SET_INDEX, this.subsentenceType);
FSIndex<FeatureStructure> subbagIndex = ir.getIndex(CASTestSetup.ANNOT_BAG_INDEX, this.subsentenceType);
FSIndex<AnnotationFS> subsortedIndex = this.cas.getAnnotationIndex(this.subsentenceType);
FSIterator<FeatureStructure> setIt = setIndex.iterator();
FSIterator<FeatureStructure> bagIt = bagIndex.iterator();
FSIterator<AnnotationFS> sortedIt = sortedIndex.iterator();
FSIterator<FeatureStructure> subsetIt = subsetIndex.iterator();
FSIterator<FeatureStructure> subbagIt = subbagIndex.iterator();
FSIterator<AnnotationFS> subsortedIt = subsortedIndex.iterator();
verifyMoveToFirst(setIt, true);
verifyMoveToFirst(bagIt, true);
verifyMoveToFirst(sortedIt, true);
verifyMoveToFirst(subsetIt, true);
verifyMoveToFirst(subbagIt, true);
verifyMoveToFirst(subsortedIt, true);
ir.removeAllIncludingSubtypes(sentenceType);
verifyConcurrantModificationDetected(setIt);
verifyConcurrantModificationDetected(bagIt);
verifyConcurrantModificationDetected(sortedIt);
verifyConcurrantModificationDetected(subsetIt);
verifyConcurrantModificationDetected(subbagIt);
verifyConcurrantModificationDetected(subsortedIt);
verifyMoveToFirst(setIt, false);
verifyMoveToFirst(bagIt, false);
verifyMoveToFirst(sortedIt, false);
verifyMoveToFirst(subsetIt, false);
verifyMoveToFirst(subbagIt, false);
verifyMoveToFirst(subsortedIt, false);
for (AnnotationFS fs : fsArray) {
ir.addFS(fs);
}
for (AnnotationFS fs : subFsArray) {
ir.addFS(fs);
}
verifyMoveToFirst(setIt, true);
verifyMoveToFirst(bagIt, true);
verifyMoveToFirst(sortedIt, true);
verifyMoveToFirst(subsetIt, true);
verifyMoveToFirst(subbagIt, true);
verifyMoveToFirst(subsortedIt, true);
ir.removeAllExcludingSubtypes(this.sentenceType);
verifyHaveSubset(setIt, 91, subsentenceType);
verifyHaveSubset(bagIt, 100, subsentenceType);
verifyHaveSubset(sortedIt, 100, subsentenceType);
verifyHaveSubset(subsetIt, 91, subsentenceType);
verifyHaveSubset(subbagIt, 100, subsentenceType);
verifyHaveSubset(subsortedIt, 100, subsentenceType);
for (AnnotationFS fs : fsArray) {
ir.addFS(fs);
}
ir.removeAllExcludingSubtypes(subsentenceType);
verifyHaveSubset(setIt, 91, sentenceType);
verifyHaveSubset(bagIt, 100, sentenceType);
verifyHaveSubset(sortedIt, 100, sentenceType);
verifyMoveToFirst(subsetIt, false);