@Test
public void atomColorerTest() {

    IAtomContainer cnop = makeSNOPSquare();
    final Map<String, Color> colorMap = new HashMap<String, Color>();
    colorMap.put("S", Color.YELLOW);
    colorMap.put("N", Color.BLUE);
    colorMap.put("O", Color.RED);
    colorMap.put("P", Color.MAGENTA);
    IAtomColorer atomColorer = new IAtomColorer() {
        @Override
        public Color getAtomColor(IAtom atom) {
            String symbol = atom.getSymbol();
            if (colorMap.containsKey(symbol)) {
                return colorMap.get(symbol);
            } else {
                return null;
            }
        }
        @Override
        public Color getAtomColor(IAtom atom, Color defaultColor) {
            Color color = getAtomColor(atom);
            if (color == null) {
                return defaultColor;
            } else {
                return color;
            }
        }
    };
    model.set(AtomColorer.class, atomColorer);
    List<IRenderingElement> elements = getAllSimpleElements(generator, cnop);
    Assert.assertEquals(4, elements.size());
    for (IRenderingElement element : elements) {
        AtomSymbolElement symbolElement = (AtomSymbolElement) unbox(element);
        String symbol = symbolElement.text;
        Assert.assertTrue(colorMap.containsKey(symbol));
        Assert.assertEquals(colorMap.get(symbol), symbolElement.color);
    }
}