@Test public void elementMismatch() throws Exception { AtomMatcher matcher = AtomMatcher.forElement(); IAtom atom1 = mock(IAtom.class); IAtom atom2 = mock(IAtom.class); when(atom1.getAtomicNumber()).thenReturn(6); when(atom2.getAtomicNumber()).thenReturn(8); assertFalse(matcher.matches(atom1, atom2)); assertFalse(matcher.matches(atom2, atom1)); }
@Test(expected = NullPointerException.class) public void elementError() throws Exception { AtomMatcher matcher = AtomMatcher.forElement(); IAtom atom1 = mock(IAtom.class); IAtom atom2 = mock(IAtom.class); when(atom1.getAtomicNumber()).thenReturn(null); when(atom2.getAtomicNumber()).thenReturn(null); matcher.matches(atom1, atom2); }
for (int i = 0; i < g1.length; i++) { for (int j = 0; j < g2.length; j++) { if (g1[i].length <= g2[j].length && atomMatcher.matches(container1.getAtom(i), container2.getAtom(j))) { matrix.set(i, j);
@Test public void queryMatch() throws Exception { AtomMatcher matcher = AtomMatcher.forQuery(); IQueryAtom atom1 = mock(IQueryAtom.class); IAtom atom2 = mock(IAtom.class); IAtom atom3 = mock(IAtom.class); when(atom1.matches(atom2)).thenReturn(true); when(atom1.matches(atom3)).thenReturn(false); assertTrue(matcher.matches(atom1, atom2)); assertFalse(matcher.matches(atom1, atom3)); } }
@Test public void elementMatch() throws Exception { AtomMatcher matcher = AtomMatcher.forElement(); IAtom atom1 = mock(IAtom.class); IAtom atom2 = mock(IAtom.class); when(atom1.getAtomicNumber()).thenReturn(6); when(atom2.getAtomicNumber()).thenReturn(6); assertTrue(matcher.matches(atom1, atom2)); assertTrue(matcher.matches(atom2, atom1)); }
@Test public void anyMatch() throws Exception { AtomMatcher matcher = AtomMatcher.forAny(); IAtom atom1 = mock(IAtom.class); IAtom atom2 = mock(IAtom.class); IAtom atom3 = mock(IAtom.class); when(atom1.getAtomicNumber()).thenReturn(6); when(atom2.getAtomicNumber()).thenReturn(7); when(atom3.getAtomicNumber()).thenReturn(8); assertTrue(matcher.matches(atom1, atom2)); assertTrue(matcher.matches(atom2, atom1)); assertTrue(matcher.matches(atom1, atom3)); assertTrue(matcher.matches(atom3, atom1)); assertTrue(matcher.matches(atom2, atom3)); assertTrue(matcher.matches(atom1, null)); assertTrue(matcher.matches(null, null)); }
@Test public void infeasibleAtoms() throws Exception { AtomMatcher mock = mock(AtomMatcher.class); when(mock.matches(any(IAtom.class), any(IAtom.class))).thenReturn(false); VFSubState state = createBenzeneToNaphthalene(mock, mock(BondMatcher.class)); for (int i = 0; i < state.nMax(); i++) { for (int j = 0; j < state.mMax(); j++) { assertFalse(state.feasible(i, j)); } } }
@Test public void infeasibleAtoms() throws Exception { AtomMatcher mock = mock(AtomMatcher.class); when(mock.matches(any(IAtom.class), any(IAtom.class))).thenReturn(false); VFState state = createBenzeneToNaphthalene(mock, mock(BondMatcher.class)); for (int i = 0; i < state.nMax(); i++) { for (int j = 0; j < state.mMax(); j++) { assertFalse(state.feasible(i, j)); } } }
if (!atomMatcher.matches(container1.getAtom(n), container2.getAtom(m))) return false;
if (!atomMatcher.matches(container1.getAtom(n), container2.getAtom(m))) return false;