### Question:
InitializeReceiverGenerator implements IPlugin { @Override public void load() throws PluginException { try { IBootstrapItem<String> item = new BootstrapItem("InitializeReceiverGenerator"); item .after("IOC") .process( () -> { try { IReceiverGenerator rg = new ReceiverGenerator(this.getClass().getClassLoader()); IOC.register( Keys.getOrAdd(IReceiverGenerator.class.getCanonicalName()), new SingletonStrategy(rg) ); } catch (ResolutionException e) { throw new ActionExecuteException("InitializeReceiverGenerator plugin can't load: can't get InitializeReceiverGenerator key", e); } catch (InvalidArgumentException e) { throw new ActionExecuteException("InitializeReceiverGenerator plugin can't load: can't create strategy", e); } catch (RegistrationException e) { throw new ActionExecuteException("InitializeReceiverGenerator plugin can't load: can't register new strategy", e); } } ); this.bootstrap.add(item); } catch (Throwable e) { throw new PluginException("Could not load 'ReceiverGenerator plugin'", e); } } InitializeReceiverGenerator(final IBootstrap<IBootstrapItem<String>> bootstrap); @Override void load();  }### Answer:
@Test public void checkLoadExecution() throws Exception { Checker checker = new Checker(); checker.item = new BootstrapItem("test"); IBootstrap<IBootstrapItem<String>> bootstrap = mock(IBootstrap.class); List<IBootstrapItem<String>> itemList = new ArrayList<>(); doAnswer(new Answer<Void>() { public Void answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); checker.item = (IBootstrapItem<String>) args[0]; itemList.add(checker.item); return null; } }) .when(bootstrap) .add(any(IBootstrapItem.class)); IPlugin plugin = new InitializeReceiverGenerator(bootstrap); plugin.load(); assertEquals(itemList.size(), 1); IBootstrapItem<String> item = itemList.get(0); item.executeProcess(); IReceiverGenerator rg = IOC.resolve(Keys.getOrAdd(IReceiverGenerator.class.getCanonicalName())); assertNotNull(rg); reset(bootstrap); }
@Test (expected = PluginException.class) public void checkPluginExceptionOnPluginLoad() throws Exception { IBootstrap<IBootstrapItem<String>> bootstrap = mock(IBootstrap.class); IPlugin plugin = new InitializeReceiverGenerator(bootstrap); doThrow(Exception.class).when(bootstrap).add(any(IBootstrapItem.class)); plugin.load(); fail(); }