### Question:
DurationUnitsProvider extends AbstractUnitsProvider<Duration> { public Duration getLargestIntegerUnitType(Duration input) { Duration largest = null; for (Class<? extends Duration> type : getAvailableUnits(false)) { try { Duration dur = Duration.create(type, input); BigDecimal durMag = dur.getMagnitude(); if (durMag.stripTrailingZeros().scale() <= 0 && (largest == null || largest.getMagnitude().compareTo(durMag) > 0)) { largest = dur; } } catch (InvalidUnitsException e) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Invalid units encountered: " + e, e); } } catch (InconvertibleUnits e) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Inconvertible encountered: " + e, e); } } } return largest; } DurationUnitsProvider(); @SuppressWarnings("PMD.PreserveStackTrace") void add(Calendar cal, Duration dur); @Override T convert(Class<T> desiredType, Duration from); @Override T fromUnitsAndMagnitude(Class<T> type, Number magnitude); @Override Class<? extends Duration> getDisplayClass(Duration value); Duration getLargestIntegerUnitType(Duration input); @Override String getLongLabel(Class<? extends Duration> type, boolean plural); @Override String getSelectionLabel(Class<? extends Duration> type); @Override String getShortLabel(Class<? extends Duration> type, boolean plural); @Override Class<Duration> getSuperType(); @Override String toShortLabelString(Duration obj);  }### Answer:
@Test public void testGetLargestIntegerUnitType() { DurationUnitsProvider units = new DurationUnitsProvider(); Assert.assertEquals(new Milliseconds(0), units.getLargestIntegerUnitType(new Seconds(0))); Assert.assertEquals(new Seconds(1), units.getLargestIntegerUnitType(new Seconds(1))); Assert.assertEquals(new Seconds(59), units.getLargestIntegerUnitType(new Seconds(59))); Assert.assertEquals(new Minutes(1), units.getLargestIntegerUnitType(new Seconds(60))); Assert.assertEquals(new Minutes(59), units.getLargestIntegerUnitType(new Seconds(59 * 60))); Assert.assertEquals(new Hours(1), units.getLargestIntegerUnitType(new Seconds(60 * 60))); Assert.assertEquals(new Hours(23), units.getLargestIntegerUnitType(new Seconds(23 * 60 * 60))); Assert.assertEquals(new Days(1), units.getLargestIntegerUnitType(new Seconds(24 * 60 * 60))); Assert.assertEquals(new Days(6), units.getLargestIntegerUnitType(new Seconds(6 * 24 * 60 * 60))); Assert.assertEquals(new Weeks(1), units.getLargestIntegerUnitType(new Seconds(7 * 24 * 60 * 60))); Assert.assertEquals(new Seconds(7 * 24 * 60 * 60 - 1), units.getLargestIntegerUnitType(new Seconds(7 * 24 * 60 * 60 - 1))); Assert.assertEquals(new Minutes(7 * 24 * 60 - 1), units.getLargestIntegerUnitType(new Seconds(7 * 24 * 60 * 60 - 60))); Assert.assertEquals(new Hours(7 * 24 - 1), units.getLargestIntegerUnitType(new Seconds(7 * 24 * 60 * 60 - 60 * 60))); Assert.assertEquals(new Days(13), units.getLargestIntegerUnitType(new Seconds(2 * 7 * 24 * 60 * 60 - 60 * 60 * 24))); }