@Test(expectedExceptions = NullPointerException.class) public void nullClass() { try { when(classType.hasInstrumentationPoints()).thenReturn(false); applier.removeInstrumentationPoints(null); } finally { verifyZeroInteractions(classType, methodType); } } }
@Test public void noInstrumentationPoints() { when(classType.hasInstrumentationPoints()).thenReturn(false); boolean result = applier.removeInstrumentationPoints(classType); assertThat(result, is(false)); verify(classType).hasInstrumentationPoints(); verifyNoMoreInteractions(classType); }
@Test public void removeInstrumentationPoints() { when(classType.hasInstrumentationPoints()).thenReturn(true); when(classType.getMethods()).thenReturn(Sets.newHashSet(methodType)); boolean result = applier.removeInstrumentationPoints(classType); assertThat(result, is(true)); verify(classType).hasInstrumentationPoints(); verify(classType).getMethods(); verify(methodType).setMethodInstrumentationConfig(null); verifyNoMoreInteractions(classType, methodType); }