1
1
package com .ericsson .eiffelcommons .subscriptionobjecttest ;
2
2
3
3
import static org .junit .Assert .assertEquals ;
4
+ import static org .junit .Assert .assertTrue ;
4
5
5
6
import java .io .IOException ;
6
7
10
11
import org .junit .Test ;
11
12
12
13
import com .ericsson .eiffelcommons .helpers .MediaType ;
14
+ import com .ericsson .eiffelcommons .subscriptionobject .MailSubscriptionObject ;
13
15
import com .ericsson .eiffelcommons .subscriptionobject .RestPostSubscriptionObject ;
14
16
15
17
public class SubscriptionObjectTest {
16
18
17
19
RestPostSubscriptionObject restPostSubscription ;
20
+ MailSubscriptionObject mailSubscription ;
18
21
19
22
@ Before
20
23
public void setup () throws IOException {
21
24
restPostSubscription = new RestPostSubscriptionObject ("mySubscription" );
25
+ mailSubscription = new MailSubscriptionObject ("myMailSubscription" );
22
26
}
23
27
24
28
@ Test
@@ -50,8 +54,7 @@ public void testSetNotificationMeta() {
50
54
restPostSubscription .setNotificationMeta ("http://localhost:8080" );
51
55
52
56
String actualNotificationMeta = restPostSubscription .getSubscriptionJson ()
53
- .get ("notificationMeta" )
54
- .toString ();
57
+ .getString ("notificationMeta" );
55
58
assertEquals ("http://localhost:8080" , actualNotificationMeta );
56
59
}
57
60
@@ -60,14 +63,11 @@ public void testSetBasicAuth() {
60
63
restPostSubscription .setBasicAuth ("admin" , "admin" );
61
64
62
65
String actualUsername = restPostSubscription .getSubscriptionJson ()
63
- .get ("userName" )
64
- .toString ();
66
+ .getString ("userName" );
65
67
String actualPassword = restPostSubscription .getSubscriptionJson ()
66
- .get ("password" )
67
- .toString ();
68
+ .getString ("password" );
68
69
String actualAuthenticationType = restPostSubscription .getSubscriptionJson ()
69
- .get ("authenticationType" )
70
- .toString ();
70
+ .getString ("authenticationType" );
71
71
72
72
assertEquals ("admin" , actualUsername );
73
73
assertEquals ("admin" , actualPassword );
@@ -79,11 +79,31 @@ public void testSetRestPostBodyMediaType() {
79
79
restPostSubscription .setRestPostBodyMediaType (MediaType .APPLICATION_FORM_URLENCODED );
80
80
81
81
String actualRestPostBodyMediaType = restPostSubscription .getSubscriptionJson ()
82
- .get ("restPostBodyMediaType" )
83
- .toString ();
82
+ .getString ("restPostBodyMediaType" );
84
83
assertEquals ("application/x-www-form-urlencoded" , actualRestPostBodyMediaType );
85
84
}
86
85
86
+ @ Test
87
+ public void testSetNotificationBody () {
88
+ String body = "Body" ;
89
+ mailSubscription .addNotificationBody (body );
90
+
91
+ String actualNotificationBody = mailSubscription .getSubscriptionJson ()
92
+ .get ("notificationMessageKeyValues" )
93
+ .toString ();
94
+ assertTrue (actualNotificationBody .contains (body ));
95
+ }
96
+
97
+ @ Test
98
+ public void testSetEmailSubject () {
99
+ String subject = "MySubject" ;
100
+ mailSubscription .setEmailSubject (subject );
101
+
102
+ String actualEmailSubject = mailSubscription .getSubscriptionJson ()
103
+ .getString ("emailSubject" );
104
+ assertEquals (subject , actualEmailSubject );
105
+ }
106
+
87
107
@ Test
88
108
public void testChaining () {
89
109
restPostSubscription .addNotificationMessageKeyValue ("Key" , "value" )
0 commit comments