1 /*
2 * #%L
3 * ToPIA :: Persistence
4 *
5 * $Id: EntityStateTest.java 2416 2012-03-02 10:08:59Z tchemit $
6 * $HeadURL: http://svn.nuiton.org/svn/topia/tags/topia-2.8-rc-1/topia-persistence/src/test/java/org/nuiton/topia/framework/EntityStateTest.java $
7 * %%
8 * Copyright (C) 2004 - 2010 CodeLutin
9 * %%
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation, either version 3 of the
13 * License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Lesser Public License for more details.
19 *
20 * You should have received a copy of the GNU General Lesser Public
21 * License along with this program. If not, see
22 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
23 * #L%
24 */
25
26 package org.nuiton.topia.framework;
27
28 import org.junit.Assert;
29 import org.junit.Test;
30
31 /**
32 * EntityStateTest.java
33 * <p/>
34 * Created: 22 nov. 06 12:15:11
35 *
36 * @author poussin <poussin@codelutin.com>
37 * @version $Revision: 2416 $
38 * <p/>
39 * Last update: $Date: 2012-03-02 11:08:59 +0100 (Fri, 02 Mar 2012) $
40 * by : $Author: tchemit $
41 */
42 public class EntityStateTest {
43
44 /**
45 * Test les changements d'etat de {@link EntityState}.
46 *
47 * @throws Exception
48 */
49 @Test
50 public void testState() throws Exception {
51 EntityState state = new EntityState();
52
53 state.addLoad();
54 Assert.assertTrue(state.isLoad());
55 Assert.assertFalse(state.isRead());
56 Assert.assertFalse(state.isCreate());
57 Assert.assertFalse(state.isUpdate());
58 Assert.assertFalse(state.isDelete());
59
60 state.addRead();
61 Assert.assertTrue(state.isLoad());
62 Assert.assertTrue(state.isRead());
63 Assert.assertFalse(state.isCreate());
64 Assert.assertFalse(state.isUpdate());
65 Assert.assertFalse(state.isDelete());
66
67 //state.addRead();
68 state.addCreate();
69 Assert.assertTrue(state.isLoad());
70 Assert.assertTrue(state.isRead());
71 Assert.assertTrue(state.isCreate());
72 Assert.assertFalse(state.isUpdate());
73 Assert.assertFalse(state.isDelete());
74
75 state.addUpdate();
76 Assert.assertTrue(state.isLoad());
77 Assert.assertTrue(state.isRead());
78 Assert.assertTrue(state.isCreate());
79 Assert.assertTrue(state.isUpdate());
80 Assert.assertFalse(state.isDelete());
81
82 state.addDelete();
83 Assert.assertTrue(state.isLoad());
84 Assert.assertTrue(state.isRead());
85 Assert.assertTrue(state.isCreate());
86 Assert.assertTrue(state.isUpdate());
87 Assert.assertTrue(state.isDelete());
88
89 state = new EntityState();
90 state.addDelete();
91 Assert.assertFalse(state.isRead());
92 Assert.assertFalse(state.isCreate());
93 Assert.assertFalse(state.isUpdate());
94 Assert.assertTrue(state.isDelete());
95 }
96 }