Search in sources :

Example 1 with PluginInfo

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);
    });
}
Also used : PluginConfigurationReader(com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader) JqassistantPlugin(org.jqassistant.schema.plugin.v1.JqassistantPlugin) ScannerPluginRepository(com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository) AnalyzerPluginRepository(com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository) PluginRepository(com.buschmais.jqassistant.core.plugin.api.PluginRepository) PluginInfo(com.buschmais.jqassistant.core.plugin.api.PluginInfo) Test(org.junit.jupiter.api.Test)

Example 2 with PluginInfo

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"));
}
Also used : PluginConfigurationReader(com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader) JqassistantPlugin(org.jqassistant.schema.plugin.v1.JqassistantPlugin) ScannerPluginRepository(com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository) AnalyzerPluginRepository(com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository) PluginRepository(com.buschmais.jqassistant.core.plugin.api.PluginRepository) PluginInfo(com.buschmais.jqassistant.core.plugin.api.PluginInfo) Test(org.junit.jupiter.api.Test)

Example 3 with PluginInfo

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);
}
Also used : ArrayList(java.util.ArrayList) PluginInfo(com.buschmais.jqassistant.core.plugin.api.PluginInfo)

Aggregations

PluginInfo (com.buschmais.jqassistant.core.plugin.api.PluginInfo)3 AnalyzerPluginRepository (com.buschmais.jqassistant.core.analysis.spi.AnalyzerPluginRepository)2 PluginConfigurationReader (com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader)2 PluginRepository (com.buschmais.jqassistant.core.plugin.api.PluginRepository)2 ScannerPluginRepository (com.buschmais.jqassistant.core.scanner.spi.ScannerPluginRepository)2 JqassistantPlugin (org.jqassistant.schema.plugin.v1.JqassistantPlugin)2 Test (org.junit.jupiter.api.Test)2 ArrayList (java.util.ArrayList)1