Changeset 5838 for DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherTest.java
- Timestamp:
- 11/19/14 17:21:25 (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/dao/impl/DBDispatcherTest.java
r5836 r5838 197 197 textBody.setBody("<html><body>some html 1</body></html>"); 198 198 mockAnnotation.setBody(mockBody); 199 PermissionList permissions = new PermissionList(); 200 permissions.setPublic(Access.WRITE); 201 mockAnnotation.setPermissions(permissions); 199 202 mockAnnotation.setTargets(null); 200 203 … … 235 238 mockeryDao.checking(new Expectations() { 236 239 { 237 oneOf(annotationDao).getAnnotationWithoutTargetsAndPemission s(1);240 oneOf(annotationDao).getAnnotationWithoutTargetsAndPemissionList(1); 238 241 will(returnValue(mockAnnotation)); 239 242 … … 257 260 oneOf(annotationDao).getPermissions(1); 258 261 will(returnValue(listMap)); 259 260 oneOf(annotationDao).getPublicAttribute(1);261 will(returnValue(Access.WRITE));262 262 263 263 oneOf(principalDao).getHrefFromInternalID(2); … … 1253 1253 will(returnValue(1)); 1254 1254 1255 /// ////////1255 /// 1256 1256 1257 1257 oneOf(annotationDao).updateAnnotationBody(5, testAnnotation.getBody().getTextBody().getBody(), testAnnotation.getBody().getTextBody().getMimeType(), false); 1258 1258 will(returnValue(1)); // the DB update will be called at perform anyway, even if the body is not changed (can be optimized) 1259 1259 1260 oneOf(annotationDao).updatePublicAccess(5, Access.WRITE); 1260 ////// 1261 1262 1263 oneOf(principalDao).getInternalIDFromHref("/api/principals/00000000-0000-0000-0000-000000000111"); 1264 will(returnValue(1)); 1265 1266 oneOf(annotationDao).addPermission(5, 1, Access.ALL); 1261 1267 will(returnValue(1)); 1262 1268 } … … 1265 1271 Number result = dbDispatcher.addPrincipalsAnnotation(3, testAnnotation); 1266 1272 assertEquals(5, result); 1267 1268 // Annotation newAnnotation = dbDispatcher.getAnnotation(5);1269 // assertEquals("/api/principals/00000000-0000-0000-0000-000000000113", newAnnotation.getOwnerHref());1270 // assertEquals(testAnnotation.getHeadline(), newAnnotation.getHeadline());1271 // assertEquals(testAnnotation.getBody().getTextBody().getBody(), newAnnotation.getBody().getTextBody().getBody());1272 // assertEquals(testAnnotation.getBody().getTextBody().getMimeType(), newAnnotation.getBody().getTextBody().getMimeType());1273 // assertEquals(testAnnotation.getPermissions().getPermission().size(), newAnnotation.getPermissions().getPermission().size());1274 // assertEquals(Access.WRITE, newAnnotation.getPermissions().getPublic());1275 // assertEquals(testAnnotation.getTargets().getTargetInfo().size(), newAnnotation.getTargets().getTargetInfo().size());1276 1277 1273 } 1278 1274 … … 1955 1951 oneOf(annotationDao).updatePublicAccess(5, Access.WRITE); 1956 1952 will(returnValue(1)); 1953 1954 //// 1955 1956 oneOf(principalDao).getInternalIDFromHref("/api/principals/00000000-0000-0000-0000-000000000111"); 1957 will(returnValue(1)); 1957 1958 1958 1959 ///////////////////////// … … 1960 1961 oneOf(notebookDao).addAnnotationToNotebook(1, 5); 1961 1962 will(returnValue(true)); 1963 1964 oneOf(annotationDao).addPermission(5, 1, Access.ALL); 1965 will(returnValue(1)); 1962 1966 } 1963 1967 }); … … 2091 2095 final Annotation annotation = (new TestInstances("/api")).getAnnotationOne(); 2092 2096 final NotInDataBaseException e = new NotInDataBaseException("annotation", "external ID", "00000000-0000-0000-0000-000000000031"); 2093 final String mockTempID = "00000000-0000-0000-0000-000000000031";2094 2097 final UUID mockNewID = Helpers.generateUUID(); 2095 2098 final PermissionList permissions = annotation.getPermissions(); … … 2159 2162 oneOf(annotationDao).updateAnnotationBody(1, annotation.getBody().getTextBody().getBody(), "text/html", false); 2160 2163 will(returnValue(1)); 2161 2162 ///2163 2164 oneOf(annotationDao).updatePublicAccess(1, permissions.getPublic());2165 will(returnValue(1));2166 2167 2164 2168 2165 } … … 2216 2213 oneOf(annotationDao).addPermission(1, 4, Access.WRITE); 2217 2214 will(returnValue(1)); 2215 2216 oneOf(annotationDao).deletePermission(1, 2); 2217 will(returnValue(1)); 2218 2218 2219 2219 } … … 2222 2222 assertEquals(1, dbDispatcher.updatePermission(1, 2, Access.READ)); 2223 2223 assertEquals(1, dbDispatcher.updatePermission(1, 4, Access.WRITE)); 2224 assertEquals(1, dbDispatcher.updatePermission(1, 2, null)); 2224 2225 } 2225 2226 … … 2307 2308 2308 2309 } 2310 2311 @Test 2312 public void testCanDo(){ 2313 System.out.println("test canDo"); 2314 2315 mockeryDao.checking(new Expectations() { { 2316 ///// 2317 oneOf(annotationDao).getOwner(1); 2318 will(returnValue(1)); 2319 oneOf(principalDao).getTypeOfPrincipalAccount(1); 2320 will(returnValue("developer")); 2321 } 2322 }); 2323 assertTrue(dbDispatcher.canDo(Access.ALL, 1, 1, Resource.ANNOTATION)); 2324 2325 mockeryDao.checking(new Expectations() { { 2326 ///// 2327 oneOf(annotationDao).getOwner(2); 2328 will(returnValue(2)); 2329 oneOf(principalDao).getTypeOfPrincipalAccount(2); 2330 will(returnValue("developer")); 2331 2332 oneOf(annotationDao).getAccess(2, 1); 2333 will(returnValue(Access.READ)); 2334 oneOf(annotationDao).getPublicAttribute(2); 2335 will(returnValue(Access.READ)); 2336 } 2337 }); 2338 assertFalse(dbDispatcher.canDo(Access.WRITE, 1, 2, Resource.ANNOTATION)); 2339 2340 mockeryDao.checking(new Expectations() { { 2341 ///// 2342 oneOf(annotationDao).getOwner(3); 2343 will(returnValue(3)); 2344 oneOf(principalDao).getTypeOfPrincipalAccount(1); 2345 will(returnValue("developer")); 2346 2347 oneOf(annotationDao).getAccess(3, 1); 2348 will(returnValue(Access.READ)); 2349 oneOf(annotationDao).getPublicAttribute(3); 2350 will(returnValue(Access.ALL)); 2351 } 2352 }); 2353 assertTrue(dbDispatcher.canDo(Access.WRITE, 1, 3, Resource.ANNOTATION)); 2354 2355 mockeryDao.checking(new Expectations() { { 2356 ///// 2357 oneOf(annotationDao).getOwner(4); 2358 will(returnValue(3)); 2359 oneOf(principalDao).getTypeOfPrincipalAccount(11); 2360 will(returnValue("user")); 2361 2362 oneOf(annotationDao).getAccess(4, 11); 2363 will(returnValue(Access.NONE)); 2364 oneOf(annotationDao).getPublicAttribute(4); 2365 will(returnValue(Access.NONE)); 2366 } 2367 }); 2368 assertFalse(dbDispatcher.canDo(Access.READ, 11, 4, Resource.ANNOTATION)); 2369 } 2309 2370 }
Note: See TracChangeset
for help on using the changeset viewer.