Skip to content

Commit

Permalink
Added a unit test for the sorting of the multiplier
Browse files Browse the repository at this point in the history
Change-Id: If572a12da7e89e80d2e986035c57acff928aeaa8
Signed-off-by: John May <john.wilkinsonmay@gmail.com>
  • Loading branch information
egonw committed Jan 30, 2013
1 parent d48d30d commit ff2d820
Showing 1 changed file with 22 additions and 0 deletions.
Expand Up @@ -469,6 +469,28 @@ public int compare(IAtomContainer o1, IAtomContainer o2) {
Assert.assertEquals(2, som.getAtomContainerCount());
}

@Test
public void testSortAtomContainers_WithMuliplier() {
IAtomContainerSet som = (IAtomContainerSet)newChemObject();
IAtomContainer ac1 = som.getBuilder().newInstance(IAtomContainer.class);
som.addAtomContainer(ac1, 2.0);
ac1.setProperty("multiplierSortCode", "2");
IAtomContainer ac2 = som.getBuilder().newInstance(IAtomContainer.class);
som.addAtomContainer(ac2, 1.0);
ac2.setProperty("multiplierSortCode", "1");
som.sortAtomContainers(new Comparator<IAtomContainer>() {
public int compare(IAtomContainer o1, IAtomContainer o2) {
return ((String)o1.getProperty("multiplierSortCode")).compareTo((String)o2.getProperty("multiplierSortCode"));
}
});
Assert.assertEquals(2, som.getAtomContainerCount());
IAtomContainer newFirstAC = som.getAtomContainer(0);
Assert.assertEquals(newFirstAC.getProperty("multiplierSortCode"), "1");
// OK, sorting worked as intended
// The multiplier should have been resorted too:
Assert.assertEquals(1.0, som.getMultiplier(newFirstAC), 0.00001);
}

private class ChemObjectListenerImpl implements IChemObjectListener {
private boolean changed;

Expand Down

0 comments on commit ff2d820

Please sign in to comment.