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.identityimport.business;
35
36 import fr.paris.lutece.test.LuteceTestCase;
37
38 import java.sql.Timestamp;
39 import java.time.Instant;
40 import java.util.Optional;
41
42
43
44
45 public class BatchBusinessTest extends LuteceTestCase
46 {
47 private static final Timestamp DATE1 = Timestamp.from( Instant.now( ) );
48 private static final Timestamp DATE2 = Timestamp.from( Instant.now( ) );
49 private static final String USER1 = "User1";
50 private static final String USER2 = "User2";
51 private static final String APPCODE1 = "AppCode1";
52 private static final String APPCODE2 = "AppCode2";
53 private static final String COMMENT1 = "Comment1";
54 private static final String COMMENT2 = "Comment2";
55
56
57
58
59 public void testBusiness( )
60 {
61
62 Batch batch = new Batch( );
63 batch.setCreationDate( DATE1 );
64 batch.setUser( USER1 );
65 batch.setAppCode( APPCODE1 );
66 batch.setClientCode( APPCODE1 );
67 batch.setComment( COMMENT1 );
68
69
70 BatchHome.create( batch );
71 Optional<Batch> optBatchStored = BatchHome.findByPrimaryKey( batch.getId( ) );
72 Batch batchStored = optBatchStored.orElse( new Batch( ) );
73 assertEquals( batchStored.getCreationDate( ).toString( ), batch.getCreationDate( ).toString( ) );
74 assertEquals( batchStored.getUser( ), batch.getUser( ) );
75 assertEquals( batchStored.getAppCode( ), batch.getAppCode( ) );
76 assertEquals( batchStored.getComment( ), batch.getComment( ) );
77
78
79 batch.setCreationDate( DATE2 );
80 batch.setUser( USER2 );
81 batch.setAppCode( APPCODE2 );
82 batch.setClientCode( APPCODE2 );
83 batch.setComment( COMMENT2 );
84 BatchHome.update( batch );
85 optBatchStored = BatchHome.findByPrimaryKey( batch.getId( ) );
86 batchStored = optBatchStored.orElse( new Batch( ) );
87
88 assertEquals( batchStored.getCreationDate( ).toString( ), batch.getCreationDate( ).toString( ) );
89 assertEquals( batchStored.getUser( ), batch.getUser( ) );
90 assertEquals( batchStored.getAppCode( ), batch.getAppCode( ) );
91 assertEquals( batchStored.getComment( ), batch.getComment( ) );
92
93
94 BatchHome.getBatchsList( );
95
96
97 BatchHome.remove( batch.getId( ) );
98 optBatchStored = BatchHome.findByPrimaryKey( batch.getId( ) );
99 batchStored = optBatchStored.orElse( null );
100 assertNull( batchStored );
101
102 }
103
104 }