Skip to content

Commit add9561

Browse files
committed
Update codestyle
1 parent 132d5b9 commit add9561

2 files changed

Lines changed: 34 additions & 30 deletions

File tree

src/main/java/io/github/jpmorganchase/fusion/Fusion.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,12 @@ public void download(
605605

606606
for (String fileName : fileNames) {
607607

608+
// String safeFileName = (fileName.equalsIgnoreCase(distribution)
609+
// ? String.format("%s_%s_%s", catalogName, dataset, seriesMember)
610+
// : fileName)
611+
// .replaceAll("[^a-zA-Z0-9_.\\-]", "_");
608612
String safeFileName = fileName.replaceAll("[^a-zA-Z0-9_.\\-]", "_");
609-
String fullPath = path + "/" + safeFileName;
613+
String fullPath = path + "/" + safeFileName + "." + distribution;
610614

611615
String url = null;
612616
try {

src/test/java/io/github/jpmorganchase/fusion/FusionTest.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ public void testFileDownloadInteraction() throws Exception {
226226
when(apiManager.callAPI(String.format(
227227
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files",
228228
config.getRootURL(), "common", "sample_dataset", "20230308", "csv")))
229-
.thenReturn("[\"file1.csv\"]");
229+
.thenReturn("[\"file1\"]");
230230

231231
doNothing()
232232
.when(apiManager)
233233
.callAPIFileDownload(
234234
String.format(
235235
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s?file=%s",
236-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1.csv"),
236+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1"),
237237
String.format("%s/%s", TMP_PATH, "file1.csv"),
238238
"common",
239239
"sample_dataset",
@@ -250,14 +250,14 @@ public void testFileDownloadInteractionWithDefaultPath() throws Exception {
250250
when(apiManager.callAPI(String.format(
251251
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files",
252252
config.getRootURL(), "common", "sample_dataset", "20230308", "csv")))
253-
.thenReturn("[\"file1.csv\"]");
253+
.thenReturn("[\"file1\"]");
254254

255255
doNothing()
256256
.when(apiManager)
257257
.callAPIFileDownload(
258258
String.format(
259259
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s?file=%s",
260-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1.csv"),
260+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1"),
261261
String.format("%s/%s", "downloads", "file1.csv"),
262262
"common",
263263
"sample_dataset",
@@ -274,12 +274,12 @@ public void testFileDownloadAsStreamInteraction() throws Exception {
274274
when(apiManager.callAPI(String.format(
275275
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files",
276276
config.getRootURL(), "common", "sample_dataset", "20230308", "csv")))
277-
.thenReturn("[\"file1.csv\"]");
277+
.thenReturn("[\"file1\"]");
278278

279279
when(apiManager.callAPIFileDownload(
280280
String.format(
281281
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files/operationType/download?file=%s",
282-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1.csv"),
282+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1"),
283283
"common",
284284
"sample_dataset",
285285
new HashMap<>()))
@@ -288,9 +288,9 @@ public void testFileDownloadAsStreamInteraction() throws Exception {
288288
Map<String, InputStream> response = f.downloadStream("common", "sample_dataset", "20230308", "csv");
289289

290290
assertThat(response.size(), is(equalTo(1)));
291-
assertThat(response.containsKey("file1.csv"), is(true));
291+
assertThat(response.containsKey("file1"), is(true));
292292

293-
InputStream stream = response.get("file1.csv");
293+
InputStream stream = response.get("file1");
294294
String responseText = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))
295295
.lines()
296296
.collect(Collectors.joining("\n"));
@@ -585,7 +585,7 @@ public void fileDownloadWithInvalidPathThrowsFusionException() throws Exception
585585
when(apiManager.callAPI(String.format(
586586
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files",
587587
config.getRootURL(), "common", "sample", "1", "csv")))
588-
.thenReturn("[\"file1.csv\"]");
588+
.thenReturn("[\"file1\"]");
589589

590590
FusionException thrown = assertThrows(FusionException.class, () -> {
591591
f.download("common", "sample", "1", "csv", "\0");
@@ -600,13 +600,13 @@ public void testListDistributionFiles() throws Exception {
600600
when(apiManager.callAPI(String.format(
601601
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files",
602602
config.getRootURL(), "common", "sample_dataset", "20230308", "csv")))
603-
.thenReturn("[\"file1.csv\", \"file2.csv\", \"file3.csv\"]");
603+
.thenReturn("[\"file1\", \"file2\", \"file3\"]");
604604

605605
List<String> files = f.listDistributionFiles("sample_dataset", "20230308", "csv", "common", 0);
606606
assertThat(files.size(), is(equalTo(3)));
607-
assertThat(files.get(0), is(equalTo("file1.csv")));
608-
assertThat(files.get(1), is(equalTo("file2.csv")));
609-
assertThat(files.get(2), is(equalTo("file3.csv")));
607+
assertThat(files.get(0), is(equalTo("file1")));
608+
assertThat(files.get(1), is(equalTo("file2")));
609+
assertThat(files.get(2), is(equalTo("file3")));
610610
}
611611

612612
@Test
@@ -616,12 +616,12 @@ public void testListDistributionFilesWithMaxResults() throws Exception {
616616
when(apiManager.callAPI(String.format(
617617
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files",
618618
config.getRootURL(), "common", "sample_dataset", "20230308", "csv")))
619-
.thenReturn("[\"file1.csv\", \"file2.csv\", \"file3.csv\"]");
619+
.thenReturn("[\"file1\", \"file2\", \"file3\"]");
620620

621621
List<String> files = f.listDistributionFiles("sample_dataset", "20230308", "csv", "common", 2);
622622
assertThat(files.size(), is(equalTo(2)));
623-
assertThat(files.get(0), is(equalTo("file1.csv")));
624-
assertThat(files.get(1), is(equalTo("file2.csv")));
623+
assertThat(files.get(0), is(equalTo("file1")));
624+
assertThat(files.get(1), is(equalTo("file2")));
625625
}
626626

627627
@Test
@@ -645,14 +645,14 @@ public void testDownloadMultipleFiles() throws Exception {
645645
when(apiManager.callAPI(String.format(
646646
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files",
647647
config.getRootURL(), "common", "sample_dataset", "20230308", "csv")))
648-
.thenReturn("[\"file1.csv\", \"file2.csv\"]");
648+
.thenReturn("[\"file1\", \"file2\"]");
649649

650650
doNothing()
651651
.when(apiManager)
652652
.callAPIFileDownload(
653653
String.format(
654654
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s?file=%s",
655-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1.csv"),
655+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1"),
656656
String.format("%s/%s", TMP_PATH, "file1.csv"),
657657
"common",
658658
"sample_dataset",
@@ -663,7 +663,7 @@ public void testDownloadMultipleFiles() throws Exception {
663663
.callAPIFileDownload(
664664
String.format(
665665
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s?file=%s",
666-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file2.csv"),
666+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file2"),
667667
String.format("%s/%s", TMP_PATH, "file2.csv"),
668668
"common",
669669
"sample_dataset",
@@ -675,7 +675,7 @@ public void testDownloadMultipleFiles() throws Exception {
675675
.callAPIFileDownload(
676676
String.format(
677677
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s?file=%s",
678-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1.csv"),
678+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1"),
679679
String.format("%s/%s", TMP_PATH, "file1.csv"),
680680
"common",
681681
"sample_dataset",
@@ -685,7 +685,7 @@ public void testDownloadMultipleFiles() throws Exception {
685685
.callAPIFileDownload(
686686
String.format(
687687
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s?file=%s",
688-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file2.csv"),
688+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file2"),
689689
String.format("%s/%s", TMP_PATH, "file2.csv"),
690690
"common",
691691
"sample_dataset",
@@ -721,12 +721,12 @@ public void testDownloadStreamMultipleFiles() throws Exception {
721721
when(apiManager.callAPI(String.format(
722722
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files",
723723
config.getRootURL(), "common", "sample_dataset", "20230308", "csv")))
724-
.thenReturn("[\"file1.csv\", \"file2.csv\"]");
724+
.thenReturn("[\"file1\", \"file2\"]");
725725

726726
when(apiManager.callAPIFileDownload(
727727
String.format(
728728
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files/operationType/download?file=%s",
729-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1.csv"),
729+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file1"),
730730
"common",
731731
"sample_dataset",
732732
new HashMap<>()))
@@ -735,7 +735,7 @@ public void testDownloadStreamMultipleFiles() throws Exception {
735735
when(apiManager.callAPIFileDownload(
736736
String.format(
737737
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s/files/operationType/download?file=%s",
738-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file2.csv"),
738+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "file2"),
739739
"common",
740740
"sample_dataset",
741741
new HashMap<>()))
@@ -744,8 +744,8 @@ public void testDownloadStreamMultipleFiles() throws Exception {
744744
Map<String, InputStream> response = f.downloadStream("common", "sample_dataset", "20230308", "csv");
745745

746746
assertThat(response.size(), is(equalTo(2)));
747-
assertThat(response.containsKey("file1.csv"), is(true));
748-
assertThat(response.containsKey("file2.csv"), is(true));
747+
assertThat(response.containsKey("file1"), is(true));
748+
assertThat(response.containsKey("file2"), is(true));
749749
}
750750

751751
@Test
@@ -773,14 +773,14 @@ public void testDownloadStreamThrowsExceptionWhenNoFilesFound() throws Exception
773773
public void testDownloadWithProvidedFileList() throws Exception {
774774
Fusion f = stubFusion();
775775

776-
List<String> fileNames = Arrays.asList("custom_file.csv");
776+
List<String> fileNames = Arrays.asList("custom_file");
777777

778778
doNothing()
779779
.when(apiManager)
780780
.callAPIFileDownload(
781781
String.format(
782782
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s?file=%s",
783-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "custom_file.csv"),
783+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "custom_file"),
784784
String.format("%s/%s", TMP_PATH, "custom_file.csv"),
785785
"common",
786786
"sample_dataset",
@@ -792,7 +792,7 @@ public void testDownloadWithProvidedFileList() throws Exception {
792792
.callAPIFileDownload(
793793
String.format(
794794
"%scatalogs/%s/datasets/%s/datasetseries/%s/distributions/%s?file=%s",
795-
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "custom_file.csv"),
795+
config.getRootURL(), "common", "sample_dataset", "20230308", "csv", "custom_file"),
796796
String.format("%s/%s", TMP_PATH, "custom_file.csv"),
797797
"common",
798798
"sample_dataset",

0 commit comments

Comments
 (0)