@@ -67,6 +67,41 @@ public void beforeMethod() {
6767 properties = new Properties ();
6868 }
6969
70+ @ Test
71+ public void testInvalidEmailAddresses () {
72+ String [] invalidEmails = new String [] { "username" ,
73+ "username@.com.my" ,
74+ "username123@example.a" ,
75+ "username123@.com" ,
76+ "username123@.com.com" ,
77+ "username()*@example.com" ,
78+ "username@%*.com" };
79+ basicChaosEmailNotifier = new BasicChaosEmailNotifier (new BasicConfiguration (properties ), sesClient , null );
80+
81+ for (String emailAddress : invalidEmails ) {
82+ Assert .assertFalse (basicChaosEmailNotifier .isValidEmail (emailAddress ));
83+ }
84+ }
85+
86+ @ Test
87+ public void testValidEmailAddresses () {
88+ String [] validEmails = new String [] { "username-100@example.com" ,
89+ "name.surname+ml-info@example.com" ,
90+ "username.100@example.com" ,
91+ "username111@example.com" ,
92+ "username-100@username.net" ,
93+ "username.100@example.com.au" ,
94+ "username@1.com" ,
95+ "username@example.com" ,
96+ "username+100@example.com" ,
97+ "username-100@example-test.com" };
98+ basicChaosEmailNotifier = new BasicChaosEmailNotifier (new BasicConfiguration (properties ), sesClient , null );
99+
100+ for (String emailAddress : validEmails ) {
101+ Assert .assertTrue (basicChaosEmailNotifier .isValidEmail (emailAddress ));
102+ }
103+ }
104+
70105 @ Test
71106 public void testbuildEmailSubject () {
72107 basicChaosEmailNotifier = new BasicChaosEmailNotifier (new BasicConfiguration (properties ), sesClient , null );
@@ -152,4 +187,4 @@ public void testBuildAndSendEmailSubjectIsBody() {
152187 verify (spyBasicChaosEmailNotifier ).sendEmail (to , defaultBody , defaultBody );
153188 }
154189
155- }
190+ }
0 commit comments