use of org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens in project SONG by overture-stack.
the class DonorServiceTest method testCreateStudyDNE.
@Test
public void testCreateStudyDNE() {
val donor = createRandomDonor();
val donorWithSpecimens = new DonorWithSpecimens();
donorWithSpecimens.setDonor(donor);
assertSongError(() -> service.create(donorWithSpecimens), STUDY_ID_DOES_NOT_EXIST);
}
use of org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens in project SONG by overture-stack.
the class DonorServiceTest method testReadByParentId.
@Test
public void testReadByParentId() {
val studyGenerator = createStudyGenerator(studyService, randomGenerator);
val studyId = studyGenerator.createRandomStudy();
val numDonors = 7;
val donorIdSet = Sets.<String>newHashSet();
for (int i = 0; i < numDonors; i++) {
val d = new DonorWithSpecimens();
d.setDonorGender("male");
d.setStudyId(studyId);
d.setDonorSubmitterId(randomGenerator.generateRandomUUIDAsString());
val donorId = service.create(d);
donorIdSet.add(donorId);
}
val donors = service.readByParentId(studyId);
assertThat(donors).hasSize(numDonors);
assertThat(donors.stream().map(Donor::getDonorId).collect(toSet())).containsAll(donorIdSet);
}
use of org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens 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.composites.DonorWithSpecimens in project SONG by overture-stack.
the class DonorServiceTest method testDeleteByParentId.
@Test
public void testDeleteByParentId() {
val studyGenerator = createStudyGenerator(studyService, randomGenerator);
val randomStudyId = studyGenerator.createRandomStudy();
val d1 = new DonorWithSpecimens();
d1.setDonorId("");
d1.setDonorSubmitterId(randomGenerator.generateRandomUUIDAsString());
d1.setStudyId(randomStudyId);
d1.setDonorGender("female");
val id1 = service.create(d1);
d1.setDonorId(id1);
val d2 = new DonorWithSpecimens();
d2.setDonorId("");
d2.setDonorSubmitterId(randomGenerator.generateRandomUUIDAsString());
d2.setStudyId(randomStudyId);
d2.setDonorGender("male");
val id2 = service.create(d2);
d2.setDonorId(id2);
val actualDonorWithSpecimens = service.readByParentId(randomStudyId);
assertThat(actualDonorWithSpecimens).contains(d1, d2);
val response = service.deleteByParentId(randomStudyId);
assertThat(response).isEqualTo("OK");
val emptyDonorWithSpecimens = service.readByParentId(randomStudyId);
assertThat(emptyDonorWithSpecimens).isEmpty();
}
use of org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens in project SONG by overture-stack.
the class EntityTest method testDonorWithSpecimens.
@Test
public void testDonorWithSpecimens() {
val specimen1 = Specimen.create("mySpecimen1", "mySpecimenSubmitter1", "myDonor1", SPECIMEN_CLASSES.get(2), SPECIMEN_TYPES.get(2));
val specimen2 = Specimen.create("mySpecimen2", "mySpecimenSubmitter2", "myDonor2", SPECIMEN_CLASSES.get(1), SPECIMEN_TYPES.get(1));
val sample11 = Sample.create("mySample11", "mySubmitterSample11", "mySpecimen11", SAMPLE_TYPES.get(2));
val sample12 = Sample.create("mySample12", "mySubmitterSample12", "mySpecimen12", SAMPLE_TYPES.get(2));
val sampleGroup1 = newArrayList(sample11, sample12);
val sample21 = Sample.create("mySample21", "mySubmitterSample21", "mySpecimen21", SAMPLE_TYPES.get(3));
val sample22 = Sample.create("mySample22", "mySubmitterSample22", "mySpecimen22", SAMPLE_TYPES.get(3));
val sampleGroup2 = newArrayList(sample21, sample22);
val specimenWithSample1 = new SpecimenWithSamples();
specimenWithSample1.setSpecimen(specimen1);
specimenWithSample1.setSamples(sampleGroup1);
val specimenWithSample2 = new SpecimenWithSamples();
specimenWithSample2.setSpecimen(specimen2);
specimenWithSample2.setSamples(sampleGroup2);
val specimenWSampleGroup1 = newArrayList(specimenWithSample1, specimenWithSample2);
val specimenWSampleGroup2 = newArrayList(specimenWithSample1);
val donor1 = Donor.create("myDonor1", "myDonorSubmitter1", DEFAULT_STUDY_ID, "male");
val donor2 = Donor.create("myDonor2", "myDonorSubmitter2", DEFAULT_STUDY_ID, "female");
val d1 = new DonorWithSpecimens();
d1.setDonorGender(donor1.getDonorGender());
d1.setDonorId(donor1.getDonorId());
d1.setDonorSubmitterId(donor1.getDonorSubmitterId());
d1.setStudyId(donor1.getStudyId());
val d2 = new DonorWithSpecimens();
d2.setDonor(donor1);
assertEntitiesEqual(d1, d2, true);
// 00 - matchingDonors=0 matchingSpecimenGroups=0
d1.setDonor(donor1);
d1.setSpecimens(specimenWSampleGroup1);
d2.setDonor(donor2);
d2.setSpecimens(specimenWSampleGroup2);
assertEntitiesNotEqual(d1, d2);
// 01 - matchingDonors=0 matchingSpecimenGroups=1
d1.setDonor(donor1);
d1.setSpecimens(specimenWSampleGroup1);
d2.setDonor(donor2);
d2.setSpecimens(specimenWSampleGroup1);
assertEntitiesNotEqual(d1, d2);
// 10 - matchingDonors=1 matchingSpecimenGroups=0
d1.setDonor(donor1);
d1.setSpecimens(specimenWSampleGroup1);
d2.setDonor(donor1);
d2.setSpecimens(specimenWSampleGroup2);
assertEntitiesNotEqual(d1, d2);
// 11 - matchingDonors=1 matchingSpecimenGroups=1
d1.setDonor(donor1);
d1.setSpecimens(specimenWSampleGroup1);
d2.setDonor(donor1);
d2.setSpecimens(specimenWSampleGroup1);
assertEntitiesEqual(d1, d2, true);
d1.setInfo("key1", "f5c9381090a53c54358feb2ba5b7a3d7");
d2.setInfo("key2", "6329334b-dcd5-53c8-98fd-9812ac386d30");
assertEntitiesNotEqual(d1, d2);
// Test getters
assertThat(d1.getDonorGender()).isEqualTo(donor1.getDonorGender());
assertThat(d1.getDonorSubmitterId()).isEqualTo(donor1.getDonorSubmitterId());
assertThat(d1.getDonorId()).isEqualTo(donor1.getDonorId());
assertThat(d1.getStudyId()).isEqualTo(donor1.getStudyId());
assertThat(d1.getSpecimens()).containsExactlyInAnyOrder(specimenWithSample1, specimenWithSample2);
assertThat(d1.createDonor()).isNotEqualTo(donor1);
assertInfoKVPair(d1, "key1", "f5c9381090a53c54358feb2ba5b7a3d7");
}
Aggregations