### Question:
OpacityColorAdapter extends IntegerModel implements Service { private static int toOpacityPercent(int alpha) { return Math.round(alpha / OPACITY_FACTOR); } OpacityColorAdapter(ColorModel colorModel); @Override void open(); @Override void close(); @Override boolean set(Integer value, boolean forceFire);  }### Answer:
@Test public void testToOpacityPercent() { ColorModel colorModel = new ColorModel(); colorModel.set(Color.BLACK); try (OpacityColorAdapter opacityModel = new OpacityColorAdapter(colorModel)) { Assert.assertEquals(100, opacityModel.get().intValue()); opacityModel.open(); colorModel.set(Color.WHITE); Assert.assertEquals(100, opacityModel.get().intValue()); colorModel.set(new Color(255, 255, 255, 0)); Assert.assertEquals(0, opacityModel.get().intValue()); colorModel.set(new Color(255, 255, 255, 127)); Assert.assertEquals(50, opacityModel.get().intValue()); opacityModel.set(Integer.valueOf(75)); Assert.assertEquals(191, colorModel.get().getAlpha()); } }