### Question:
UiySettingsConverter { public YSettings convert(UiySettings uiySettings) { Preconditions.checkNotNull(uiySettings); YSettings ysettings = new YSettings(); YValueType yValueType = new NumberYValue(); if (uiySettings.getValueType().equals(UiyValueType.PERCENT)) { yValueType = new RateYValue(100); } else if (uiySettings.getValueType().equals(UiyValueType.NUMBER_PER_1000)) { yValueType = new RateYValue(1000); } ysettings.setValueType(yValueType); return ysettings; }  YSettings convert(UiySettings uiySettings);  }### Answer:
@Test(expected = NullPointerException.class) public void convert_NULL() { converter.convert(null); }
@Test public void convert_NUMBER() { uiySettings.setValueType(UiyValueType.NUMBER); YSettings ysettings = converter.convert(uiySettings); assertNotNull(ysettings.getValueType()); assertTrue(ysettings.getValueType() instanceof NumberYValue); }
@Test public void convert_PERCENT() { uiySettings.setValueType(UiyValueType.PERCENT); YSettings ysettings = converter.convert(uiySettings); assertNotNull(ysettings.getValueType()); assertTrue(ysettings.getValueType() instanceof RateYValue); assertEquals(100, ((RateYValue)ysettings.getValueType()).getRateRatio()); }
@Test public void convert_NUMBER_PER_1000() { uiySettings.setValueType(UiyValueType.NUMBER_PER_1000); YSettings ysettings = converter.convert(uiySettings); assertNotNull(ysettings.getValueType()); assertTrue(ysettings.getValueType() instanceof RateYValue); assertEquals(1000, ((RateYValue)ysettings.getValueType()).getRateRatio()); }