11package com .aspose .email .cloud .sdk .api ;
22
33import java .io .IOException ;
4- import java .nio . charset . StandardCharsets ;
4+ import java .io . UnsupportedEncodingException ;
55import java .text .DateFormat ;
66import java .text .ParseException ;
77import java .text .SimpleDateFormat ;
@@ -74,10 +74,10 @@ public void dateTest() throws ApiException, ParseException {
7474 }
7575
7676 @ Test (groups = { "pipeline" })
77- public void fileTest () throws ApiException {
77+ public void fileTest () throws ApiException , UnsupportedEncodingException {
7878 String file = createCalendar ();
7979 byte [] fileBytes = api .downloadFile (new DownloadFileRequestData (folder + "/" + file , storage , null ));
80- String calendarContent = new String (fileBytes , StandardCharsets . UTF_8 );
80+ String calendarContent = new String (fileBytes , "UTF-8" );
8181 assert calendarContent .contains ("organizer@am.ru" );
8282 String uploadedName = UUID .randomUUID ().toString () + ".ics" ;
8383 String path = folder + "/" + uploadedName ;
@@ -188,7 +188,7 @@ public void aiBcrParseStorageTest() throws ApiException, IOException {
188188 ListResponseOfStorageFileLocation result = api .aiBcrParseStorage (new AiBcrParseStorageRequestData (
189189 new AiBcrParseStorageRq (
190190 null ,
191- Arrays . asList (new AiBcrImageStorageFile (true , new StorageFileLocation (storage , folder , fileName ))),
191+ Collections . singletonList (new AiBcrImageStorageFile (true , new StorageFileLocation (storage , folder , fileName ))),
192192 new StorageFolderLocation (storage , outFolderPath ))));
193193 // Check that only one file produced
194194 assert result .getValue ().size () == 1 ;
@@ -199,7 +199,7 @@ public void aiBcrParseStorageTest() throws ApiException, IOException {
199199 contactFile .getFolderPath () + "/" + contactFile .getFileName (),
200200 contactFile .getStorage (),
201201 null ));
202- String contactFileContent = new String (contactBytes , StandardCharsets . UTF_8 );
202+ String contactFileContent = new String (contactBytes , "UTF-8" );
203203 assert contactFileContent .contains ("Thomas" );
204204 // 5) Get VCard object properties list, check that there are 3 properties or more
205205 HierarchicalObject contactProperties = api .getContactProperties (new GetContactPropertiesRequestData (
@@ -219,7 +219,7 @@ public void aiBcrParseTest() throws ApiException, IOException {
219219 this .getClass ().getResourceAsStream ("test_single_0001.png" ));
220220 String fileBase64 = Base64 .encodeToString (fileBytes , false );
221221 ListResponseOfHierarchicalObject result = api .aiBcrParse (new AiBcrParseRequestData (
222- new AiBcrBase64Rq (null , Arrays . asList (new AiBcrBase64Image (true , fileBase64 )))));
222+ new AiBcrBase64Rq (null , Collections . singletonList (new AiBcrBase64Image (true , fileBase64 )))));
223223 assert result .getValue ().size () == 1 ;
224224 PrimitiveObject displayName = null ;
225225 for (BaseObject property : result .getValue ().get (0 ).getInternalProperties ()) {
@@ -233,7 +233,7 @@ public void aiBcrParseTest() throws ApiException, IOException {
233233 }
234234
235235 @ Test (groups = { "pipeline" })
236- public void createCalendarEmailTest () throws ApiException {
236+ public void createCalendarEmailTest () throws ApiException , UnsupportedEncodingException {
237237 Calendar startDate = Calendar .getInstance ();
238238 Calendar endDate = (Calendar ) startDate .clone ();
239239 endDate .set (Calendar .HOUR_OF_DAY , endDate .get (Calendar .HOUR_OF_DAY ) + 1 );
@@ -272,7 +272,7 @@ public void createCalendarEmailTest() throws ApiException {
272272
273273 byte [] downloaded = api .downloadFile (
274274 new DownloadFileRequestData (folder + "/" + emailFile , storage , null ));
275- String calendarContent = new String (downloaded , StandardCharsets . UTF_8 );
275+ String calendarContent = new String (downloaded , "UTF-8" );
276276 assert calendarContent .contains ("Some subject" );
277277 }
278278
@@ -304,7 +304,7 @@ public void aiBcrParseModelTest() throws ApiException, IOException {
304304 this .getClass ().getResourceAsStream ("test_single_0001.png" ));
305305 String fileBase64 = Base64 .encodeToString (fileBytes , false );
306306 ListResponseOfContactDto result = api .aiBcrParseModel (new AiBcrParseModelRequestData (
307- new AiBcrBase64Rq (null , Arrays . asList (new AiBcrBase64Image (true , fileBase64 )))));
307+ new AiBcrBase64Rq (null , Collections . singletonList (new AiBcrBase64Image (true , fileBase64 )))));
308308 assert result .getValue ().size () == 1 ;
309309 ContactDto firstVCard = result .getValue ().get (0 );
310310 assert firstVCard .getDisplayName ().contains ("Thomas" );
@@ -316,8 +316,7 @@ public void discoverEmailConfigTest() throws ApiException {
316316 new DiscoverEmailConfigRequestData ("example@gmail.com" , true ));
317317 assert configList .getValue ().size () >= 2 ;
318318 for (EmailAccountConfig config : configList .getValue ()) {
319- if (config .getProtocolType ().equals ("SMTP" ))
320- assert "smtp.gmail.com" .equals (config .getHost ());
319+ assert !config .getProtocolType ().equals ("SMTP" ) || "smtp.gmail.com" .equals (config .getHost ());
321320 }
322321 }
323322
@@ -395,7 +394,7 @@ public void emailClientAccountTest() throws ApiException {
395394 @ Test (groups = { "pipeline" })
396395 public void emailClientMultiAccountTest () throws ApiException {
397396 EmailClientMultiAccount multiAccount = new EmailClientMultiAccount (
398- Arrays .< EmailClientAccount > asList (
397+ Arrays .asList (
399398 new EmailClientAccount ("imap.gmail.com" , 993 , "SSLAuto" , "IMAP" ,
400399 new EmailClientAccountPasswordCredentials ("example@gmail.com" , null , "password" ), null ),
401400 new EmailClientAccount ("exchange.outlook.com" , 443 , "SSLAuto" , "EWS" ,
@@ -425,18 +424,18 @@ private String createCalendar(Calendar startDate) throws ApiException {
425424 Calendar endDate =(Calendar ) startDate .clone ();
426425 endDate .set (Calendar .HOUR_OF_DAY , endDate .get (Calendar .HOUR_OF_DAY ) + 1 );
427426 api .createCalendar (new CreateCalendarRequestData (fileName , new HierarchicalObjectRequest (
428- new HierarchicalObject ("CALENDAR" , null , Arrays .< BaseObject > asList (
427+ new HierarchicalObject ("CALENDAR" , null , Arrays .asList (
429428 new PrimitiveObject ("LOCATION" , null , "location" ),
430429 new PrimitiveObject ("STARTDATE" , null , dateFormat .format (startDate .getTime ())),
431430 new PrimitiveObject ("ENDDATE" , null , dateFormat .format (endDate .getTime ())),
432431 new HierarchicalObject ("ORGANIZER" , null , Arrays .<BaseObject >asList (
433432 new PrimitiveObject ("ADDRESS" , null , "organizer@am.ru" ),
434433 new PrimitiveObject ("DISPLAYNAME" , null , "Organizer Name" ))),
435- new HierarchicalObject ("ATTENDEES" , null , Arrays .<BaseObject >asList (
436- new IndexedHierarchicalObject (
437- "ATTENDEE" , null , 0 , Arrays .<BaseObject >asList (
438- new PrimitiveObject ("ADDRESS" , null , "attendee@am.ru" ),
439- new PrimitiveObject ("DISPLAYNAME" , null , "Attendee Name" ))))))),
434+ new HierarchicalObject ("ATTENDEES" , null , Collections .<BaseObject >singletonList (
435+ new IndexedHierarchicalObject (
436+ "ATTENDEE" , null , 0 , Arrays .<BaseObject >asList (
437+ new PrimitiveObject ("ADDRESS" , null , "attendee@am.ru" ),
438+ new PrimitiveObject ("DISPLAYNAME" , null , "Attendee Name" ))))))),
440439 new StorageFolderLocation (storage , folder ))));
441440 return fileName ;
442441 }
0 commit comments