ExplicitConnectionAtom extends SMARTSAtom { @Override public boolean matches(IAtom atom) { return invariants(atom).connectivity() - invariants(atom).totalHydrogenCount() == degree; } ExplicitConnectionAtom(int degree, IChemObjectBuilder builder); @Override boolean matches(IAtom atom);  }
@Test public void matches() throws Exception { ExplicitConnectionAtom matcher = new ExplicitConnectionAtom(2, mock(IChemObjectBuilder.class)); IAtom atom = mock(IAtom.class); when(atom.getProperty(SMARTSAtomInvariants.KEY)).thenReturn( new SMARTSAtomInvariants(mock(IAtomContainer.class), 0, 0, Collections.<Integer> emptySet(), 0, 0, 2, 0)); assertTrue(matcher.matches(atom)); }