ColorConverter { public static Color toColor(RemoteColor remoteColor) { if (remoteColor == null) { return null; } if (isRGB(remoteColor)) { return new Color(remoteColor.getRed(), remoteColor.getGreen(), remoteColor.getBlue()); } else if (isRGBA(remoteColor)) { return new Color(remoteColor.getRed(), remoteColor.getGreen(), remoteColor.getBlue(), remoteColor.getAlpha()); } return null; } private  ColorConverter(); static RemoteColor toRemoteColor(Color color); static Color toColor(RemoteColor remoteColor);  }
@Test public void convertNotValid() { RemoteColor remoteColor = new RemoteColor(-1, 10, 10); assertThrows(IllegalArgumentException.class, () -> ColorConverter.toColor(remoteColor)); RemoteColor remoteColorWithAlpha = new RemoteColor(10, 10, 10, -1); assertThrows(IllegalArgumentException.class, () -> ColorConverter.toColor(remoteColorWithAlpha)); }