@Test public void createPanel() throws CatalogDBException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); // DiseasePanel diseasePanel = new DiseasePanel("panel1", "Panel 1", 1, 1, "author", null, "description", Collections.emptyList(), // Arrays.asList(new VariantPanel().setId("variant1"), new VariantPanel().setId("variant2")), // Collections.emptyList(), Collections.emptyList(), null, Collections.emptyMap()); // QueryResult<DiseasePanel> panel = catalogPanelDBAdaptor.insert(studyId, diseasePanel, new QueryOptions()); // assertEquals(1, panel.getNumResults()); }
@Test public void getPanel() throws CatalogDBException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); // DiseasePanel diseasePanel = new DiseasePanel("panel1", "Panel 1", 1, 1, "author", null, "description", Collections.emptyList(), Arrays.asList(new VariantPanel().setId("variant1"), // new VariantPanel().setId("variant2")), Collections.emptyList(), Collections.emptyList(), null, // Collections.emptyMap()); // QueryResult<DiseasePanel> panel = catalogPanelDBAdaptor.insert(studyId, diseasePanel, new QueryOptions()); // QueryResult<DiseasePanel> panel1 = catalogPanelDBAdaptor.get(panel.first().getUid(), new QueryOptions()); // assertEquals(1, panel1.getNumResults()); } }
@Test public void getAllJobTest() throws CatalogDBException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); QueryResult<Job> allJobs = catalogJobDBAdaptor.getAllInStudy(studyId, null); System.out.println(allJobs); }
@Test public void getFileTest() throws CatalogDBException { File file = user3.getProjects().get(0).getStudies().get(0).getFiles().get(0); QueryResult<File> fileQueryResult = catalogFileDBAdaptor.get(file.getUid(), null); System.out.println(fileQueryResult); try { System.out.println(catalogFileDBAdaptor.get(-1, null)); fail("Expected \"FileId not found\" exception"); } catch (CatalogDBException e) { System.out.println(e); } }
@Test public void testCreateIndividual() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); catalogIndividualDBAdaptor.insert(studyId, new Individual(), null); }
@Test public void testCreateIndividualAlreadyExists() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", null, "", null, 1, Collections .emptyList(), null), null); thrown.expect(CatalogDBException.class); //Name already exists catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", null, "", null, 1, Collections .emptyList(), null), null); }
@Test public void testCreateIndividualFatherNotFound() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); thrown.expect(CatalogDBException.class); catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", new Individual().setId("father").setUid(10), null, null, null, null, null, "", null, null, null, "", Collections.emptyList(), false, 1, Collections.emptyList(), Collections.emptyList(), null), null); }
@Test public void testModifyIndividualBadGender() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); thrown.expect(CatalogDBException.class); catalogIndividualDBAdaptor.update(individualId, new ObjectMap("sex", "bad sex"), QueryOptions.empty()); }
@Test public void testModifyIndividualBadFatherId() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); thrown.expect(CatalogDBException.class); catalogIndividualDBAdaptor.update(individualId, new ObjectMap("fatherId", 4000), QueryOptions.empty()); }
@Test public void testGetIndividualNoExists() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Individual individual = new Individual("in1", "An Individual", IndividualProperty.Sex.MALE, "", new Individual .Population(), 1, Collections.emptyList(), null); catalogIndividualDBAdaptor.insert(studyId, individual, null).first(); catalogIndividualDBAdaptor.get(individual.getUid(), null).first(); thrown.expect(CatalogDBException.class); //Id not found catalogIndividualDBAdaptor.get(9999, null); }
@Test public void testModifyIndividual() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); ObjectMap params = new ObjectMap("sex", "MALE"); catalogIndividualDBAdaptor.update(individualId, params, QueryOptions.empty()); Individual individual = catalogIndividualDBAdaptor.get(individualId, null).first(); assertEquals(IndividualProperty.Sex.MALE, individual.getSex()); }
@Ignore @Test public void testModifyIndividualExistingName() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); catalogIndividualDBAdaptor.insert(studyId, new Individual("in2", "in2", IndividualProperty.Sex.UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); thrown.expect(CatalogDBException.class); catalogIndividualDBAdaptor.update(individualId, new ObjectMap("name", "in2"), QueryOptions.empty()); }
@Test public void testGetStudyIdByIndividualId() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual().setStatus(new Status()), null).first().getUid(); long studyIdByIndividualId = catalogIndividualDBAdaptor.getStudyId(individualId); assertEquals(studyId, studyIdByIndividualId); }
@Test public void testGetIndividual() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Individual individual = new Individual("an_individual", "An Individual", IndividualProperty.Sex.MALE, "", new Individual.Population(), 1, Collections.emptyList(), null); individual = catalogIndividualDBAdaptor.insert(studyId, individual, null).first(); Individual individual2 = catalogIndividualDBAdaptor.get(individual.getUid(), null).first(); assertEquals(individual.toString(), individual2.toString()); }
@Test @Ignore public void deleteSampleFail2Test() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long fileId = dbAdaptorFactory.getCatalogFileDBAdaptor().getId(user3.getProjects().get(0).getStudies().get(0).getUid(), "data/file.vcf"); Sample hg0097 = new Sample("HG0097", "1000g", new Individual(), "A description", 1); QueryResult<Sample> createResult = dbAdaptorFactory.getCatalogSampleDBAdaptor().insert(studyId, hg0097, null); dbAdaptorFactory.getCatalogFileDBAdaptor().update(fileId, new ObjectMap(FileDBAdaptor.QueryParams.SAMPLES.key(), createResult.first().getUid()), QueryOptions.empty()); dbAdaptorFactory.getCatalogSampleDBAdaptor().delete(createResult.first().getUid()); }
@Test public void testModifyIndividualNegativeFatherId() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); Individual individual = catalogIndividualDBAdaptor.update(individualId, new ObjectMap(IndividualDBAdaptor.QueryParams.FATHER_UID.key(), -1), QueryOptions.empty()).first(); assertEquals(-1, individual.getFather().getUid()); }
@Test @Ignore // TODO: This should be tested in the sample manager, not here !!! public void deleteSampleFail3Test() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Sample hg0097 = new Sample("HG0097", "1000g", new Individual(), "A description", 1); QueryResult<Sample> createResult = dbAdaptorFactory.getCatalogSampleDBAdaptor().insert(studyId, hg0097, null); dbAdaptorFactory.getCatalogCohortDBAdaptor().insert(studyId, new Cohort("Cohort", Study.Type.COLLECTION, "", "", Collections.singletonList(createResult.first()), 1, null), null); thrown.expect(CatalogDBException.class); dbAdaptorFactory.getCatalogSampleDBAdaptor().delete(createResult.first().getUid()); }
@Test public void deleteJobTest() throws CatalogException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Job job = catalogJobDBAdaptor.insert(new Job("name", user3.getId(), "", "", "", new File().setUid(4), Collections.emptyList(), 1), studyId, null).first(); long jobId = job.getUid(); assertEquals(Job.JobStatus.PREPARED, job.getStatus().getName()); catalogJobDBAdaptor.delete(jobId); thrown.expect(CatalogDBException.class); thrown.expectMessage("not exist"); catalogJobDBAdaptor.get(jobId, QueryOptions.empty()); }
@Test public void SetVisitedJob() throws CatalogException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Job jobBefore = catalogJobDBAdaptor.insert(new Job("name", user3.getId(), "", "", "", new File().setUid(4), Collections.emptyList(), 1), studyId, null).first(); long jobId = jobBefore.getUid(); assertTrue(!jobBefore.isVisited()); ObjectMap params = new ObjectMap(JobDBAdaptor.QueryParams.VISITED.key(), true); catalogJobDBAdaptor.update(jobBefore.getUid(), params, QueryOptions.empty()); Job jobAfter = catalogJobDBAdaptor.get(jobId, null).first(); assertTrue(jobAfter.isVisited()); }
@Test public void createSampleTest() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Sample hg0097 = new Sample("HG0097", "1000g", new Individual(), "A description", 1); QueryResult<Sample> result = dbAdaptorFactory.getCatalogSampleDBAdaptor().insert(studyId, hg0097, null); assertEquals(hg0097.getId(), result.first().getId()); assertEquals(hg0097.getDescription(), result.first().getDescription()); assertTrue(result.first().getUid() > 0); }