1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.service.prefs;
35
36 import fr.paris.lutece.test.LuteceTestCase;
37 import static junit.framework.Assert.assertEquals;
38 import static junit.framework.Assert.assertTrue;
39
40 import java.util.List;
41
42
43
44
45 public class AdminUserPreferencesServiceTest extends LuteceTestCase
46 {
47 private final static String USER_ID_1 = "1";
48 private final static String KEY1 = "KEY1";
49 private final static String KEY2 = "KEY2";
50 private final static String KEY3 = "KEY3";
51 private final static String DEFAULT = "default";
52 private final static String VALUE1 = "Value 1";
53 private static final int INT_DEFAULT = 10;
54 private static final int INT_VALUE = 20;
55 private static final boolean BOOL_DEFAULT = true;
56 private static final boolean BOOL_VALUE = false;
57 private static final String NICKNAME = "nickname";
58
59 public void testBusinessLevel( )
60 {
61 IUserPreferencesService service = UserPreferencesService.instance( );
62
63 service.clear( USER_ID_1 );
64
65 String strValue = service.get( USER_ID_1, KEY1, DEFAULT );
66 assertEquals( strValue, DEFAULT );
67 service.put( USER_ID_1, KEY1, VALUE1 );
68 strValue = service.get( USER_ID_1, KEY1, DEFAULT );
69 assertEquals( strValue, VALUE1 );
70
71 int nValue = service.getInt( USER_ID_1, KEY2, INT_DEFAULT );
72 assertEquals( nValue, INT_DEFAULT );
73 service.putInt( USER_ID_1, KEY2, INT_VALUE );
74 nValue = service.getInt( USER_ID_1, KEY2, INT_DEFAULT );
75 assertEquals( nValue, INT_VALUE );
76
77 boolean bValue = service.getBoolean( USER_ID_1, KEY3, BOOL_DEFAULT );
78 assertEquals( bValue, BOOL_DEFAULT );
79 service.putBoolean( USER_ID_1, KEY3, BOOL_VALUE );
80 bValue = service.getBoolean( USER_ID_1, KEY3, BOOL_DEFAULT );
81 assertEquals( bValue, BOOL_VALUE );
82
83
84 List list = service.keys( USER_ID_1 );
85 assertTrue( list.size( ) > 0 );
86 }
87 }