### Question:
XDateRangeConverter implements XRangeConverter { @Override public String convertGap(XRange xRange) { Preconditions.checkNotNull(xRange); Preconditions.checkArgument(isApplicable(xRange.getClass())); XDateRange xDateRange = (XDateRange) xRange; Period gap = xDateRange.getGap(); int gapValue = gap.getValue(); PeriodUnit gapUnit = gap.getUnit(); String periodUnit = PERIOD_UNIT_MAPPINGS.get(gapUnit); if (periodUnit == null) { throw new IllegalArgumentException("PeriodUnit " + gapUnit.name() + " is not supported"); } return "+" + gapValue + periodUnit; }  @Override boolean isApplicable(Class<? extends XRange> clazz); @Override String convertStart(XRange xRange); @Override String convertEnd(XRange xRange); @Override String convertGap(XRange xRange);  }### Answer:
@Test public void convertGap_DAY() { XDateRange xDateRange = new XDateRange(new LocalDate(), new LocalDate(), new Period(2, PeriodUnit.DAY)); String gapParam = xDateRangeConverter.convertGap(xDateRange); assertEquals("+2DAYS", gapParam); }
@Test public void convertGap_14DAYS() { XDateRange xDateRange = new XDateRange(new LocalDate(), new LocalDate(), new Period(14, PeriodUnit.DAY)); String gapParam = xDateRangeConverter.convertGap(xDateRange); assertEquals("+14DAYS", gapParam); }
@Test public void convertGap_MONTH() { XDateRange xDateRange = new XDateRange(new LocalDate(), new LocalDate(), new Period(4, PeriodUnit.MONTH)); String gapParam = xDateRangeConverter.convertGap(xDateRange); assertEquals("+4MONTHS", gapParam); }
@Test public void convertGap_YEAR() { XDateRange xDateRange = new XDateRange(new LocalDate(), new LocalDate(), new Period(1, PeriodUnit.YEAR)); String gapParam = xDateRangeConverter.convertGap(xDateRange); assertEquals("+1YEARS", gapParam); }
@Test(expected = NullPointerException.class) public void convertGap_NULL_XRANGE() { xDateRangeConverter.convertGap(null); }