Ejemplo n.º 1
0
 @Test
 public void testGetCriterionTypeFromQuery() {
   Query query = new Query();
   CompoundCriterion compoundCriterion1 = new CompoundCriterion();
   CompoundCriterion compoundCriterion2 = new CompoundCriterion();
   compoundCriterion1.getCriterionCollection().add(new GeneNameCriterion());
   compoundCriterion1.getCriterionCollection().add(compoundCriterion2);
   compoundCriterion2.getCriterionCollection().add(new SubjectListCriterion());
   compoundCriterion2.getCriterionCollection().add(new SubjectListCriterion());
   query.setCompoundCriterion(compoundCriterion1);
   assertEquals(1, QueryUtil.getCriterionTypeFromQuery(query, GeneNameCriterion.class).size());
   assertEquals(2, QueryUtil.getCriterionTypeFromQuery(query, SubjectListCriterion.class).size());
   assertEquals(
       0, QueryUtil.getCriterionTypeFromQuery(query, StringComparisonCriterion.class).size());
 }
  /**
   * Unit test setup.
   *
   * @throws Exception on error
   */
  @Before
  public void setUp() throws Exception {
    Platform platform = dao.getPlatform("platformName");
    ReporterList reporterList =
        platform.addReporterList("reporterList", ReporterTypeEnum.DNA_ANALYSIS_REPORTER);

    study = new Study();
    query = new Query();
    query.setCopyNumberPlatform(platform);
    StudySubscription subscription = new StudySubscription();
    subscription.setStudy(study);
    query.setSubscription(subscription);
    StudySubjectAssignment assignment = new StudySubjectAssignment();
    study.getAssignmentCollection().add(assignment);
    SampleAcquisition acquisition = new SampleAcquisition();
    Sample sample = new Sample();
    Array array = new Array();
    array.setPlatform(platform);
    ArrayData arrayData = new ArrayData();
    arrayData.setStudy(study);
    arrayData.setArray(array);
    arrayData.getReporterLists().add(reporterList);
    reporterList.getArrayDatas().add(arrayData);
    arrayData.setSample(sample);
    sample.getSampleAcquisitions().add(acquisition);
    sample.getArrayDataCollection().add(arrayData);
    segmentData = new SegmentData();
    arrayData.getSegmentDatas().add(segmentData);
    segmentData.setArrayData(arrayData);
    acquisition.setSample(sample);
    assignment.getSampleAcquisitionCollection().add(acquisition);
    StudyConfiguration studyConfiguration = new StudyConfiguration();
    studyConfiguration.getGenomicDataSources().add(new GenomicDataSourceConfiguration());
    study.setStudyConfiguration(studyConfiguration);

    when(dao.findMatchingSegmentDatas(
            any(CopyNumberAlterationCriterion.class), any(Study.class), any(Platform.class)))
        .thenReturn(Arrays.asList(segmentData));
    when(dao.findMatchingSegmentDatasByLocation(
            anyListOf(SegmentData.class), any(Study.class), any(Platform.class)))
        .thenReturn(Arrays.asList(segmentData));
  }