Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Dec 24, 2023
1 parent b240ab5 commit e589a3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

Expand All @@ -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);
Expand All @@ -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!"));

Expand Down

0 comments on commit e589a3d

Please sign in to comment.