@Test
public void testNeighboringChirality() throws Exception {

    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    final IAtomContainer mol = sp.parseSmiles("C[C@H](O)[C@H](O)C");
    List<IStereoElement> stereoElements = new ArrayList<IStereoElement>(FluentIterable.from(mol.stereoElements())
            .toList());
    Collections.sort(stereoElements, new Comparator<IStereoElement>() {
        @Override
        public int compare(IStereoElement o1, IStereoElement o2) {
            return Ints.compare(mol.indexOf(((ITetrahedralChirality) o1).getChiralAtom()),
                    mol.indexOf(((ITetrahedralChirality) o2).getChiralAtom()));
        }
    });
    // first chiral center
    assertThat(stereoElements.size(), is(2));
    IStereoElement stereoElement = stereoElements.get(0);
    Assert.assertNotNull(stereoElement);
    assertTrue(stereoElement instanceof ITetrahedralChirality);
    ITetrahedralChirality l4Chiral = (ITetrahedralChirality) stereoElement;
    Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol());
    IAtom[] ligands = l4Chiral.getLigands();
    for (IAtom atom : ligands)
        Assert.assertNotNull(atom);
    Assert.assertEquals(mol.getAtom(0), ligands[0]);
    Assert.assertEquals(mol.getAtom(1), ligands[1]);
    Assert.assertEquals(mol.getAtom(2), ligands[2]);
    Assert.assertEquals(mol.getAtom(3), ligands[3]);
    Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo());
    // second chiral center
    stereoElement = stereoElements.get(1);
    Assert.assertNotNull(stereoElement);
    assertTrue(stereoElement instanceof ITetrahedralChirality);
    l4Chiral = (ITetrahedralChirality) stereoElement;
    Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol());
    ligands = l4Chiral.getLigands();
    for (IAtom atom : ligands)
        Assert.assertNotNull(atom);
    Assert.assertEquals(mol.getAtom(1), ligands[0]);
    Assert.assertEquals(mol.getAtom(3), ligands[1]);
    Assert.assertEquals(mol.getAtom(4), ligands[2]);
    Assert.assertEquals(mol.getAtom(5), ligands[3]);
    Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo());
}