source: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcPermissionsDaoTest.java @ 3407

Last change on this file since 3407 was 3407, checked in by olhsha, 11 years ago

refactored DAO-s: resource dao do not call each-other methods any more. Only the new Dispatcher method can do it. Not tested.

File size: 3.5 KB
Line 
1/*
2 * Copyright (C) 2013 DASISH
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 */
18package eu.dasish.annotation.backend.dao.impl;
19
20import eu.dasish.annotation.backend.TestBackendConstants;
21import eu.dasish.annotation.backend.TestInstances;
22import eu.dasish.annotation.backend.dao.UserDao;
23import eu.dasish.annotation.backend.identifiers.UserIdentifier;
24import eu.dasish.annotation.schema.UserWithPermission;
25import java.util.List;
26import org.jmock.Expectations;
27import org.jmock.Mockery;
28import org.junit.Test;
29import org.springframework.beans.factory.annotation.Autowired;
30import static org.junit.Assert.*;
31import org.junit.Ignore;
32import org.junit.runner.RunWith;
33import org.springframework.test.context.ContextConfiguration;
34import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
35
36/**
37 *
38 * @author olhsha
39 */
40
41@RunWith(SpringJUnit4ClassRunner.class)
42@ContextConfiguration({"/spring-config/dataSource.xml", "/spring-config/permissionsDao.xml"})
43public class JdbcPermissionsDaoTest extends JdbcResourceDaoTest{
44   
45    @Autowired
46    JdbcPermissionsDao jdbcPermissionsDao; 
47    TestInstances testInstances = new TestInstances();
48   
49    /**
50     * Test of retrievePermissions method, of class PermissionsDao.
51     * public List<UserWithPermission> retrievePermissions(Number annotationId)
52     */
53    @Test
54    @Ignore
55    public void testRetrievePermissions() {
56        Number testAnnotationId = 2;
57        final String external_1 = TestBackendConstants._TEST_USER_3_EXT_ID;
58        final String external_2 = TestBackendConstants._TEST_USER_4_EXT_ID;
59        final String external_3 = TestBackendConstants._TEST_USER_5_EXT_ID;
60        final int principal_1 = 3;
61        final int principal_2 = 4;
62        final int principal_3 = 5;
63        String permission_1 = "owner";
64        String permission_2 = "writer";
65        String permission_3 = "reader";
66       
67//        mockery.checking(new Expectations() {
68//            {
69//                oneOf(userDao).getExternalID(principal_1);
70//                will(returnValue(new UserIdentifier(external_1)));
71//               
72//                oneOf(userDao).getExternalID(principal_2);
73//                will(returnValue(new UserIdentifier(external_2)));
74//               
75//                oneOf(userDao).getExternalID(principal_3);
76//                will(returnValue(new UserIdentifier(external_3)));
77//               
78//            }
79//        });
80       
81               
82        List<UserWithPermission> test = jdbcPermissionsDao.retrievePermissions(testAnnotationId);
83        assertEquals(external_1, test.get(0).getRef());
84        assertEquals(external_2, test.get(1).getRef());
85        assertEquals(external_3, test.get(2).getRef());
86        assertEquals(permission_1, test.get(0).getPermission().value());
87        assertEquals(permission_2, test.get(1).getPermission().value());
88        assertEquals(permission_3, test.get(2).getPermission().value());
89       
90    }
91
92   
93}
Note: See TracBrowser for help on using the repository browser.