### Question:
RasterRulesList_DistinctValues extends RasterRulesListColormap implements UniqueValuesRulesListInterface<Double> { @Override public void importColorMap(ColorMap cm) { QuantileBin1D ops = new QuantileBin1D(1.); for (ColorMapEntry cme : cm.getColorMapEntries()) { importValuesLabelsQuantitiesColors(cme); ops.add(getOpacities().get(getOpacities().size() - 1)); } if (ops.median() >= 0 && ops.median() < 1.) setOpacity(ops.median()); else setOpacity(1.); } RasterRulesList_DistinctValues(StyledRasterInterface<?> styledRaster); @Override void applyPalette(JComponent parentGui); @Override void importColorMap(ColorMap cm); Integer addAllValues(AtlasSwingWorker<Integer> sw); @Override boolean addUniqueValue(final Double uniqueValue); Set<Double> getAllUniqueValuesThatAreNotYetIncluded(); void move(int row, int delta); @Override void applyOpacity();  }### Answer:
@Test public void testColorMapImport1() { ColorMap cm = StylingUtil.STYLE_BUILDER.createColorMap(new String[] {"A","B","C"}, new double[] {1,2,3}, new Color[]{Color.red, Color.blue, Color.green}, ColorMap.TYPE_VALUES); RasterRulesList_DistinctValues rl = new RasterRulesList_DistinctValues(styledRaster); rl.importColorMap(cm); assertEquals(3,rl.getValues().size()); assertEquals(3,rl.getLabels().size()); assertEquals(3,rl.getColors().size()); assertEquals(3,rl.getOpacities().size()); assertEquals(3,rl.getNumClasses()); assertEquals(Color.red, rl.getColors().get(0)); assertEquals("C", rl.getLabels().get(2).toString()); testExportAndImport(rl, new RasterRulesList_DistinctValues( styledRaster)); RasterLegendData rld = StyledLayerUtil.generateRasterLegendData(rl.getColorMap(), true,null); assertEquals(3,rld.size()); assertEquals("A",rld.get(1.).toString()); assertEquals("B",rld.get(2.).toString()); assertEquals("C",rld.get(3.).toString()); }