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.plugins.crm.business.demand.category;
35
36 import fr.paris.lutece.test.LuteceTestCase;
37
38
39
40
41
42
43 public class CategoryTest extends LuteceTestCase
44 {
45 private static final String NAME1 = "Name1";
46 private static final String NAME2 = "Name2";
47 private static final String DESCRIPTION1 = "Description1";
48 private static final String DESCRIPTION2 = "Description2";
49
50
51
52
53 public void testBusiness( )
54 {
55
56 Category category = new Category( );
57 category.setName( NAME1 );
58 category.setDescription( DESCRIPTION1 );
59
60
61 CategoryHome.create( category );
62
63 Category categoryStored = CategoryHome.findByPrimaryKey( category.getIdCategory( ) );
64 assertEquals( category.getIdCategory( ), categoryStored.getIdCategory( ) );
65 assertEquals( category.getName( ), categoryStored.getName( ) );
66 assertEquals( category.getDescription( ), categoryStored.getDescription( ) );
67
68
69 category.setName( NAME2 );
70 category.setDescription( DESCRIPTION2 );
71 CategoryHome.update( category );
72 categoryStored = CategoryHome.findByPrimaryKey( category.getIdCategory( ) );
73 assertEquals( category.getIdCategory( ), categoryStored.getIdCategory( ) );
74 assertEquals( category.getName( ), categoryStored.getName( ) );
75 assertEquals( category.getDescription( ), categoryStored.getDescription( ) );
76
77
78 CategoryHome.findFirstCategory( );
79 CategoryHome.getCategories( );
80 CategoryHome.getCategoriesList( );
81
82
83 CategoryHome.remove( category.getIdCategory( ) );
84 categoryStored = CategoryHome.findByPrimaryKey( category.getIdCategory( ) );
85 assertNull( categoryStored );
86 }
87 }