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.identitystore.modules.quality.business;
35
36 import fr.paris.lutece.plugins.identitystore.business.duplicates.suspicions.SuspiciousIdentity;
37 import fr.paris.lutece.plugins.identitystore.business.duplicates.suspicions.SuspiciousIdentityHome;
38 import fr.paris.lutece.plugins.identitystore.web.exception.IdentityStoreException;
39 import fr.paris.lutece.test.LuteceTestCase;
40
41 import java.util.Optional;
42
43
44
45
46 public class SuspiciousIdentityBusinessTest extends LuteceTestCase
47 {
48 private static final String CUSTOMERID1 = "CustomerId1";
49 private static final String CUSTOMERID2 = "CustomerId2";
50
51
52
53
54 public void testBusiness( ) throws IdentityStoreException
55 {
56
57 SuspiciousIdentity suspiciousIdentity = new SuspiciousIdentity( );
58 suspiciousIdentity.setCustomerId( CUSTOMERID1 );
59
60
61 SuspiciousIdentityHome.create( suspiciousIdentity );
62 Optional<SuspiciousIdentity> optSuspiciousIdentityStored = SuspiciousIdentityHome.findByPrimaryKey( suspiciousIdentity.getId( ) );
63 SuspiciousIdentity suspiciousIdentityStored = optSuspiciousIdentityStored.orElse( new SuspiciousIdentity( ) );
64 assertEquals( suspiciousIdentityStored.getCustomerId( ), suspiciousIdentity.getCustomerId( ) );
65
66
67 suspiciousIdentity.setCustomerId( CUSTOMERID2 );
68 SuspiciousIdentityHome.update( suspiciousIdentity );
69 optSuspiciousIdentityStored = SuspiciousIdentityHome.findByPrimaryKey( suspiciousIdentity.getId( ) );
70 suspiciousIdentityStored = optSuspiciousIdentityStored.orElse( new SuspiciousIdentity( ) );
71
72 assertEquals( suspiciousIdentityStored.getCustomerId( ), suspiciousIdentity.getCustomerId( ) );
73
74
75 SuspiciousIdentityHome.getSuspiciousIdentitysList( "0", 0, null );
76
77
78 SuspiciousIdentityHome.remove( suspiciousIdentity.getId( ) );
79 optSuspiciousIdentityStored = SuspiciousIdentityHome.findByPrimaryKey( suspiciousIdentity.getId( ) );
80 suspiciousIdentityStored = optSuspiciousIdentityStored.orElse( null );
81 assertNull( suspiciousIdentityStored );
82
83 }
84
85 }