Search in sources :

Example 1 with DonorWithSpecimens

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);
}
Also used : lombok.val(lombok.val) DonorWithSpecimens(org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with DonorWithSpecimens

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);
}
Also used : lombok.val(lombok.val) DonorWithSpecimens(org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with DonorWithSpecimens

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);
}
Also used : lombok.val(lombok.val) Donor(org.icgc.dcc.song.server.model.entity.Donor) DonorWithSpecimens(org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with DonorWithSpecimens

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();
}
Also used : lombok.val(lombok.val) DonorWithSpecimens(org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with DonorWithSpecimens

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");
}
Also used : lombok.val(lombok.val) DonorWithSpecimens(org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens) SpecimenWithSamples(org.icgc.dcc.song.server.model.entity.composites.SpecimenWithSamples) Test(org.junit.Test)

Aggregations

lombok.val (lombok.val)14 DonorWithSpecimens (org.icgc.dcc.song.server.model.entity.composites.DonorWithSpecimens)14 Test (org.junit.Test)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 SpecimenWithSamples (org.icgc.dcc.song.server.model.entity.composites.SpecimenWithSamples)3 Collectors.toSet (java.util.stream.Collectors.toSet)2 Donor (org.icgc.dcc.song.server.model.entity.Donor)2 Maps (com.google.common.collect.Maps)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 Collection (java.util.Collection)1 Set (java.util.Set)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 RandomGenerator (org.icgc.dcc.song.core.utils.RandomGenerator)1 RandomGenerator.createRandomGenerator (org.icgc.dcc.song.core.utils.RandomGenerator.createRandomGenerator)1 SequencingReadAnalysis (org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis)1 Sample (org.icgc.dcc.song.server.model.entity.Sample)1 Specimen (org.icgc.dcc.song.server.model.entity.Specimen)1 CompositeEntity (org.icgc.dcc.song.server.model.entity.composites.CompositeEntity)1 StudyWithDonors (org.icgc.dcc.song.server.model.entity.composites.StudyWithDonors)1