@Test public void twoPeriodsAreNotEqualIfTheyHaveUnequalCodes() { FinancialPeriod other = new FinancialPeriod(period.getCode() + "Y"); parent.addChild(other); assertNotEquals(period, other); }
@Test public void twoPeriodsAreEqualIfTheyBelongToEqualParentsAndHaveEqualCodes() { FinancialPeriod other = new FinancialPeriod(period.getCode()); parent.addChild(other); assertEquals(period, other); assertEquals(period.hashCode(), other.hashCode()); }
@Test public void twoPeriodsAreNotEqualIfTheyBelongToUnequalParents() { FinancialPeriod other = new FinancialPeriod(period.getCode()); FinancialPeriod otherParent = new FinancialPeriod(parent.getCode() + "X"); otherParent.addChild(other); assertNotEquals(period, other); }
@Test public void aPeriodIsLessThanOtherBasedOnItsCodeCoparison() { FinancialPeriod other = new FinancialPeriod("Q2"); FinancialPeriod otherParent = new FinancialPeriod(parent.getCode()); otherParent.addChild(other); assertThat(period, is(lessThan(other))); }
@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))); }