use of org.icgc.dcc.song.server.model.entity.Donor in project SONG by overture-stack.
the class DonorServiceTest method testUpdateDonor.
@Test
public void testUpdateDonor() {
val studyId = DEFAULT_STUDY_ID;
val info = JsonUtils.fromSingleQuoted("{'test': 'new json'}");
val d = new DonorWithSpecimens();
d.setDonorId("");
d.setDonorSubmitterId("Triangle-Arrow-S");
d.setStudyId(studyId);
d.setDonorGender("male");
val id = service.create(d);
assertThat(id).isEqualTo(d.getDonorId());
val d2 = new Donor();
d2.setDonorId(id);
d2.setDonorSubmitterId("X21-Beta-17");
d2.setStudyId(studyId);
d2.setDonorGender("female");
d2.setInfo(info);
val response = service.update(d2);
assertThat(response).isEqualTo("OK");
val d3 = service.read(id);
assertThat(d3).isEqualToComparingFieldByField(d2);
}
use of org.icgc.dcc.song.server.model.entity.Donor in project SONG by overture-stack.
the class SerializationTest method testDonorToJson.
@Test
public void testDonorToJson() {
val donor = new Donor();
val json = JsonUtils.toJson(donor);
val expected = "{'donorId':'','donorSubmitterId':'','studyId':'','donorGender':''," + "'info':{}}";
val expectedJson = JsonUtils.fromSingleQuoted(expected);
assertThat(json).isEqualTo(expectedJson);
}
use of org.icgc.dcc.song.server.model.entity.Donor in project SONG by overture-stack.
the class StudyWithDonorsServiceTest method testReadWithChildren.
@Test
public void testReadWithChildren() {
// Create random isolated study
val studyId = studyGenerator.createRandomStudy();
// Generate Random SequencingRead analyses
val analysisGenerator = createAnalysisGenerator(studyId, analysisService, randomGenerator);
val numAnalysis = 11;
val analysisMap = Maps.<String, SequencingReadAnalysis>newHashMap();
for (int i = 0; i < numAnalysis; i++) {
val sequencingReadAnalysis = analysisGenerator.createDefaultRandomSequencingReadAnalysis();
analysisMap.put(sequencingReadAnalysis.getAnalysisId(), sequencingReadAnalysis);
}
// Extract expected donors and verify
val expectedDonors = analysisMap.values().stream().flatMap(x -> x.getSample().stream()).map(CompositeEntity::getDonor).collect(toSet());
assertThat(expectedDonors).hasSize(numAnalysis);
assertThat(expectedDonors.stream().map(Donor::getDonorSubmitterId).distinct().count()).isEqualTo(numAnalysis);
assertThat(expectedDonors.stream().filter(x -> x.getStudyId().equals(studyId)).count()).isEqualTo(numAnalysis);
// Extract expected specimens and verify
val expectedSpecimens = analysisMap.values().stream().flatMap(x -> x.getSample().stream()).map(CompositeEntity::getSpecimen).collect(toSet());
assertThat(expectedSpecimens).hasSize(numAnalysis);
assertThat(expectedSpecimens.stream().map(Specimen::getSpecimenSubmitterId).distinct().count()).isEqualTo(numAnalysis);
// Extract expected samples and verify
val expectedSamples = analysisMap.values().stream().flatMap(x -> x.getSample().stream()).collect(toSet());
val expectedSampleSubmitterIds = expectedSamples.stream().map(Sample::getSampleSubmitterId).collect(toSet());
assertThat(expectedSamples).hasSize(numAnalysis);
assertThat(expectedSampleSubmitterIds).hasSize(numAnalysis);
// Run the target method to test, readWithChildren
val studyWithDonors = studyWithDonorsService.readWithChildren(studyId);
// Extract actual donors
val actualDonors = studyWithDonors.getDonors().stream().map(DonorWithSpecimens::createDonor).collect(toSet());
// Extract actual specimens
val actualSpecimens = studyWithDonors.getDonors().stream().map(DonorWithSpecimens::getSpecimens).flatMap(Collection::stream).map(SpecimenWithSamples::getSpecimen).collect(toSet());
// Extract actual samples
val actualSamples = studyWithDonors.getDonors().stream().map(DonorWithSpecimens::getSpecimens).flatMap(Collection::stream).map(SpecimenWithSamples::getSamples).flatMap(Collection::stream).collect(toSet());
val actualSampleSubmitterIds = actualSamples.stream().map(Sample::getSampleSubmitterId).collect(toSet());
// Verify expected donors and actual donors match
assertSetsMatch(expectedDonors, actualDonors);
// Verify expected specimens and actual specimens match
assertSetsMatch(expectedSpecimens, actualSpecimens);
// Verify expected sampleSubmitterIds and actual sampleSubmitterIds match
assertSetsMatch(expectedSampleSubmitterIds, actualSampleSubmitterIds);
}
use of org.icgc.dcc.song.server.model.entity.Donor in project SONG by overture-stack.
the class EntityTest method testDonor.
@Test
public void testDonor() {
val donor1 = new Donor();
donor1.setDonorGender("male");
donor1.setDonorSubmitterId("donorSubmitter1");
donor1.setDonorId("donor1");
donor1.setStudyId("study1");
val donor1_same = Donor.create("donor1", "donorSubmitter1", "study1", "male");
assertEntitiesEqual(donor1, donor1_same, true);
val donor2 = Donor.create("donor2", "donorSubmitter2", "study2", "female");
assertEntitiesNotEqual(donor1, donor2);
donor1.setInfo("key1", "f5c9381090a53c54358feb2ba5b7a3d7");
donor1_same.setInfo("key2", "6329334b-dcd5-53c8-98fd-9812ac386d30");
assertEntitiesNotEqual(donor1, donor1_same);
// Test getters
assertThat(donor1.getStudyId()).isEqualTo("study1");
assertThat(donor1.getDonorGender()).isEqualTo("male");
assertThat(donor1.getDonorSubmitterId()).isEqualTo("donorSubmitter1");
assertThat(donor1.getDonorId()).isEqualTo("donor1");
assertInfoKVPair(donor1, "key1", "f5c9381090a53c54358feb2ba5b7a3d7");
}
use of org.icgc.dcc.song.server.model.entity.Donor in project SONG by overture-stack.
the class SerializationTest method testDonorSettings.
@Test
public void testDonorSettings() {
val donor = new Donor();
donor.setDonorId(null);
val json = JsonUtils.toJson(donor);
System.err.printf("json='%s'\n", json);
val expected = "{'donorId':null,'donorSubmitterId':'','studyId':'','donorGender':''," + "'info':{}}";
val expectedJson = JsonUtils.fromSingleQuoted(expected);
assertThat(json).isEqualTo(expectedJson);
}
Aggregations