2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.persistence
.dao
.hibernate
.common
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assert
.assertFalse
;
14 import static org
.junit
.Assert
.assertNotNull
;
16 import java
.util
.List
;
17 import java
.util
.UUID
;
19 import org
.junit
.Before
;
20 import org
.junit
.Test
;
21 import org
.unitils
.dbunit
.annotation
.DataSet
;
22 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
24 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
25 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
26 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IAnnotationDao
;
27 import eu
.etaxonomy
.cdm
.test
.integration
.CdmIntegrationTest
;
30 public class AnnotationDaoTest
extends CdmIntegrationTest
{
33 IAnnotationDao annotationDao
;
39 uuid
= UUID
.fromString("97097410-a112-4dde-a2c6-0096754076b5");
43 public void testCountAnnotations() {
44 Annotation annotatedObj
= annotationDao
.findByUuid(uuid
);
45 assert annotatedObj
!= null : "annotatedObj must exist";
47 int numberOfAnnotations
= annotationDao
.countAnnotations(annotatedObj
, null);
48 assertEquals("countAnnotations should return 4",4,numberOfAnnotations
);
52 public void testGetAnnotations() {
53 Annotation annotatedObj
= annotationDao
.findByUuid(uuid
);
54 assert annotatedObj
!= null : "annotatedObj must exist";
56 List
<Annotation
> annotations
= annotationDao
.getAnnotations(annotatedObj
, null,null,null);
57 assertNotNull("getAnnotations should return a List",annotations
);
58 assertFalse("the list should contain Annotation instances",annotations
.isEmpty());
59 assertEquals("getAnnotations should return 4",4,annotations
.size());
63 public void testCountAnnotationsWithStatus() {
64 Annotation annotatedObj
= annotationDao
.findByUuid(uuid
);
65 MarkerType markerType
= MarkerType
.TO_BE_CHECKED();
66 assert annotatedObj
!= null : "annotatedObj must exist";
67 assert markerType
!= null : "markerType must exist";
69 int numberOfAnnotations
= annotationDao
.countAnnotations(annotatedObj
, markerType
);
70 assertEquals("countAnnotations should return 2",2,numberOfAnnotations
);
74 public void testGetAnnotationsWithStatus() {
75 Annotation annotatedObj
= annotationDao
.findByUuid(uuid
);
76 MarkerType markerType
= MarkerType
.TO_BE_CHECKED();
77 assert annotatedObj
!= null : "annotatedObj must exist";
78 assert markerType
!= null : "markerType must exist";
80 List
<Annotation
> annotations
= annotationDao
.getAnnotations(annotatedObj
, markerType
,null,null);
81 assertNotNull("getAnnotations should return a List",annotations
);
82 assertFalse("the list should contain Annotation instances",annotations
.isEmpty());
83 assertEquals("getAnnotations should return 2",2,annotations
.size());