ColorimetricColor { public ColorSlice getSlice(ColorReferenceSystem crs) { ColorSlice sliceColor = null; if (crs != null) { List<ColorWheel> wheels = crs.getWheels(); for (ColorWheel wheel : wheels) { List<ColorSlice> slices = wheel.getSlices(); for (ColorSlice slice : slices) { List<ColorimetricColor> colors = slice.getColors(); for (ColorimetricColor color : colors) { if (this.equals(color)) { sliceColor = slice; } } } } } return sliceColor; } ColorimetricColor();  ColorimetricColor(int idColor);  ColorimetricColor(String hue, int lightness);  ColorimetricColor(String usualName);  ColorimetricColor(int r, int g, int b);  ColorimetricColor(int r, int g, int b, boolean reference);  ColorimetricColor(Color c);  ColorimetricColor(Color c, boolean reference);  ColorimetricColor(float l, float a, float b);  ColorimetricColor(float[] lab); int getIdColor(); void setIdColor(int id); String getHue(); void setHue(String hue); ColorSlice getSlice(ColorReferenceSystem crs); ColorWheel getWheel(ColorReferenceSystem crs); int getLightness(); void setLightness(int lightness); void setSaturation(int saturation); String getUsualName(); void setUsualName(String usualName); String getCleCoul(); void setCleCoul(String cleCoul); int getRedRGB(); void setRedRGB(int redRGB); int getGreenRGB(); void setGreenRGB(int greenRGB); int getBlueRGB(); void setBlueRGB(int blueRGB); int getXScreen(); void setXScreen(int x); int getYScreen(); void setYScreen(int y); Color toColor(); float[] toXYZ(); static float[] toXYZ(float[] lab); float[] getLab(); static float f(float t); float getCIELabL(); float getCIELabA(); float getCIELabB(); double getCIEChroma(); double getCIEHue(); static boolean labExistance(float l, float a, float b); void setL(float l); void setA(float a); void setB(float b); boolean equals(ColorimetricColor c); float maxRGB(); static float distanceCIElab(ColorimetricColor c1, ColorimetricColor c2); static float distanceRVB(ColorimetricColor c1, ColorimetricColor c2); static float CIELab_Lightness_Difference(ColorimetricColor c1,
      ColorimetricColor c2); static double CIELCh_Chroma_Difference(ColorimetricColor c1,
      ColorimetricColor c2); static double CIELCh_Hue_Difference(ColorimetricColor c1,
      ColorimetricColor c2); @Override String toString(); static void basicColorsComponents();  }
