### Question:
MonthYearRangeGapCalculator { public Period calculateGap(int startYear, int startMonth, int endYear, int endMonth) { int monthDiff = (endYear - startYear) * 12 + (endMonth - startMonth + 1); if (monthDiff <= 2) { return new Period(1, PeriodUnit.DAY); } if (monthDiff <= 12) { return new Period(7, PeriodUnit.DAY); } if (monthDiff <= 60) { return new Period(1, PeriodUnit.MONTH); } if (monthDiff <= 120) { return new Period(6, PeriodUnit.MONTH); } return new Period(1, PeriodUnit.YEAR); }  Period calculateGap(int startYear, int startMonth, int endYear, int endMonth);  }### Answer:
@Test public void calculateGap_DAY() { assertEquals(new Period(1, PeriodUnit.DAY), calculator.calculateGap(2014, 1, 2014, 2)); }
@Test public void calculateGap_WEEK() { assertEquals(new Period(7, PeriodUnit.DAY), calculator.calculateGap(2014, 1, 2014, 3)); assertEquals(new Period(7, PeriodUnit.DAY), calculator.calculateGap(2014, 1, 2014, 12)); }
@Test public void calculateGap_MONTH() { assertEquals(new Period(1, PeriodUnit.MONTH), calculator.calculateGap(2014, 2, 2015, 3)); assertEquals(new Period(1, PeriodUnit.MONTH), calculator.calculateGap(2009, 2, 2014, 1)); }
@Test public void calculateGap_6_MONTHS() { assertEquals(new Period(6, PeriodUnit.MONTH), calculator.calculateGap(2005, 4, 2015, 3)); assertEquals(new Period(6, PeriodUnit.MONTH), calculator.calculateGap(2008, 2, 2013, 2)); }
@Test public void calculateGap_YEAR() { assertEquals(new Period(1, PeriodUnit.YEAR), calculator.calculateGap(2004, 2, 2014, 3)); }