FeatureLoader implements IFeatureLoader { @Override public IFeatureStatus loadFeature(final IPath featurePath) throws FeatureLoadException { FeatureStatusImpl status = loadFeature0(featurePath); for (FeatureStatusImpl dependencyStatus : status.getDependencies()) { if (!dependencyStatus.isLoaded()) { throw new FeatureLoadException( MessageFormat.format("Feature ''{0}'' required by ''{1}'' is not loaded.", dependencyStatus.getId(), status.getId())); } } try { preStartProcess(status); status.load(); } catch (ActionExecuteException e) { throw new FeatureLoadException("Error occurred loading the feature.", e); } return status; } FeatureLoader(); @Override IFeatureStatus loadGroup(final IPath groupPath); @Override IFeatureStatus loadFeature(final IPath featurePath); @Override IFeatureStatus getFeatureStatus(final String featureId);  }
@Test public void Should_loadSingleFeature() throws Exception { IPlugin pluginMock1 = mock(IPlugin.class); IPath directoryPathMock = mock(IPath.class); when(queueMock.tryTake()).thenReturn(taskMock).thenReturn(null); when(featureConfigurationMock1.getValue(featureNameFN)).thenReturn("the feature"); when(featureConfigurationMock1.getValue(afterFeaturesFN)).thenReturn(Collections.emptyList()); FeatureLoader featureLoader = new FeatureLoader(); IFeatureStatus status = featureLoader.loadFeature(directoryPathMock); assertSame(featureStatusMock1, status); verify(featureStatusMock1).init(directoryPathMock, featureConfigurationMock1); verifyStatic(times(1)); IOC.resolve(same(featureStatusKey), argsCaptor.capture()); IBiAction loadAction = (IBiAction) argsCaptor.getAllValues().get(1); argsCaptor.getAllValues().clear(); loadAction.execute(featureConfigurationMock1, directoryPathMock); verifyStatic(); IOC.resolve(same(pluginLoaderKey), argsCaptor.capture()); IAction classHandler = (IAction) argsCaptor.getAllValues().get(1); when(pluginCreatorMock.create(same(getClass()), any())).thenReturn(pluginMock1); classHandler.execute(getClass()); verify(pluginMock1).load(); verify(taskMock, times(0)).execute(); ArgumentCaptor<IAction> actionArgumentCaptor = ArgumentCaptor.forClass(IAction.class); verify(featureStatusMock1).whenDone(actionArgumentCaptor.capture()); actionArgumentCaptor.getValue().execute(null); verify(taskMock, times(1)).execute(); }