use of com.buschmais.jqassistant.core.plugin.api.PluginInfo in project jqa-core-framework by buschmais.
the class PluginRepositoryImplTest method returnedCollectionForTheOverviewIsUnmodifiable.
@Test
void returnedCollectionForTheOverviewIsUnmodifiable() {
PluginConfigurationReader pluginConfigurationReader = Mockito.mock(PluginConfigurationReader.class);
JqassistantPlugin pluginA = Mockito.mock(JqassistantPlugin.class);
JqassistantPlugin pluginB = Mockito.mock(JqassistantPlugin.class);
JqassistantPlugin pluginC = Mockito.mock(JqassistantPlugin.class);
doReturn("jqa.a").when(pluginA).getId();
doReturn("A").when(pluginA).getName();
doReturn("jqa.b").when(pluginB).getId();
doReturn("B").when(pluginB).getName();
doReturn("jqa.c").when(pluginC).getId();
doReturn("C").when(pluginC).getName();
doReturn(Arrays.asList(pluginA, pluginB, pluginC)).when(pluginConfigurationReader).getPlugins();
doReturn(PluginRepositoryImplTest.class.getClassLoader()).when(pluginConfigurationReader).getClassLoader();
PluginRepository pluginRepository = new PluginRepositoryImpl(pluginConfigurationReader);
pluginRepository.initialize();
Collection<PluginInfo> overview = pluginRepository.getPluginOverview();
SoftAssertions.assertSoftly(overviewOfPlugins -> {
overviewOfPlugins.assertThatThrownBy(() -> overview.clear()).isInstanceOf(RuntimeException.class);
overviewOfPlugins.assertThatThrownBy(() -> overview.removeIf(i -> true)).isInstanceOf(RuntimeException.class);
});
}
use of com.buschmais.jqassistant.core.plugin.api.PluginInfo in project jqa-core-framework by buschmais.
the class PluginRepositoryImplTest method allPluginsKnownToThePluginReaderFormThePluginOverview.
@Test
void allPluginsKnownToThePluginReaderFormThePluginOverview() {
PluginConfigurationReader pluginConfigurationReader = Mockito.mock(PluginConfigurationReader.class);
JqassistantPlugin pluginA = Mockito.mock(JqassistantPlugin.class);
JqassistantPlugin pluginB = Mockito.mock(JqassistantPlugin.class);
JqassistantPlugin pluginC = Mockito.mock(JqassistantPlugin.class);
doReturn("jqa.a").when(pluginA).getId();
doReturn("A").when(pluginA).getName();
doReturn("jqa.b").when(pluginB).getId();
doReturn("B").when(pluginB).getName();
doReturn("jqa.c").when(pluginC).getId();
doReturn("C").when(pluginC).getName();
doReturn(Arrays.asList(pluginA, pluginB, pluginC)).when(pluginConfigurationReader).getPlugins();
doReturn(PluginRepositoryImplTest.class.getClassLoader()).when(pluginConfigurationReader).getClassLoader();
PluginRepository pluginRepository = new PluginRepositoryImpl(pluginConfigurationReader);
pluginRepository.initialize();
Collection<PluginInfo> overview = pluginRepository.getPluginOverview();
assertThat(overview).hasSize(3);
assertThat(overview).anyMatch(info -> info.getName().equals("A") && info.getId().equals("jqa.a"));
assertThat(overview).anyMatch(info -> info.getName().equals("B") && info.getId().equals("jqa.b"));
assertThat(overview).anyMatch(info -> info.getName().equals("C") && info.getId().equals("jqa.c"));
}
use of com.buschmais.jqassistant.core.plugin.api.PluginInfo in project jqa-core-framework by buschmais.
the class PluginRepositoryImpl method getPluginOverview.
@Override
public Collection<PluginInfo> getPluginOverview() {
ArrayList<PluginInfo> infos = new ArrayList<>();
pluginConfigurationReader.getPlugins().forEach(plugin -> {
String id = plugin.getId();
String name = plugin.getName();
PluginInfo info = new PluginInfoImpl(id, name);
infos.add(info);
});
return Collections.unmodifiableCollection(infos);
}
Aggregations