From 056976918b4f876aaf847488d283fcd1f26f2ffb Mon Sep 17 00:00:00 2001 From: Vaibhav-a Mankar Date: Fri, 17 May 2024 10:40:07 +0530 Subject: [PATCH 1/3] SYMPHONYP-1118 test case for File handler --- .../teams/state/FileStateStorageUtility.java | 26 -- .../teams/controller/BotControllerTest.java | 57 +++++ .../ChannelServiceControllerTest.java | 227 ++++++++++++++++++ 3 files changed, 284 insertions(+), 26 deletions(-) create mode 100644 libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/controller/BotControllerTest.java create mode 100644 libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/controller/ChannelServiceControllerTest.java diff --git a/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/state/FileStateStorageUtility.java b/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/state/FileStateStorageUtility.java index 84fd7657..aff9d31a 100644 --- a/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/state/FileStateStorageUtility.java +++ b/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/state/FileStateStorageUtility.java @@ -1,42 +1,16 @@ package org.finos.springbot.teams.state; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.HashSet; import java.util.List; import java.util.Optional; -import java.util.Set; import org.finos.springbot.teams.TeamsException; public class FileStateStorageUtility { - public static Set getAllDataFiles(String filePath) { - Set fileList = new HashSet<>(); - getAllAddressableFiles(new File(filePath), fileList); - return fileList; - } - - private static void getAllAddressableFiles(File node, Set fileList) { - if (node.isDirectory()) { - String[] subNote = node.list(); - for (String fileName : subNote) { - File dir = new File(node, fileName); - if (dir.isDirectory()) { - getAllAddressableFiles(dir, fileList); - } else { - if (dir.getParentFile().getName().equals(FileStateStorage.DATA_FOLDER) - && dir.getName().equals(TeamsStateStorage.ADDRESSABLE_KEY + FileStateStorage.FILE_EXT)) { - fileList.add(dir); - } - } - } - } - } - public static Optional readFile(String filePath) { try { Path path = Paths.get(filePath); diff --git a/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/controller/BotControllerTest.java b/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/controller/BotControllerTest.java new file mode 100644 index 00000000..5d12388c --- /dev/null +++ b/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/controller/BotControllerTest.java @@ -0,0 +1,57 @@ +package org.finos.springbot.teams.controller; + + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import org.finos.springbot.teams.MockTeamsConfiguration; +import org.finos.springbot.teams.bot.BotController; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import com.microsoft.bot.builder.Bot; +import com.microsoft.bot.builder.InvokeResponse; +import com.microsoft.bot.integration.BotFrameworkHttpAdapter; +import com.microsoft.bot.schema.Activity; + +@SpringBootTest(classes = { MockTeamsConfiguration.class}) +@ActiveProfiles("teams") +@ExtendWith(SpringExtension.class) +public class BotControllerTest { + + @Mock + BotFrameworkHttpAdapter adapter; + + @Spy + Bot bot; + + @InjectMocks + BotController controller; + + + @SuppressWarnings({ "deprecation" }) + @Test + public void testIncoming() throws InterruptedException, ExecutionException { + Activity a = Mockito.mock(Activity.class); + InvokeResponse ir = new InvokeResponse(HttpStatus.OK.value(), "Success"); + Mockito.when(adapter.processIncomingActivity("any text", a, bot)).thenReturn(CompletableFuture.completedFuture(ir)); + CompletableFuture> future = controller.incoming(a, "any text"); + + ResponseEntity entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + Assertions.assertEquals("Success", entity.getBody()); + + } + +} diff --git a/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/controller/ChannelServiceControllerTest.java b/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/controller/ChannelServiceControllerTest.java new file mode 100644 index 00000000..1b443bcf --- /dev/null +++ b/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/controller/ChannelServiceControllerTest.java @@ -0,0 +1,227 @@ +package org.finos.springbot.teams.controller; + + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import org.finos.springbot.teams.MockTeamsConfiguration; +import org.finos.springbot.teams.TeamsWorkflowConfig; +import org.finos.springbot.teams.bot.ChannelServiceController; +import org.finos.springbot.teams.content.TeamsUser; +import org.finos.springbot.teams.handlers.TeamsResponseHandler; +import org.finos.springbot.workflow.data.DataHandlerConfig; +import org.finos.springbot.workflow.response.MessageResponse; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import com.microsoft.bot.builder.ChannelServiceHandler; +import com.microsoft.bot.schema.Activity; +import com.microsoft.bot.schema.AttachmentData; +import com.microsoft.bot.schema.ChannelAccount; +import com.microsoft.bot.schema.ConversationParameters; +import com.microsoft.bot.schema.ConversationResourceResponse; +import com.microsoft.bot.schema.ConversationsResult; +import com.microsoft.bot.schema.PagedMembersResult; +import com.microsoft.bot.schema.ResourceResponse; +import com.microsoft.bot.schema.Transcript; + +@SpringBootTest(classes = { MockTeamsConfiguration.class, TeamsWorkflowConfig.class, DataHandlerConfig.class }) +@ActiveProfiles("teams") +@ExtendWith(SpringExtension.class) +public class ChannelServiceControllerTest { + + @Mock + ChannelServiceHandler handler; + + @InjectMocks + ChannelServiceController controller = new ChannelServiceController(handler) {};; + + @Mock + TeamsResponseHandler teamsResponseHandler; + + ResourceResponse rr; + + Activity a; + + @BeforeEach + public void setup() { + controller = new ChannelServiceController(handler) {}; + a = Mockito.mock(Activity.class); + TeamsUser tu = new TeamsUser("made", "up", "thing"); + MessageResponse r = new MessageResponse(tu, "Some object"); + rr = Mockito.mock(ResourceResponse.class); + + Mockito.when(teamsResponseHandler.apply(r)).thenReturn(rr); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testSendToConversation() throws InterruptedException, ExecutionException { + + Mockito.when(handler.handleSendToConversation("any text","conversation Id", a)).thenReturn(CompletableFuture.completedFuture(rr)); + CompletableFuture> future = controller.sendToConversation("conversation Id", a, "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testReplyToActivity() throws InterruptedException, ExecutionException { + Mockito.when(handler.handleReplyToActivity("any text","conversation Id", "activityId", a)).thenReturn(CompletableFuture.completedFuture(rr)); + CompletableFuture> future = controller.replyToActivity("conversation Id", "activityId", a, "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testUpdateActivity() throws InterruptedException, ExecutionException { + Mockito.when(handler.handleUpdateActivity("any text","conversation Id", "activityId", a)).thenReturn(CompletableFuture.completedFuture(rr)); + CompletableFuture> future = controller.updateActivity("conversation Id", "activityId", a, "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testDeleteActivity() throws InterruptedException, ExecutionException { + + Void vo = Mockito.mock(Void.class); + + Mockito.when(handler.handleDeleteActivity("any text","conversation Id", "activityId")).thenReturn(CompletableFuture.completedFuture(vo)); + CompletableFuture> future = controller.deleteActivity("conversation Id", "activityId", "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(202, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testGetActivityMembers() throws InterruptedException, ExecutionException { + + List accounts = Mockito.mock(List.class); + + Mockito.when(handler.handleGetActivityMembers("any text","conversation Id", "activityId")).thenReturn(CompletableFuture.completedFuture(accounts)); + CompletableFuture>> future = controller.getActivityMembers("conversation Id", "activityId", "any text"); + ResponseEntity> entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testCreateConversation() throws InterruptedException, ExecutionException { + + ConversationResourceResponse r = Mockito.mock(ConversationResourceResponse.class); + + ConversationParameters parameters = new ConversationParameters(); + + Mockito.when(handler.handleCreateConversation("any text", parameters)).thenReturn(CompletableFuture.completedFuture(r)); + + CompletableFuture> future = controller.createConversation(parameters, "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testGetConversations() throws InterruptedException, ExecutionException { + + ConversationsResult r = Mockito.mock(ConversationsResult.class); + + Mockito.when(handler.handleGetConversations("any text", "conversation Id", "activityId")).thenReturn(CompletableFuture.completedFuture(r)); + + CompletableFuture> future = controller.getConversations("conversation Id", "activityId", "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testGetConversationMembers() throws InterruptedException, ExecutionException { + + List r = Mockito.mock(List.class); + + Mockito.when(handler.handleGetConversationMembers("any text", "conversation Id")).thenReturn(CompletableFuture.completedFuture(r)); + + CompletableFuture>> future = controller.getConversationMembers("conversation Id", "any text"); + ResponseEntity> entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testGetConversationPagedMembers() throws InterruptedException, ExecutionException { + + PagedMembersResult r = Mockito.mock(PagedMembersResult.class); + + Mockito.when(handler.handleGetConversationPagedMembers("any text", "conversation Id", 1, "activityId")).thenReturn(CompletableFuture.completedFuture(r)); + + CompletableFuture> future = controller.getConversationPagedMembers("conversation Id", 1, "activityId", "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testDeleteConversationMember() throws InterruptedException, ExecutionException { + + Void r = Mockito.mock(Void.class); + + Mockito.when(handler.handleDeleteConversationMember("any text", "conversation Id", "Member Id")).thenReturn(CompletableFuture.completedFuture(r)); + + CompletableFuture> future = controller.deleteConversationMember("conversation Id", "Member Id", "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(202, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testSendConversationHistory() throws InterruptedException, ExecutionException { + + ResourceResponse r = Mockito.mock(ResourceResponse.class); + + Transcript history = new Transcript(); + + Mockito.when(handler.handleSendConversationHistory("any text", "conversation Id", history)).thenReturn(CompletableFuture.completedFuture(r)); + + CompletableFuture> future = controller.sendConversationHistory("conversation Id",history, "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } + + @SuppressWarnings({ "deprecation" }) + @Test + public void testUploadAttachment() throws InterruptedException, ExecutionException { + + ResourceResponse r = Mockito.mock(ResourceResponse.class); + + AttachmentData attachmentUpload = new AttachmentData(); + + Mockito.when(handler.handleUploadAttachment("any text", "conversation Id", attachmentUpload)).thenReturn(CompletableFuture.completedFuture(r)); + + CompletableFuture> future = controller.uploadAttachment("conversation Id",attachmentUpload, "any text"); + ResponseEntity entity = future.get(); + + Assertions.assertEquals(200, entity.getStatusCodeValue()); + } +} From b1195d2012a9fe1a13a69b37aa3ea6c59cd14650 Mon Sep 17 00:00:00 2001 From: Vaibhav-a Mankar Date: Fri, 17 May 2024 12:41:30 +0530 Subject: [PATCH 2/3] SYMPHONYP-1118 test case for File handler --- .../teams/messages/FileActivityHandler.java | 23 +++++-- .../messages/FileActivityHandlerTest.java | 69 +++++++++++++++++++ 2 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/messages/FileActivityHandlerTest.java diff --git a/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/messages/FileActivityHandler.java b/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/messages/FileActivityHandler.java index 220ce98a..15dcc574 100644 --- a/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/messages/FileActivityHandler.java +++ b/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/messages/FileActivityHandler.java @@ -7,6 +7,7 @@ import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; +import java.net.URLConnection; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -73,11 +74,16 @@ private CompletableFuture> upload(FileConsentCardResponse fil LOG.info("File upload endpoint : {}", fileConsentCardResponse.getUploadInfo().getUploadUrl()); File filePath = new File(context.get("filepath")); - HttpURLConnection connection = null; + URLConnection connection = null; try { URL url = new URL(fileConsentCardResponse.getUploadInfo().getUploadUrl()); - connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("PUT"); + if(url.openConnection() instanceof HttpURLConnection) { + connection = (HttpURLConnection) url.openConnection(); + ((HttpURLConnection) connection).setRequestMethod("PUT"); + }else { + connection = (sun.net.www.protocol.file.FileURLConnection) url.openConnection(); + } + connection.setDoOutput(true); connection.setRequestProperty("Content-Length", Long.toString(filePath.length())); connection.setRequestProperty("Content-Range", @@ -108,13 +114,19 @@ private CompletableFuture> upload(FileConsentCardResponse fil result.set(new ResultPair(false, t.getLocalizedMessage())); } finally { if (connection != null) { - connection.disconnect(); + + if(connection instanceof HttpURLConnection) { + ((HttpURLConnection) connection).disconnect(); + } } } }).thenApply(aVoid -> result.get()); } private CompletableFuture fileUploadFailed(TurnContext turnContext, String error) { + + LOG.info("fileUploadFailed called with error {}" , error); + Activity reply = MessageFactory.text("File upload failed. Error:
" + error + "
"); reply.setTextFormat(TextFormatTypes.XML); return turnContext.sendActivityBlind(reply); @@ -129,6 +141,9 @@ private CompletableFuture fileDownloadCompleted(TurnContext turnContext, A private CompletableFuture fileUploadCompleted(TurnContext turnContext, FileConsentCardResponse fileConsentCardResponse) { + + LOG.info("file Upload Completed with unique id {} ", fileConsentCardResponse.getUploadInfo().getUniqueId()); + FileInfoCard downloadCard = new FileInfoCard(); downloadCard.setUniqueId(fileConsentCardResponse.getUploadInfo().getUniqueId()); downloadCard.setFileType(fileConsentCardResponse.getUploadInfo().getFileType()); diff --git a/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/messages/FileActivityHandlerTest.java b/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/messages/FileActivityHandlerTest.java new file mode 100644 index 00000000..3d4eb97b --- /dev/null +++ b/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/messages/FileActivityHandlerTest.java @@ -0,0 +1,69 @@ +package org.finos.springbot.teams.messages; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import org.finos.springbot.teams.MockTeamsConfiguration; +import org.finos.springbot.teams.TeamsWorkflowConfig; +import org.finos.springbot.workflow.data.DataHandlerConfig; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mockito; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import com.microsoft.bot.builder.TurnContext; +import com.microsoft.bot.schema.teams.FileConsentCardResponse; +import com.microsoft.bot.schema.teams.FileUploadInfo; + +@SpringBootTest(classes = { MockTeamsConfiguration.class, TeamsWorkflowConfig.class, DataHandlerConfig.class }) +@ActiveProfiles("teams") +@ExtendWith(SpringExtension.class) +public class FileActivityHandlerTest { + + + @InjectMocks + FileActivityHandler handler; + + TurnContext tc; + + @Test + public void testOnTeamsFileConsentAccept() throws IOException, InterruptedException, ExecutionException { + tc = Mockito.mock(TurnContext.class); + + FileConsentCardResponse f = getFileConsent(); + handler.onTeamsFileConsentAccept(tc, f); + } + + @Test + public void testOnTeamsFileConsentDecline() throws IOException, InterruptedException, ExecutionException { + tc = Mockito.mock(TurnContext.class); + + FileConsentCardResponse f = getFileConsent(); + handler.onTeamsFileConsentDecline(tc, f); + } + + private FileConsentCardResponse getFileConsent() throws IOException { + FileConsentCardResponse fileConsentCardResponse = new FileConsentCardResponse(); + Path file = Files.createTempFile("temp-", "sample.json"); + + Map map = new HashMap<>(); + String filePath = "file:///"+ file.toAbsolutePath().toString(); + map.put("filepath", filePath); + map.put("filename", "sample.json"); + + fileConsentCardResponse.setContext(map); + FileUploadInfo uploadInfo = new FileUploadInfo(); + + uploadInfo.setUploadUrl(filePath); + fileConsentCardResponse.setUploadInfo(uploadInfo); + return fileConsentCardResponse; + } + +} From 4958a388f0b9aa305b75a40a0beddee0275de69c Mon Sep 17 00:00:00 2001 From: Vaibhav-a Mankar Date: Fri, 17 May 2024 18:25:05 +0530 Subject: [PATCH 3/3] SYMPHONYP-1118 test case for File handler --- .../teams/messages/FileActivityHandler.java | 58 +++++++++---------- .../messages/FileActivityHandlerTest.java | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/messages/FileActivityHandler.java b/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/messages/FileActivityHandler.java index 15dcc574..0e21c0be 100644 --- a/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/messages/FileActivityHandler.java +++ b/libs/teams/teams-chat-workflow-spring-boot-starter/src/main/java/org/finos/springbot/teams/messages/FileActivityHandler.java @@ -77,45 +77,45 @@ private CompletableFuture> upload(FileConsentCardResponse fil URLConnection connection = null; try { URL url = new URL(fileConsentCardResponse.getUploadInfo().getUploadUrl()); - if(url.openConnection() instanceof HttpURLConnection) { + if (url.openConnection() instanceof HttpURLConnection) { connection = (HttpURLConnection) url.openConnection(); ((HttpURLConnection) connection).setRequestMethod("PUT"); - }else { - connection = (sun.net.www.protocol.file.FileURLConnection) url.openConnection(); - } - - connection.setDoOutput(true); - connection.setRequestProperty("Content-Length", Long.toString(filePath.length())); - connection.setRequestProperty("Content-Range", - String.format("bytes 0-%d/%d", filePath.length() - 1, filePath.length())); - - try (FileInputStream fileStream = new FileInputStream(filePath); - OutputStream uploadStream = connection.getOutputStream()) { - byte[] buffer = new byte[4096]; - int bytes_read; - while ((bytes_read = fileStream.read(buffer)) != -1) { - uploadStream.write(buffer, 0, bytes_read); - } - uploadStream.flush(); - } + connection.setDoOutput(true); + connection.setRequestProperty("Content-Length", Long.toString(filePath.length())); + connection.setRequestProperty("Content-Range", + String.format("bytes 0-%d/%d", filePath.length() - 1, filePath.length())); + + try (FileInputStream fileStream = new FileInputStream(filePath); + OutputStream uploadStream = connection.getOutputStream()) { + byte[] buffer = new byte[4096]; + int bytes_read; + while ((bytes_read = fileStream.read(buffer)) != -1) { + uploadStream.write(buffer, 0, bytes_read); + } - try { - BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String inputLine; - while ((inputLine = in.readLine()) != null) - LOG.info(inputLine); - in.close(); - } catch (Exception e) { - LOG.error("Exception occured while reading steam.. ignore this error " + e); + uploadStream.flush(); + } + + try { + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + while ((inputLine = in.readLine()) != null) + LOG.info(inputLine); + in.close(); + } catch (Exception e) { + LOG.error("Exception occured while reading steam.. ignore this error " + e); + } } result.set(new ResultPair(true, null)); + } catch (Throwable t) { + t.printStackTrace(); result.set(new ResultPair(false, t.getLocalizedMessage())); } finally { if (connection != null) { - - if(connection instanceof HttpURLConnection) { + + if (connection instanceof HttpURLConnection) { ((HttpURLConnection) connection).disconnect(); } } diff --git a/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/messages/FileActivityHandlerTest.java b/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/messages/FileActivityHandlerTest.java index 3d4eb97b..62fe48c8 100644 --- a/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/messages/FileActivityHandlerTest.java +++ b/libs/teams/teams-chat-workflow-spring-boot-starter/src/test/java/org/finos/springbot/teams/messages/FileActivityHandlerTest.java @@ -54,7 +54,7 @@ private FileConsentCardResponse getFileConsent() throws IOException { Path file = Files.createTempFile("temp-", "sample.json"); Map map = new HashMap<>(); - String filePath = "file:///"+ file.toAbsolutePath().toString(); + String filePath = "file://"+ file.toAbsolutePath().toString(); map.put("filepath", filePath); map.put("filename", "sample.json");