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