@Test public final void testGetSlice() { logger.info("--------------------------------------------------------------------------------------------------------------"); logger.info("Test method getSlice(ColorReferenceSystem)"); logger.info(" Test 1.1 : ColorReferenceSystem is null. "); ColorimetricColor cResult = new ColorimetricColor(); assertNull("ColorSlice is not null ", cResult.getSlice(null)); logger.info(" Test 1.2 : ColorReferenceSystem exist but is empty. "); cResult = new ColorimetricColor(); ColorReferenceSystem crsZeroWheels = new ColorReferenceSystem(); assertNull("ColorSlice is not null ", cResult.getSlice(crsZeroWheels)); logger.info(" Test 1.3 : ColorReferenceSystem without wheels"); cResult = new ColorimetricColor(); crsZeroWheels = new ColorReferenceSystem(); List<ColorWheel> wheels = new ArrayList<ColorWheel>(); crsZeroWheels.setWheels(wheels); assertNull("ColorSlice is not null ", cResult.getSlice(crsZeroWheels)); logger.info(" Test 1.4 : ColorReferenceSystem : each wheels has not got slices"); List<ColorSlice> slices = new ArrayList<ColorSlice>(); ColorWheel colorWheel = new ColorWheel(); colorWheel.setSlices(slices); wheels = new ArrayList<ColorWheel>(); wheels.add(colorWheel); cResult = new ColorimetricColor(); crsZeroWheels = new ColorReferenceSystem(); crsZeroWheels.setWheels(wheels); assertNull("ColorSlice is not null ", cResult.getSlice(crsZeroWheels)); logger.info(" Test 1.5 : ColorReferenceSystem : each slices of each wheels has not got colors"); ColorSlice colorSlice = new ColorSlice(); slices = new ArrayList<ColorSlice>(); slices.add(colorSlice); colorWheel = new ColorWheel(); colorWheel.setSlices(slices); wheels = new ArrayList<ColorWheel>(); wheels.add(colorWheel); cResult = new ColorimetricColor(); crsZeroWheels = new ColorReferenceSystem(); crsZeroWheels.setWheels(wheels); assertNull("ColorSlice is not null ", cResult.getSlice(crsZeroWheels)); logger.info(" Test 2 : ColorReferenceSystem with one color"); colorSlice = new ColorSlice(); colorSlice.setHue("ROUGE GRIS"); colorSlice.setIdSaturationParentWheel(0); List<ColorimetricColor> justDefaultColorimetricList = new ArrayList<ColorimetricColor>(); justDefaultColorimetricList.add(new ColorimetricColor()); colorSlice.setColors(justDefaultColorimetricList); colorWheel = new ColorWheel(); slices = new ArrayList<ColorSlice>(); slices.add(colorSlice); colorWheel.setSlices(slices); colorWheel.setidSaturation(0); crsZeroWheels = new ColorReferenceSystem(); wheels = new ArrayList<ColorWheel>(); wheels.add(colorWheel); crsZeroWheels.setWheels(wheels); cResult = new ColorimetricColor(); assertNotNull("ColorSlice is not null ", cResult.getSlice(crsZeroWheels)); logger.info(" Test 3 : COGIT ColorReferenceSystem"); ColorReferenceSystem COGITcrs = ColorReferenceSystem .unmarshall(this.getClass().getClassLoader().getResourceAsStream("color/ColorReferenceSystem.xml")); logger.info(" Test 3.1 : JAUNE"); List<ColorimetricColor> colorsExpected = new ArrayList<ColorimetricColor>(); colorsExpected.add(new ColorimetricColor("JAUNE TRES CLAIR")); colorsExpected.add(new ColorimetricColor("JAUNE CLAIR")); colorsExpected.add(new ColorimetricColor("JAUNE MOYEN CLAIR")); colorsExpected.add(new ColorimetricColor("JAUNE PUR")); colorsExpected.add(new ColorimetricColor("JAUNE MOYEN FONCE")); colorsExpected.add(new ColorimetricColor("JAUNE FONCE")); colorsExpected.add(new ColorimetricColor("JAUNE TRES FONCE")); cResult = COGITcrs.getAllColors().get(1); assertEquals("Compare hue. ", "JAUNE", cResult.getSlice(COGITcrs).getHue()); assertEquals("Compare idSaturationParentWheel. ", 0, cResult.getSlice(COGITcrs).getIdSaturationParentWheel()); compareColorimetricColorList(colorsExpected, cResult.getSlice(COGITcrs).getColors()); cResult = new ColorimetricColor(1); assertEquals("Compare hue. ", "JAUNE", cResult.getSlice(COGITcrs).getHue()); assertEquals("Compare idSaturationParentWheel. ", 0, cResult.getSlice(COGITcrs).getIdSaturationParentWheel()); compareColorimetricColorList(colorsExpected, cResult.getSlice(COGITcrs).getColors()); cResult = new ColorimetricColor(2); assertEquals("Compare hue. ", "JAUNE", cResult.getSlice(COGITcrs).getHue()); assertEquals("Compare idSaturationParentWheel. ", 0, cResult.getSlice(COGITcrs).getIdSaturationParentWheel()); compareColorimetricColorList(colorsExpected, cResult.getSlice(COGITcrs).getColors()); cResult = new ColorimetricColor(7); assertEquals("Compare hue. ", "JAUNE", cResult.getSlice(COGITcrs).getHue()); assertEquals("Compare idSaturationParentWheel. ", 0, cResult.getSlice(COGITcrs).getIdSaturationParentWheel()); compareColorimetricColorList(colorsExpected, cResult.getSlice(COGITcrs).getColors()); cResult = new ColorimetricColor("JAUNE TRES FONCE"); assertEquals("Compare hue. ", "JAUNE", cResult.getSlice(COGITcrs).getHue()); assertEquals("Compare idSaturationParentWheel. ", 0, cResult.getSlice(COGITcrs).getIdSaturationParentWheel()); compareColorimetricColorList(colorsExpected, cResult.getSlice(COGITcrs).getColors()); logger.info(" Test 3.2 : ORANGE GRIS"); colorsExpected = new ArrayList<ColorimetricColor>(); colorsExpected.add(new ColorimetricColor("ORANGE GRIS TRES CLAIR")); colorsExpected.add(new ColorimetricColor("ORANGE GRIS MOYEN CLAIR")); colorsExpected.add(new ColorimetricColor("ORANGE GRIS MOYEN FONCE")); colorsExpected.add(new ColorimetricColor("ORANGE GRIS TRES FONCE")); cResult = new ColorimetricColor(129); assertEquals("", "ORANGE GRIS", cResult.getSlice(COGITcrs).getHue()); assertEquals("", 1, cResult.getSlice(COGITcrs).getIdSaturationParentWheel()); cResult = new ColorimetricColor(130); assertEquals("", "ORANGE GRIS", cResult.getSlice(COGITcrs).getHue()); assertEquals("", 1, cResult.getSlice(COGITcrs).getIdSaturationParentWheel()); cResult = new ColorimetricColor(131); assertEquals("", "ORANGE GRIS", cResult.getSlice(COGITcrs).getHue()); assertEquals("", 1, cResult.getSlice(COGITcrs).getIdSaturationParentWheel()); cResult = new ColorimetricColor("ORANGE GRIS TRES CLAIR"); assertEquals("", "ORANGE GRIS", cResult.getSlice(COGITcrs).getHue()); assertEquals("", 1, cResult.getSlice(COGITcrs).getIdSaturationParentWheel()); }