ExternalPayloadStorageUtils { @SuppressWarnings("unchecked") public Map<String, Object> downloadPayload(String path) { try (InputStream inputStream = externalPayloadStorage.download(path)) { return objectMapper.readValue(IOUtils.toString(inputStream), Map.class); } catch (IOException e) { logger.error("Unable to download payload from external storage path: {}", path, e); throw new ApplicationException(ApplicationException.Code.INTERNAL_ERROR, e); } } @Inject  ExternalPayloadStorageUtils(ExternalPayloadStorage externalPayloadStorage,
                                       Configuration configuration,
                                       ObjectMapper objectMapper); @SuppressWarnings("unchecked") Map<String, Object> downloadPayload(String path); void verifyAndUpload(T entity, PayloadType payloadType);  }
@Test public void testDownloadPayload() throws IOException { String path = "test/payload"; Map<String, Object> payload = new HashMap<>(); payload.put("key1", "value1"); payload.put("key2", 200); byte[] payloadBytes = objectMapper.writeValueAsString(payload).getBytes(); when(externalPayloadStorage.download(path)).thenReturn(new ByteArrayInputStream(payloadBytes)); Map<String, Object> result = externalPayloadStorageUtils.downloadPayload(path); assertNotNull(result); assertEquals(payload, result); }