@Test public void testChangeMethod() { final StealingMethod initialMethod = mock(StealingMethod.class); final HalflingThief thief = new HalflingThief(initialMethod); thief.steal(); verify(initialMethod).steal(); final StealingMethod newMethod = mock(StealingMethod.class); thief.changeMethod(newMethod); thief.steal(); verify(newMethod).steal(); verifyNoMoreInteractions(initialMethod, newMethod); }
public void changeMethod(StealingMethod method) { this.method = method; }
HalflingThief { public void changeMethod(StealingMethod method) { this.method = method; } }
HalflingThief { public void changeMethod(StealingMethod method) { this.method = method; } HalflingThief(StealingMethod method); }
HalflingThief { public void changeMethod(StealingMethod method) { this.method = method; } HalflingThief(StealingMethod method); void steal(); void changeMethod(StealingMethod method); }
HalflingThief { public void changeMethod(StealingMethod method) { this.method = method; } HalflingThief(StealingMethod method); void steal(); void changeMethod(StealingMethod method);  }