예제 #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)));
  }