CheckValidityAsyncOperationPlugin implements IPlugin { @Override public void load() throws PluginException { try { IBootstrapItem<String> item = new BootstrapItem("CreateCheckValidityAsyncOperationActor"); item .process(() -> { try { IKey operationKey = Keys.getOrAdd(CheckValidityAsyncOperationActor.class.getCanonicalName()); IOC.register(operationKey, new ApplyFunctionToArgumentsStrategy( (args) -> { return new CheckValidityAsyncOperationActor((IObject) args[0]); } )); } catch (ResolutionException e) { throw new ActionExecuteException("CheckValidityAsyncOperationActor plugin can't load: can't get CheckValidityAsyncOperationActor key", e); } catch (InvalidArgumentException e) { throw new ActionExecuteException("CheckValidityAsyncOperationActor plugin can't load: can't create strategy", e); } catch (RegistrationException e) { throw new ActionExecuteException("CheckValidityAsyncOperationActor plugin can't load: can't register new strategy", e); } }); bootstrap.add(item); } catch (InvalidArgumentException e) { throw new PluginException("Can't load CheckValidityAsyncOperation plugin", e); } } CheckValidityAsyncOperationPlugin(final IBootstrap<IBootstrapItem<String>> bootstrap); @Override void load();  }
@Test public void ShouldAddNewItemDuringLoad() throws Exception { BootstrapItem bootstrapItem = Mockito.mock(BootstrapItem.class); PowerMockito.whenNew(BootstrapItem.class).withAnyArguments().thenReturn(bootstrapItem); when(bootstrapItem.after(anyString())).thenReturn(bootstrapItem); when(bootstrapItem.before(anyString())).thenReturn(bootstrapItem); CheckValidityAsyncOperationActor actor = Mockito.mock(CheckValidityAsyncOperationActor.class); PowerMockito.whenNew(CheckValidityAsyncOperationActor.class).withAnyArguments().thenReturn(actor); plugin.load(); PowerMockito.verifyNew(BootstrapItem.class).withArguments("CreateCheckValidityAsyncOperationActor"); ArgumentCaptor<IPoorAction> actionArgumentCaptor = ArgumentCaptor.forClass(IPoorAction.class); verify(bootstrapItem).process(actionArgumentCaptor.capture()); ArgumentCaptor<ApplyFunctionToArgumentsStrategy> createNewInstanceStrategyArgumentCaptor = ArgumentCaptor.forClass(ApplyFunctionToArgumentsStrategy.class); actionArgumentCaptor.getValue().execute(); PowerMockito.verifyStatic(); IOC.register(Mockito.eq(operationKey), createNewInstanceStrategyArgumentCaptor.capture()); verify(bootstrap).add(Mockito.any()); }