### Question:
MasterInstrumenter extends CompositeInstrumenter { @Override public boolean instrument(Test test, Recorder recorder, Object target, InstrumentationFilter filter) throws NonInstrumentableTypeException { if (target == null) { throw new NonInstrumentableTypeException("Can't instrument null/None"); } final boolean result = super.instrument(test, recorder, target, filter); if (result) { return true; } throw new NonInstrumentableTypeException("Failed to wrap " + target); } MasterInstrumenter(List<Instrumenter> instrumenters); @Override Object createInstrumentedProxy(Test test,
                                                  Recorder recorder,
                                                  Object target); @Override boolean instrument(Test test,
                                      Recorder recorder,
                                      Object target,
                                      InstrumentationFilter filter); @Override String getDescription();  }### Answer:
@Test public void testInstrument() throws Exception { when(m_instrumenter2.instrument(m_test, m_recorder, m_target, m_filter)) .thenReturn(true); final Instrumenter instrumenter = new MasterInstrumenter(asList(m_instrumenter1, m_instrumenter2)); instrumenter.instrument(m_test, m_recorder, m_target, m_filter); final InOrder inOrder = inOrder(m_instrumenter1, m_instrumenter2); inOrder.verify(m_instrumenter1) .instrument(m_test, m_recorder, m_target, m_filter); inOrder.verify(m_instrumenter2) .instrument(m_test, m_recorder, m_target, m_filter); verifyNoMoreInteractions(m_instrumenter1, m_instrumenter2); }
@Test public void testInstrumentWithNull() throws Exception { final Instrumenter instrumenter = new MasterInstrumenter(asList(m_instrumenter1, m_instrumenter2)); try { instrumenter.instrument(m_test, m_recorder, null, null); fail("Expected NonInstrumentableTypeException"); } catch (NonInstrumentableTypeException e) { } }
@Test public void testCreateInstrumentedFailure() throws Exception { final Instrumenter instrumenter = new MasterInstrumenter(asList(m_instrumenter1, m_instrumenter2)); try { instrumenter.instrument(m_test, m_recorder, m_target, null); fail("Expected NonInstrumentableTypeException"); } catch (NonInstrumentableTypeException e) { } }