Ignore:
Timestamp:
11/18/14 17:52:24 (10 years ago)
Author:
olhsha@mpi.nl
Message:

refactoring. Adding ALL as an access mode.

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

    r5774 r5836  
    344344                will(returnValue(mockAnnotationIDs1));
    345345
    346                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     346                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    347347                will(returnValue(mockAnnotationIDsRead));
    348348
    349                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     349                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    350350                will(returnValue(mockAnnotationIDsPublicRead));               
    351351
     
    418418                will(returnValue(mockAnnotationIDs1));
    419419
    420                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     420                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    421421                will(returnValue(mockAnnotationIDsRead));
    422422
    423                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     423                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    424424                will(returnValue(mockAnnotationIDsPublicRead));               
    425425
     
    491491                will(returnValue(mockAnnotationIDs1));
    492492
    493                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     493                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    494494                will(returnValue(mockAnnotationIDsRead));
    495495
    496                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     496                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    497497                will(returnValue(mockAnnotationIDsPublicRead));               
    498498
     
    565565                will(returnValue(mockAnnotationIDs1));
    566566
    567                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     567                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    568568                will(returnValue(mockAnnotationIDsRead));
    569569
    570                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     570                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    571571                will(returnValue(mockAnnotationIDsPublicRead));               
    572572
     
    631631                will(returnValue(mockAnnotationIDs1));
    632632
    633                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.WRITE);
     633                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.WRITE);
    634634                will(returnValue(mockAnnotationIDsWrite));
    635635
    636                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.WRITE);
     636                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.WRITE);
    637637                will(returnValue(mockAnnotationIDsPublicWrite));               
    638638
     
    695695                will(returnValue(mockAnnotationIDs1));
    696696
    697                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.WRITE);
     697                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.WRITE);
    698698                will(returnValue(mockAnnotationIDsWrite));
    699699
    700                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.WRITE);
     700                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.WRITE);
    701701                will(returnValue(mockAnnotationIDsPublicWrite));               
    702702
     
    761761                will(returnValue(mockAnnotationIDs1));
    762762
    763                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.WRITE);
     763                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.WRITE);
    764764                will(returnValue(mockAnnotationIDsWrite));
    765765
    766                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.WRITE);
     766                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.WRITE);
    767767                will(returnValue(mockAnnotationIDsPublicWrite));               
    768768
     
    826826                will(returnValue(mockAnnotationIDs1));
    827827
    828                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.WRITE);
     828                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.WRITE);
    829829                will(returnValue(mockAnnotationIDsWrite));
    830830
    831                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.WRITE);
     831                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.WRITE);
    832832                will(returnValue(mockAnnotationIDsPublicWrite));               
    833833
     
    10211021                will(returnValue(mockAnnotationIDs1));
    10221022
    1023                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     1023                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    10241024                will(returnValue(mockAnnotationIDsRead));
    10251025
    1026                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     1026                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    10271027                will(returnValue(mockAnnotationIDsPublicRead));
    10281028             
     
    12581258                will(returnValue(1)); // the DB update will be called at perform anyway, even if the body is not changed (can be optimized)
    12591259
    1260                 oneOf(annotationDao).updatePublicAttribute(5, Access.WRITE);
     1260                oneOf(annotationDao).updatePublicAccess(5, Access.WRITE);
    12611261                will(returnValue(1));
    12621262            }
     
    14141414        mockeryDao.checking(new Expectations() {
    14151415            {
    1416                 oneOf(annotationDao).deleteAnnotationPermissions(2);
     1416                oneOf(annotationDao).deletePermissions(2);
    14171417                will(returnValue(2));
    14181418
     
    17671767                will(returnValue("/api/principals/00000000-0000-0000-0000-000000000113"));
    17681768
    1769 
     1769               oneOf(principalDao).getPrincipalIDsWithAccessForNotebook(2, Access.ALL);
     1770                will(returnValue(new ArrayList<Number>()));
    17701771
    17711772            }
     
    19521953                will(returnValue(1)); // the DB update will be called at perform anyway, even if the body is not changed (can be optimized)
    19531954
    1954                 oneOf(annotationDao).updatePublicAttribute(5, Access.WRITE);
     1955                oneOf(annotationDao).updatePublicAccess(5, Access.WRITE);
    19551956                will(returnValue(1));
    19561957
     
    21102111                will(returnValue(1));
    21112112
    2112                 oneOf(annotationDao).deleteAnnotationPermissions(1);
     2113                oneOf(annotationDao).deletePermissions(1);
    21132114                will(returnValue(3));
    21142115
     
    21442145                will(returnValue(2));
    21452146
    2146                 oneOf(annotationDao).addAnnotationPrincipalAccess(1, 2, Access.WRITE);
     2147                oneOf(annotationDao).addPermission(1, 2, Access.WRITE);
    21472148                will(returnValue(1));
    21482149
     
    21502151                will(returnValue(3));
    21512152
    2152                 oneOf(annotationDao).addAnnotationPrincipalAccess(1, 3, Access.READ);
     2153                oneOf(annotationDao).addPermission(1, 3, Access.READ);
    21532154                will(returnValue(1));
    21542155
     
    21612162                ///
    21622163
    2163                 oneOf(annotationDao).updatePublicAttribute(1, permissions.getPublic());
     2164                oneOf(annotationDao).updatePublicAccess(1, permissions.getPublic());
    21642165                will(returnValue(1));
    21652166
     
    22002201//    }
    22012202    @Test
    2202     public void testUpdateAnnotationPrinciaplAccess() {
     2203    public void testUpdatePermission() {
    22032204        System.out.println("test updateAnnotationPrincipalAccess");
    22042205        mockeryDao.checking(new Expectations() {
    22052206            {
    2206                 oneOf(annotationDao).getAccess(1, 2);
    2207                 will(returnValue(Access.WRITE));
    2208 
    2209                 oneOf(annotationDao).updateAnnotationPrincipalAccess(1, 2, Access.READ);
    2210                 will(returnValue(1));
    2211 
    2212                 oneOf(annotationDao).getAccess(1, 4);
    2213                 will(returnValue(null));
    2214                
    2215                 oneOf(annotationDao).addAnnotationPrincipalAccess(1, 4, Access.WRITE);
    2216                 will(returnValue(1));
    2217 
    2218             }
    2219         });
    2220 
    2221         assertEquals(1, dbDispatcher.updateAnnotationPrincipalAccess(1, 2, Access.READ));
    2222         assertEquals(1, dbDispatcher.updateAnnotationPrincipalAccess(1, 4, Access.WRITE));
     2207                oneOf(annotationDao).hasExplicitAccess(1, 2);
     2208                will(returnValue(true));
     2209
     2210                oneOf(annotationDao).updatePermission(1, 2, Access.READ);
     2211                will(returnValue(1));
     2212
     2213                oneOf(annotationDao).hasExplicitAccess(1, 4);
     2214                will(returnValue(false));
     2215               
     2216                oneOf(annotationDao).addPermission(1, 4, Access.WRITE);
     2217                will(returnValue(1));
     2218
     2219            }
     2220        });
     2221
     2222        assertEquals(1, dbDispatcher.updatePermission(1, 2, Access.READ));
     2223        assertEquals(1, dbDispatcher.updatePermission(1, 4, Access.WRITE));
    22232224    }
    22242225
     
    22492250            {
    22502251                /////
    2251                 oneOf(annotationDao).updatePublicAttribute(1, permissions.getPublic());
     2252                oneOf(annotationDao).updatePublicAccess(1, permissions.getPublic());
    22522253                will(returnValue(1));
    22532254
     
    22552256                will(returnValue(2));
    22562257
    2257                 oneOf(annotationDao).getAccess(1, 2);
    2258                 will(returnValue(Access.WRITE));
     2258                oneOf(annotationDao).hasExplicitAccess(1, 2);
     2259                will(returnValue(true));
    22592260
    22602261                oneOf(principalDao).getInternalIDFromHref(permissions.getPermission().get(1).getPrincipalHref());
    22612262                will(returnValue(3));
    22622263
    2263                 oneOf(annotationDao).getAccess(1, 3);
    2264                 will(returnValue(Access.WRITE));
     2264                oneOf(annotationDao).hasExplicitAccess(1, 3);
     2265                will(returnValue(true));
    22652266               
    22662267                oneOf(principalDao).getInternalIDFromHref(permissions.getPermission().get(2).getPrincipalHref());
    22672268                will(returnValue(4));
    22682269
    2269                 oneOf(annotationDao).getAccess(1, 4);
    2270                 will(returnValue(null));
    2271 
    2272                 oneOf(annotationDao).updateAnnotationPrincipalAccess(1, 3, Access.READ);
    2273                 will(returnValue(1));
    2274                
    2275                 oneOf(annotationDao).addAnnotationPrincipalAccess(1, 4, Access.READ);
    2276                 will(returnValue(1));
    2277 
    2278             }
    2279         });
    2280 
    2281         assertEquals(2, dbDispatcher.updatePermissions(1, permissions));
     2270                oneOf(annotationDao).hasExplicitAccess(1, 4);
     2271                will(returnValue(false));
     2272               
     2273                oneOf(annotationDao).updatePermission(1, 2, Access.WRITE);
     2274                will(returnValue(1));
     2275
     2276                oneOf(annotationDao).updatePermission(1, 3, Access.READ);
     2277                will(returnValue(1));
     2278               
     2279                oneOf(annotationDao).addPermission(1, 4, Access.READ);
     2280                will(returnValue(1));
     2281
     2282            }
     2283        });
     2284
     2285        assertEquals(3, dbDispatcher.updatePermissions(1, permissions));
    22822286
    22832287    }
     
    22932297            {
    22942298                /////
    2295                 oneOf(annotationDao).updatePublicAttribute(1, Access.NONE);
     2299                oneOf(annotationDao).updatePublicAccess(1, Access.NONE);
    22962300                will(returnValue(1));
    22972301
Note: See TracChangeset for help on using the changeset viewer.