@Test public void test_should_geturl_by_fileStoreId() { Map<String, String> expectedFileStoreUrls = new HashMap<String, String>(); expectedFileStoreUrls.put("key", "value"); when(restTemplate.getForObject(any(String.class), eq(Map.class))).thenReturn(expectedFileStoreUrls); Map<String, String> fileStoreUrl = null; try { List<String> list = new ArrayList<String>(); list.add("key"); fileStoreUrl = fileStoreRepository.getUrlByFileStoreId("default", list); } catch (Exception e) { e.printStackTrace(); } assertEquals(fileStoreUrl.get("key"), "value"); }
public Map<String, String> getUrlByFileStoreId(String tenantId, List<String> fileStoreIds) throws Exception { Map<String, String> fileStoreUrls = null; String idLIst = fileStoreIds.toString().substring(1, fileStoreIds.toString().length() - 1).replace(", ", ","); log.info("idLIst: " + idLIst); String Url = fileStoreHost + fileStorePath + "?tenantId=" + tenantId + "&fileStoreIds=" + idLIst; try { fileStoreUrls = restTemplate.getForObject(Url, Map.class); } catch (HttpClientErrorException e) { throw new RuntimeException(e.getResponseBodyAsString()); } log.info("filrStoreUrls " + fileStoreUrls); if (null != fileStoreUrls && !fileStoreUrls.isEmpty()) return fileStoreUrls; return null; }
FileStoreRepository { public Map<String, String> getUrlByFileStoreId(String tenantId, List<String> fileStoreIds) throws Exception { Map<String, String> fileStoreUrls = null; String idLIst = fileStoreIds.toString().substring(1, fileStoreIds.toString().length() - 1).replace(", ", ","); log.info("idLIst: " + idLIst); String Url = fileStoreHost + fileStorePath + "?tenantId=" + tenantId + "&fileStoreIds=" + idLIst; try { fileStoreUrls = restTemplate.getForObject(Url, Map.class); } catch (HttpClientErrorException e) { throw new RuntimeException(e.getResponseBodyAsString()); } log.info("filrStoreUrls " + fileStoreUrls); if (null != fileStoreUrls && !fileStoreUrls.isEmpty()) return fileStoreUrls; return null; } }
FileStoreRepository { public Map<String, String> getUrlByFileStoreId(String tenantId, List<String> fileStoreIds) throws Exception { Map<String, String> fileStoreUrls = null; String idLIst = fileStoreIds.toString().substring(1, fileStoreIds.toString().length() - 1).replace(", ", ","); log.info("idLIst: " + idLIst); String Url = fileStoreHost + fileStorePath + "?tenantId=" + tenantId + "&fileStoreIds=" + idLIst; try { fileStoreUrls = restTemplate.getForObject(Url, Map.class); } catch (HttpClientErrorException e) { throw new RuntimeException(e.getResponseBodyAsString()); } log.info("filrStoreUrls " + fileStoreUrls); if (null != fileStoreUrls && !fileStoreUrls.isEmpty()) return fileStoreUrls; return null; }  }
FileStoreRepository { public Map<String, String> getUrlByFileStoreId(String tenantId, List<String> fileStoreIds) throws Exception { Map<String, String> fileStoreUrls = null; String idLIst = fileStoreIds.toString().substring(1, fileStoreIds.toString().length() - 1).replace(", ", ","); log.info("idLIst: " + idLIst); String Url = fileStoreHost + fileStorePath + "?tenantId=" + tenantId + "&fileStoreIds=" + idLIst; try { fileStoreUrls = restTemplate.getForObject(Url, Map.class); } catch (HttpClientErrorException e) { throw new RuntimeException(e.getResponseBodyAsString()); } log.info("filrStoreUrls " + fileStoreUrls); if (null != fileStoreUrls && !fileStoreUrls.isEmpty()) return fileStoreUrls; return null; }  Map<String, String> getUrlByFileStoreId(String tenantId, List<String> fileStoreIds); }
FileStoreRepository { public Map<String, String> getUrlByFileStoreId(String tenantId, List<String> fileStoreIds) throws Exception { Map<String, String> fileStoreUrls = null; String idLIst = fileStoreIds.toString().substring(1, fileStoreIds.toString().length() - 1).replace(", ", ","); log.info("idLIst: " + idLIst); String Url = fileStoreHost + fileStorePath + "?tenantId=" + tenantId + "&fileStoreIds=" + idLIst; try { fileStoreUrls = restTemplate.getForObject(Url, Map.class); } catch (HttpClientErrorException e) { throw new RuntimeException(e.getResponseBodyAsString()); } log.info("filrStoreUrls " + fileStoreUrls); if (null != fileStoreUrls && !fileStoreUrls.isEmpty()) return fileStoreUrls; return null; }  Map<String, String> getUrlByFileStoreId(String tenantId, List<String> fileStoreIds);  }