This method tests if the generator for new Annotation IDs is greather than the maximum Annotation ID present in the GATE document. In oter words, it ensures that new Annotations will receive an UNIQUE ID. @param aDoc The GATE document being tested
(gate.Document aDoc)
| 341 | * @param aDoc The GATE document being tested |
| 342 | */ |
| 343 | protected void verifyAnnotationIDGenerator(gate.Document aDoc){ |
| 344 | // Creates a MAP containing all the annotations of the document. |
| 345 | // In doing so, it also tests if there are annotations with the same ID. |
| 346 | Map<Integer,Annotation> id2AnnotationMap = buildID2AnnotMap(aDoc); |
| 347 | |
| 348 | if (id2AnnotationMap == null || id2AnnotationMap.isEmpty()){ |
| 349 | //System.out.println("No annotations found on the document! Nothing to test."); |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | // Get the key set of the Map and sort them |
| 354 | Set<Integer> keysSet = id2AnnotationMap.keySet(); |
| 355 | TreeSet<Integer> sortedSet = new TreeSet<Integer>(keysSet); |
| 356 | // Get the highest Annotation ID |
| 357 | Integer maxAnnotId = sortedSet.last(); |
| 358 | // Compare its value to the one hold by the document's ID generator |
| 359 | Integer generatorId = ((DocumentImpl)aDoc).getNextAnnotationId(); |
| 360 | |
| 361 | // System.out.println("maxAnnotid = " + maxAnnotId + " generatorID = " + generatorId); |
| 362 | |
| 363 | assertTrue("Annotation ID generator["+generatorId+"] on document [" + aDoc.getSourceUrl() + |
| 364 | "] was equal or less than the MAX Annotation ID["+maxAnnotId+"] on the document."+ |
| 365 | " This may lead to Annotation ID conflicts.", generatorId.intValue() > maxAnnotId.intValue()); |
| 366 | |
| 367 | |
| 368 | }// End of verifyAnnotationIDGenerator() |
| 369 | |
| 370 | /** |
| 371 | * Verifies if the two maps hold annotations with the same ID. The only thing not checked |
no test coverage detected