-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ALS-7581: Implement multiple values per patient in CSV output (#122)
- Loading branch information
Showing
6 changed files
with
100 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
service/src/main/resources/application-integration-test.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
service/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.service; | ||
|
||
import de.siegmar.fastcsv.reader.CsvContainer; | ||
import de.siegmar.fastcsv.reader.CsvReader; | ||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; | ||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.ResultType; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.AsyncResult; | ||
import edu.harvard.hms.dbmi.avillach.hpds.test.util.BuildIntegrationTestEnvironment; | ||
import org.apache.commons.io.IOUtils; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
@ExtendWith(SpringExtension.class) | ||
@EnableAutoConfiguration | ||
@SpringBootTest(classes = edu.harvard.hms.dbmi.avillach.hpds.service.HpdsApplication.class) | ||
@ActiveProfiles("integration-test") | ||
class QueryServiceTest { | ||
|
||
@Autowired | ||
private QueryService queryService; | ||
|
||
@BeforeAll | ||
public static void beforeAll() { | ||
BuildIntegrationTestEnvironment instance = BuildIntegrationTestEnvironment.INSTANCE; | ||
} | ||
|
||
@Test | ||
public void dataframeMulti() throws IOException, InterruptedException { | ||
Query query = new Query(); | ||
List<Query.VariantInfoFilter> variantInfoFilters = new ArrayList<>(); | ||
Query.VariantInfoFilter variantInfoFilter = new Query.VariantInfoFilter(); | ||
variantInfoFilter.categoryVariantInfoFilters = Map.of("Gene_with_variant", new String[]{"LOC102723996", "LOC101928576"}); | ||
variantInfoFilters.add(variantInfoFilter); | ||
query.setVariantInfoFilters(variantInfoFilters); | ||
query.setFields(List.of("\\open_access-1000Genomes\\data\\SYNTHETIC_AGE\\")); | ||
query.setExpectedResultType(ResultType.DATAFRAME); | ||
|
||
AsyncResult asyncResult = queryService.runQuery(query); | ||
|
||
int retries = 0; | ||
while ((AsyncResult.Status.RUNNING.equals(asyncResult.getStatus()) || AsyncResult.Status.PENDING.equals(asyncResult.getStatus())) && retries < 10) { | ||
retries++; | ||
Thread.sleep(200); | ||
} | ||
|
||
assertEquals(AsyncResult.Status.SUCCESS, asyncResult.getStatus()); | ||
CsvReader csvReader = new CsvReader(); | ||
CsvContainer csvContainer = csvReader.read(asyncResult.getFile(), StandardCharsets.UTF_8); | ||
// 22 plus header | ||
assertEquals(23, csvContainer.getRows().size()); | ||
} | ||
|
||
} |