コード例 #1
0
  @Test
  public void twoPeriodsAreNotEqualIfTheyHaveUnequalCodes() {

    FinancialPeriod other = new FinancialPeriod(period.getCode() + "Y");
    parent.addChild(other);

    assertNotEquals(period, other);
  }
コード例 #2
0
  @Test
  public void twoPeriodsAreEqualIfTheyBelongToEqualParentsAndHaveEqualCodes() {

    FinancialPeriod other = new FinancialPeriod(period.getCode());
    parent.addChild(other);

    assertEquals(period, other);
    assertEquals(period.hashCode(), other.hashCode());
  }
コード例 #3
0
  @Test
  public void twoPeriodsAreNotEqualIfTheyBelongToUnequalParents() {

    FinancialPeriod other = new FinancialPeriod(period.getCode());
    FinancialPeriod otherParent = new FinancialPeriod(parent.getCode() + "X");
    otherParent.addChild(other);

    assertNotEquals(period, other);
  }
コード例 #4
0
  @Test
  public void aPeriodIsLessThanOtherBasedOnItsCodeCoparison() {

    FinancialPeriod other = new FinancialPeriod("Q2");
    FinancialPeriod otherParent = new FinancialPeriod(parent.getCode());
    otherParent.addChild(other);

    assertThat(period, is(lessThan(other)));
  }
コード例 #5
0
  @Test
  public void twoPeriodsAreEqualUnderTheComparableContractBecauseHaveEqualCodesAtTheSameLevel() {

    FinancialPeriod other = new FinancialPeriod(period.getCode());
    FinancialPeriod otherParent = new FinancialPeriod(parent.getCode());
    otherParent.addChild(other);

    assertThat(period, is(lessThanOrEqualTo(other)));
    assertThat(period, is(greaterThanOrEqualTo(other)));
  }