### Question:
LengthUnitsProvider extends AbstractUnitsProvider<Length> { @Override public String getSelectionLabel(Class<? extends Length> type) throws InvalidUnitsException { return Length.getSelectionLabel(type); } LengthUnitsProvider(); @Override T convert(Class<T> desiredType, Length source); @Override T fromUnitsAndMagnitude(Class<T> type, Number magnitude); @Override Class<? extends Length> getDisplayClass(Length value); @Override String getLongLabel(Class<? extends Length> type, boolean plural); @Override String getSelectionLabel(Class<? extends Length> type); @Override String getShortLabel(Class<? extends Length> type, boolean plural); @Override Class<Length> getSuperType(); @Override String toShortLabelString(Length obj);  }### Answer:
@Test public void testFromMagnitudeAndSelectionLabel() { Assert.assertEquals(new NauticalMiles(1.), new LengthUnitsProvider().fromMagnitudeAndSelectionLabel(Double.valueOf(1.), Length.getSelectionLabel(NauticalMiles.class))); }
@Test public void testGetAvailableUnitsSelectionLabels() { LengthUnitsProvider units = new LengthUnitsProvider(); String[] expected1 = new String[] { Length.getSelectionLabel(AutoscaleMetric.class), Length.getSelectionLabel(AutoscaleImperial.class), Length.getSelectionLabel(AutoscaleNautical.class), Length.getSelectionLabel(Feet.class), Length.getSelectionLabel(Inches.class), Length.getSelectionLabel(Meters.class), Length.getSelectionLabel(Kilometers.class), Length.getSelectionLabel(NauticalMiles.class), Length.getSelectionLabel(StatuteMiles.class), Length.getSelectionLabel(Yards.class), }; Assert.assertTrue(Arrays.equals(expected1, units.getAvailableUnitsSelectionLabels(true))); String[] expected2 = new String[] { Length.getSelectionLabel(Feet.class), Length.getSelectionLabel(Inches.class), Length.getSelectionLabel(Meters.class), Length.getSelectionLabel(Kilometers.class), Length.getSelectionLabel(NauticalMiles.class), Length.getSelectionLabel(StatuteMiles.class), Length.getSelectionLabel(Yards.class), }; Assert.assertTrue(Arrays.equals(expected2, units.getAvailableUnitsSelectionLabels(false))); }
@Test public void testGetLengthWithSelectionLabel() { Assert.assertEquals(Feet.class, new LengthUnitsProvider().getUnitsWithSelectionLabel(Length.getSelectionLabel(Feet.class))); Assert.assertEquals(Inches.class, new LengthUnitsProvider().getUnitsWithSelectionLabel(Length.getSelectionLabel(Inches.class))); Assert.assertEquals(Meters.class, new LengthUnitsProvider().getUnitsWithSelectionLabel(Length.getSelectionLabel(Meters.class))); Assert.assertEquals(Kilometers.class, new LengthUnitsProvider().getUnitsWithSelectionLabel(Length.getSelectionLabel(Kilometers.class))); Assert.assertEquals(NauticalMiles.class, new LengthUnitsProvider().getUnitsWithSelectionLabel(Length.getSelectionLabel(NauticalMiles.class))); Assert.assertEquals(StatuteMiles.class, new LengthUnitsProvider().getUnitsWithSelectionLabel(Length.getSelectionLabel(StatuteMiles.class))); Assert.assertEquals(Yards.class, new LengthUnitsProvider().getUnitsWithSelectionLabel(Length.getSelectionLabel(Yards.class))); }