/** Ensures that boundaries can be determined correctly based on lower and upper limits. */
  @Test
  public void insideBoundary() {
    CopyNumberAlterationCriterion criterion = new CopyNumberAlterationCriterion();
    CopyNumberAlterationCriterionHandler handler =
        CopyNumberAlterationCriterionHandler.create(criterion);

    criterion.setLowerLimit(2f);
    criterion.setUpperLimit(1f);

    assertFalse(criterion.isInsideBoundaryType());
    assertEquals(
        GenomicCriteriaMatchTypeEnum.MATCH_POSITIVE_OR_NEGATIVE,
        handler.getSegmentValueMatchCriterionType(2f));

    criterion.setLowerLimit(1f);
    criterion.setUpperLimit(2f);
    assertTrue(criterion.isInsideBoundaryType());
    assertEquals(
        GenomicCriteriaMatchTypeEnum.NO_MATCH, handler.getSegmentValueMatchCriterionType(3f));

    criterion.setLowerLimit(3f);
    criterion.setUpperLimit(1f);
    assertFalse(criterion.isInsideBoundaryType());
    assertEquals(
        GenomicCriteriaMatchTypeEnum.MATCH_POSITIVE_OR_NEGATIVE,
        handler.getSegmentValueMatchCriterionType(4f));
  }
  /** Tests for various segment value match criterion. */
  @Test
  public void matchCriterion() {
    CopyNumberAlterationCriterion criterion = new CopyNumberAlterationCriterion();

    CopyNumberAlterationCriterionHandler handler =
        CopyNumberAlterationCriterionHandler.create(criterion);
    assertEquals(
        GenomicCriteriaMatchTypeEnum.MATCH_POSITIVE_OR_NEGATIVE,
        handler.getSegmentValueMatchCriterionType(2f));

    criterion.setLowerLimit(1f);
    assertEquals(
        GenomicCriteriaMatchTypeEnum.MATCH_POSITIVE_OR_NEGATIVE,
        handler.getSegmentValueMatchCriterionType(2f));
    assertEquals(
        GenomicCriteriaMatchTypeEnum.NO_MATCH, handler.getSegmentValueMatchCriterionType(0f));

    criterion.setLowerLimit(null);
    criterion.setUpperLimit(4f);
    assertEquals(
        GenomicCriteriaMatchTypeEnum.MATCH_POSITIVE_OR_NEGATIVE,
        handler.getSegmentValueMatchCriterionType(4f));
    assertEquals(
        GenomicCriteriaMatchTypeEnum.NO_MATCH, handler.getSegmentValueMatchCriterionType(5f));

    criterion.setLowerLimit(2f);
    assertEquals(
        GenomicCriteriaMatchTypeEnum.MATCH_POSITIVE_OR_NEGATIVE,
        handler.getSegmentValueMatchCriterionType(2f));
    assertEquals(
        GenomicCriteriaMatchTypeEnum.NO_MATCH, handler.getSegmentValueMatchCriterionType(1f));
    assertEquals(
        GenomicCriteriaMatchTypeEnum.NO_MATCH, handler.getSegmentValueMatchCriterionType(5f));
  }
 /**
  * Tests segment data retrieval.
  *
  * @throws InvalidCriterionException on unexpected invalid criterion error
  */
 @Test
 public void getSegmentDataMatches() throws InvalidCriterionException {
   CopyNumberAlterationCriterion criterion = new CopyNumberAlterationCriterion();
   CopyNumberAlterationCriterionHandler handler =
       CopyNumberAlterationCriterionHandler.create(criterion);
   Set<SegmentData> segments = handler.getSegmentDataMatches(dao, study, null);
   assertEquals(1, segments.size());
   assertEquals(segmentData, segments.iterator().next());
 }
 /**
  * Tests match retrieval.
  *
  * @throws InvalidCriterionException on unexpected invalid criterion error
  */
 @Test
 public void getMatches() throws InvalidCriterionException {
   CopyNumberAlterationCriterion criterion = new CopyNumberAlterationCriterion();
   CopyNumberAlterationCriterionHandler handler =
       CopyNumberAlterationCriterionHandler.create(criterion);
   Set<ResultRow> rows =
       handler.getMatches(dao, arrayDataService, query, new HashSet<EntityTypeEnum>());
   assertEquals(1, rows.size());
 }
  /** Tests that the handler doesn't attempt to deal with data is should not. */
  @Test
  public void capabilities() {
    CopyNumberAlterationCriterion criterion = new CopyNumberAlterationCriterion();

    CopyNumberAlterationCriterionHandler handler =
        CopyNumberAlterationCriterionHandler.create(criterion);
    assertFalse(handler.hasReporterCriterion());
    assertFalse(handler.isReporterMatchHandler());
    assertTrue(handler.hasCriterionSpecifiedSegmentValues());
    assertFalse(handler.hasCriterionSpecifiedReporterValues());
  }
  /** Tests for handling calls value criterion type. */
  @Test
  public void callsValues() {
    Set<Integer> callsValues = new HashSet<Integer>();
    callsValues.add(1);

    CopyNumberAlterationCriterion criterion = new CopyNumberAlterationCriterion();
    criterion.setCopyNumberCriterionType(CopyNumberCriterionTypeEnum.CALLS_VALUE);
    criterion.setCallsValues(callsValues);

    CopyNumberAlterationCriterionHandler handler =
        CopyNumberAlterationCriterionHandler.create(criterion);

    assertTrue(handler.hasCriterionSpecifiedSegmentValues());
    assertTrue(handler.hasCriterionSpecifiedSegmentCallsValues());
    assertEquals(
        GenomicCriteriaMatchTypeEnum.MATCH_POSITIVE_OR_NEGATIVE,
        handler.getSegmentCallsValueMatchCriterionType(1));
    assertFalse(
        GenomicCriteriaMatchTypeEnum.MATCH_POSITIVE_OR_NEGATIVE.equals(
            handler.getSegmentCallsValueMatchCriterionType(2)));
  }