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
35 package fr.paris.lutece.plugins.botpress.business;
36
37 import fr.paris.lutece.test.LuteceTestCase;
38
39
40
41
42 public class BPBotBusinessTest extends LuteceTestCase
43 {
44 private static final String BOTKEY1 = "BotKey1";
45 private static final String BOTKEY2 = "BotKey2";
46 private static final String NAME1 = "Name1";
47 private static final String NAME2 = "Name2";
48 private static final String DESCRIPTION1 = "Description1";
49 private static final String DESCRIPTION2 = "Description2";
50 private static final String AVATARURL1 = "AvatarUrl1";
51 private static final String AVATARURL2 = "AvatarUrl2";
52 private static final String LANGUAGE1 = "Language1";
53 private static final String LANGUAGE2 = "Language2";
54 private static final int BOTSTATUS1 = 1;
55 private static final int BOTSTATUS2 = 2;
56 private static final int ISSTANDALONE1 = 1;
57 private static final int ISSTANDALONE2 = 2;
58 private static final String WELCOMEMESSAGE1 = "WelcomeMessage1";
59 private static final String WELCOMEMESSAGE2 = "WelcomeMessage2";
60 private static final String SERVERURL1 = "ServerUrl1";
61 private static final String SERVERURL2 = "ServerUrl2";
62 private static final int APIVERSION1 = 1;
63 private static final int APIVERSION2 = 2;
64
65
66
67
68 public void testBusiness( )
69 {
70
71 BPBot bPBot = new BPBot( );
72 bPBot.setBotKey( BOTKEY1 );
73 bPBot.setName( NAME1 );
74 bPBot.setDescription( DESCRIPTION1 );
75 bPBot.setAvatarUrl( AVATARURL1 );
76 bPBot.setLanguage( LANGUAGE1 );
77 bPBot.setBotStatus( BOTSTATUS1 );
78 bPBot.setIsStandalone( ISSTANDALONE1 );
79 bPBot.setWelcomeMessage( WELCOMEMESSAGE1 );
80 bPBot.setServerUrl( SERVERURL1 );
81 bPBot.setApiVersion( APIVERSION1 );
82
83
84 BPBotHome.create( bPBot );
85 BPBot bPBotStored = BPBotHome.findByPrimaryKey( bPBot.getId( ) );
86 assertEquals( bPBotStored.getBotKey( ), bPBot.getBotKey( ) );
87 assertEquals( bPBotStored.getName( ), bPBot.getName( ) );
88 assertEquals( bPBotStored.getDescription( ), bPBot.getDescription( ) );
89 assertEquals( bPBotStored.getAvatarUrl( ), bPBot.getAvatarUrl( ) );
90 assertEquals( bPBotStored.getLanguage( ), bPBot.getLanguage( ) );
91 assertEquals( bPBotStored.getBotStatus( ), bPBot.getBotStatus( ) );
92 assertEquals( bPBotStored.getIsStandalone( ), bPBot.getIsStandalone( ) );
93 assertEquals( bPBotStored.getWelcomeMessage( ), bPBot.getWelcomeMessage( ) );
94 assertEquals( bPBotStored.getServerUrl( ), bPBot.getServerUrl( ) );
95 assertEquals( bPBotStored.getApiVersion( ), bPBot.getApiVersion( ) );
96
97
98 bPBot.setBotKey( BOTKEY2 );
99 bPBot.setName( NAME2 );
100 bPBot.setDescription( DESCRIPTION2 );
101 bPBot.setAvatarUrl( AVATARURL2 );
102 bPBot.setLanguage( LANGUAGE2 );
103 bPBot.setBotStatus( BOTSTATUS2 );
104 bPBot.setIsStandalone( ISSTANDALONE2 );
105 bPBot.setWelcomeMessage( WELCOMEMESSAGE2 );
106 bPBot.setServerUrl( SERVERURL2 );
107 bPBot.setApiVersion( APIVERSION2 );
108 BPBotHome.update( bPBot );
109 bPBotStored = BPBotHome.findByPrimaryKey( bPBot.getId( ) );
110 assertEquals( bPBotStored.getBotKey( ), bPBot.getBotKey( ) );
111 assertEquals( bPBotStored.getName( ), bPBot.getName( ) );
112 assertEquals( bPBotStored.getDescription( ), bPBot.getDescription( ) );
113 assertEquals( bPBotStored.getAvatarUrl( ), bPBot.getAvatarUrl( ) );
114 assertEquals( bPBotStored.getLanguage( ), bPBot.getLanguage( ) );
115 assertEquals( bPBotStored.getBotStatus( ), bPBot.getBotStatus( ) );
116 assertEquals( bPBotStored.getIsStandalone( ), bPBot.getIsStandalone( ) );
117 assertEquals( bPBotStored.getWelcomeMessage( ), bPBot.getWelcomeMessage( ) );
118 assertEquals( bPBotStored.getServerUrl( ), bPBot.getServerUrl( ) );
119 assertEquals( bPBotStored.getApiVersion( ), bPBot.getApiVersion( ) );
120
121
122 BPBotHome.getBPBotsList( );
123
124
125 BPBotHome.remove( bPBot.getId( ) );
126 bPBotStored = BPBotHome.findByPrimaryKey( bPBot.getId( ) );
127 assertNull( bPBotStored );
128
129 }
130
131 }