diff --git a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSharingService.java b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSharingService.java index 70d223b4..be94c8e0 100644 --- a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSharingService.java +++ b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSharingService.java @@ -34,7 +34,7 @@ public class FileSharingService { public boolean createPhenotypicData(Query query) { AsyncResult result = queryService.getResultFor(query.getId()); - if (result.status != AsyncResult.Status.SUCCESS) { + if (result == null || result.status != AsyncResult.Status.SUCCESS) { return false; } return fileWriter.writeResultToFile("phenotypic_data.tsv", result, query.getPicSureId()); diff --git a/service/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSharingServiceTest.java b/service/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSharingServiceTest.java index 5cdcbe0c..66aec055 100644 --- a/service/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSharingServiceTest.java +++ b/service/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSharingServiceTest.java @@ -33,12 +33,13 @@ public class FileSharingServiceTest { public void shouldCreatePhenotypicData() { Query query = new Query(); query.setId("my-id"); + query.setPicSureId("my-ps-id"); AsyncResult result = new AsyncResult(query, new String[]{}); result.status = AsyncResult.Status.SUCCESS; Mockito.when(queryService.getResultFor("my-id")) .thenReturn(result); - Mockito.when(fileWriter.writeResultToFile("phenotypic_data.tsv", result, "my-id")) + Mockito.when(fileWriter.writeResultToFile("phenotypic_data.tsv", result, "my-ps-id")) .thenReturn(true); boolean actual = subject.createPhenotypicData(query); @@ -50,6 +51,7 @@ public void shouldCreatePhenotypicData() { public void shouldNotCreatePhenotypicData() { Query query = new Query(); query.setId("my-id"); + query.setPicSureId("my-ps-id"); AsyncResult result = new AsyncResult(query, new String[]{}); result.status = AsyncResult.Status.ERROR; @@ -64,7 +66,7 @@ public void shouldNotCreatePhenotypicData() { @Test public void shouldCreateGenomicData() throws IOException { Query query = new Query(); - query.setId("my-id"); + query.setPicSureId("my-id"); String vcf = "lol lets put the whole vcf in a string"; Mockito.when(variantListProcessor.runVcfExcerptQuery(query, true)) .thenReturn(vcf); @@ -79,7 +81,7 @@ public void shouldCreateGenomicData() throws IOException { @Test public void shouldNotCreateGenomicData() throws IOException { Query query = new Query(); - query.setId("my-id"); + query.setPicSureId("my-id"); Mockito.when(variantListProcessor.runVcfExcerptQuery(query, true)) .thenThrow(new IOException("oh no!"));