GeometricDoubleBondEncoderFactory implements StereoEncoderFactory { static GeometricParity geometric(IAtomContainer mol, int l, int r, int l1, int l2, int r1, int r2) { Point2d l2d = mol.getAtom(l).getPoint2d(); Point2d r2d = mol.getAtom(r).getPoint2d(); Point2d l12d = mol.getAtom(l1).getPoint2d(); Point2d l22d = mol.getAtom(l2).getPoint2d(); Point2d r12d = mol.getAtom(r1).getPoint2d(); Point2d r22d = mol.getAtom(r2).getPoint2d(); if (l2d != null && r2d != null && l12d != null && l22d != null && r12d != null && r22d != null) { return new DoubleBond2DParity(l2d, r2d, l12d, l22d, r12d, r22d); } Point3d l3d = mol.getAtom(l).getPoint3d(); Point3d r3d = mol.getAtom(r).getPoint3d(); Point3d l13d = mol.getAtom(l1).getPoint3d(); Point3d r13d = mol.getAtom(r1).getPoint3d(); if (l3d != null && r3d != null && l13d != null && r13d != null) return new DoubleBond3DParity(l3d, r3d, l13d, r13d); return null; }  @Override StereoEncoder create(IAtomContainer container, int[][] graph);  }
@Test public void testGeometric_2D() throws Exception { IAtom l = mock(IAtom.class); IAtom r = mock(IAtom.class); IAtom l1 = mock(IAtom.class); IAtom l2 = mock(IAtom.class); IAtom r1 = mock(IAtom.class); IAtom r2 = mock(IAtom.class); IAtomContainer m = mock(IAtomContainer.class); when(m.getAtom(0)).thenReturn(l); when(m.getAtom(1)).thenReturn(r); when(m.getAtom(2)).thenReturn(l1); when(m.getAtom(3)).thenReturn(l2); when(m.getAtom(4)).thenReturn(r1); when(m.getAtom(5)).thenReturn(r2); when(l.getPoint2d()).thenReturn(new Point2d()); when(r.getPoint2d()).thenReturn(new Point2d()); when(l1.getPoint2d()).thenReturn(new Point2d()); when(l2.getPoint2d()).thenReturn(new Point2d()); when(r1.getPoint2d()).thenReturn(new Point2d()); when(r2.getPoint2d()).thenReturn(new Point2d()); GeometricParity p = geometric(m, 0, 1, 2, 3, 4, 5); assertTrue(p instanceof DoubleBond2DParity); }
@Test public void testGeometric_3D() throws Exception { IAtom l = mock(IAtom.class); IAtom r = mock(IAtom.class); IAtom l1 = mock(IAtom.class); IAtom l2 = mock(IAtom.class); IAtom r1 = mock(IAtom.class); IAtom r2 = mock(IAtom.class); IAtomContainer m = mock(IAtomContainer.class); when(m.getAtom(0)).thenReturn(l); when(m.getAtom(1)).thenReturn(r); when(m.getAtom(2)).thenReturn(l1); when(m.getAtom(3)).thenReturn(l2); when(m.getAtom(4)).thenReturn(r1); when(m.getAtom(5)).thenReturn(r2); when(l.getPoint3d()).thenReturn(new Point3d()); when(r.getPoint3d()).thenReturn(new Point3d()); when(l1.getPoint3d()).thenReturn(new Point3d()); when(l2.getPoint3d()).thenReturn(new Point3d()); when(r1.getPoint3d()).thenReturn(new Point3d()); when(r2.getPoint3d()).thenReturn(new Point3d()); GeometricParity p = geometric(m, 0, 1, 2, 3, 4, 5); assertTrue(p instanceof DoubleBond3DParity); }