Changeset 5385 for DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestInstances.java
- Timestamp:
- 06/24/14 17:43:30 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestInstances.java
r4903 r5385 26 26 import eu.dasish.annotation.schema.Permission; 27 27 import eu.dasish.annotation.schema.PermissionList; 28 import java.util.UUID; 28 29 import javax.xml.datatype.DatatypeConfigurationException; 29 30 import javax.xml.datatype.DatatypeFactory; … … 38 39 final private Annotation _annotationToAdd; 39 40 40 public TestInstances(String baseURI) {41 _annotationOne = makeAnnotationOne( baseURI);42 _annotationToAdd = makeAnnotationToAdd( baseURI);41 public TestInstances(String relativePath) { 42 _annotationOne = makeAnnotationOne(relativePath); 43 _annotationToAdd = makeAnnotationToAdd(relativePath); 43 44 } 44 45 45 private Annotation makeAnnotationOne(String baseURI) { 46 Annotation result = makeAnnotation(baseURI, "<html><body>some html 1</body></html>", "text/html", "Sagrada Famiglia", "00000000-0000-0000-0000-000000000111"); 47 result.setURI(baseURI+"annotations/00000000-0000-0000-0000-000000000021"); 48 46 private Annotation makeAnnotationOne(String relativePath) { 47 Annotation result = makeAnnotation(relativePath, "<html><body>some html 1</body></html>", "text/html", "Sagrada Famiglia", "00000000-0000-0000-0000-000000000111", "00000000-0000-0000-0000-000000000021"); 48 49 49 try { 50 50 result.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar("2013-08-12T09:25:00.383000Z")); … … 59 59 60 60 Permission up1 = new Permission(); 61 up1.setPrincipal Ref(baseURI + "principals/00000000-0000-0000-0000-000000000112");61 up1.setPrincipalHref(relativePath + "/principals/00000000-0000-0000-0000-000000000112"); 62 62 up1.setLevel(Access.WRITE); 63 63 64 64 Permission up2 = new Permission(); 65 up2.setPrincipal Ref(baseURI + "principals/00000000-0000-0000-0000-000000000113");65 up2.setPrincipalHref(relativePath + "/principals/00000000-0000-0000-0000-000000000113"); 66 66 up2.setLevel(Access.READ); 67 67 … … 72 72 TargetInfo target1 = new TargetInfo(); 73 73 target1.setLink("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"); 74 target1.set Ref(baseURI + "targets/00000000-0000-0000-0000-000000000031");74 target1.setHref(relativePath + "/targets/00000000-0000-0000-0000-000000000031"); 75 75 target1.setVersion("version 1.0"); 76 76 77 77 TargetInfo target2 = new TargetInfo(); 78 78 target2.setLink("http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD"); 79 target2.set Ref(baseURI + "targets/00000000-0000-0000-0000-000000000032");79 target2.setHref(relativePath + "/targets/00000000-0000-0000-0000-000000000032"); 80 80 target2.setVersion("version 1.1"); 81 81 … … 86 86 } 87 87 88 private Annotation makeAnnotationToAdd(String baseURI) {89 Annotation result = makeAnnotation( baseURI, "<html><body>some html 3</body></html>", "text/plain", "Annotation to add to test DAO", "00000000-0000-0000-0000-000000000113");88 private Annotation makeAnnotationToAdd(String relativePath) { 89 Annotation result = makeAnnotation(relativePath, "<html><body>some html 3</body></html>", "text/plain", "Annotation to add to test DAO", "00000000-0000-0000-0000-000000000113", UUID.randomUUID().toString()); 90 90 91 91 TargetInfo TargetInfo = new TargetInfo(); 92 92 TargetInfo.setLink("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#de_Opdracht"); 93 TargetInfo.set Ref(baseURI+ "targets/00000000-0000-0000-0000-000000000031");93 TargetInfo.setHref(relativePath + "/targets/00000000-0000-0000-0000-000000000031"); 94 94 TargetInfo.setVersion("version 1.0"); 95 95 … … 97 97 targetInfos.getTargetInfo().add(TargetInfo); 98 98 result.setTargets(targetInfos); 99 99 100 100 PermissionList permissions = new PermissionList(); 101 101 permissions.setPublic(Access.WRITE); 102 102 result.setPermissions(permissions); 103 103 104 104 return result; 105 105 } 106 106 107 private Annotation makeAnnotation(String baseURI, String bodyTxt, String bodyMimeType, String headline, String ownerExternalId) {107 private Annotation makeAnnotation(String relativePath, String bodyTxt, String bodyMimeType, String headline, String ownerExternalId, String externalId) { 108 108 Annotation result = new Annotation(); 109 109 110 AnnotationBody body = new AnnotationBody(); 110 111 result.setBody(body); … … 113 114 textBody.setMimeType(bodyMimeType); 114 115 textBody.setBody(bodyTxt); 115 116 116 117 result.setHeadline(headline); 117 118 if (baseURI != null) { 119 result.setOwnerRef(baseURI + "principals/" + ownerExternalId); 120 } else { 121 result.setOwnerRef("principals/" + ownerExternalId); 122 } 123 118 result.setOwnerHref(relativePath + "/principals/" + ownerExternalId); 124 119 result.setLastModified(null); 125 result.setURI(null); 120 result.setId(externalId); 121 result.setHref(relativePath + "/annotations/"+externalId); 126 122 result.setTargets(null); 127 result.setURI(null);128 129 123 return result; 130 124 }
Note: See TracChangeset
for help on using the changeset viewer.