@@ -65,6 +65,33 @@ void simpleMessageWithHeaders() throws IOException{
6565
6666 }
6767
68+ @ Test
69+ void singleMessageFromRecipient () {
70+ Message message = new Message ();
71+
72+ message .setFrom ("igor@example.com" );
73+ assertEquals (message .getFrom (), "igor@example.com" );
74+ }
75+
76+ @ Test
77+ void singleMessageFromRecipientFullName () {
78+ Message message = new Message ();
79+
80+ message .setFrom ("John Smith" ,"igor@example.com" );
81+ assertEquals (message .getFrom (), "\" John Smith\" <igor@example.com>" );
82+ }
83+
84+ @ Test
85+ void singleMessageToRecipient () {
86+ Message message = new Message ();
87+
88+ ArrayList <String > recipients = new ArrayList <>();
89+ recipients .add ("igor@example.com" );
90+
91+ message .setTo (recipients );
92+ assertEquals (message .getTo (), "\" igor@example.com\" " );
93+ }
94+
6895 @ Test
6996 void simpleMessageToRecipients () throws IOException {
7097
@@ -167,14 +194,31 @@ void addAttachment() throws IOException {
167194 assertEquals (attachment .get ("ContentType" ), "application/pdf" );
168195 assertEquals (attachment .get ("Name" ), new File (getDefaultFilePath ()).getName ());
169196 assertNotNull (attachment .get ("Content" ));
197+ assertEquals (attachment .get ("ContentId" ), null );
198+ }
199+
200+ @ Test
201+ void addAttachmentWithContentId () throws IOException {
202+ String contentId = "test-id" ;
203+ Message message = new Message ("from@example.com" ,"to@example.com" ,"Hello world" , "Hello world" );
204+ message .addAttachment (getDefaultFilePath (), contentId );
205+
206+ HashMap <String ,String > attachment = (HashMap <String , String >) message .getAttachments ().get (0 );
207+ assertEquals (attachment .get ("ContentType" ), "application/pdf" );
208+ assertEquals (attachment .get ("Name" ), new File (getDefaultFilePath ()).getName ());
209+ assertNotNull (attachment .get ("Content" ));
210+ assertEquals (attachment .get ("ContentId" ), contentId );
170211 }
171212
172213 @ Test
173214 void addMultipleAttachments () throws IOException {
215+ String contentId = "test-id" ;
174216 Message message = new Message ("from@example.com" ,"to@example.com" ,"Hello world" , "Hello world" );
175- message .addAttachment (getDefaultFilePath ());
217+ message .addAttachment (getDefaultFilePath (), contentId );
176218 message .addAttachment (getDefaultFilePath ());
177219 assertEquals (message .getAttachments ().size (), 2 );
220+ assertEquals (message .getAttachments ().get (0 ).get ("ContentId" ), contentId );
221+ assertEquals (message .getAttachments ().get (1 ).get ("ContentId" ), null );
178222 }
179223
180224}
0 commit comments