use of org.jqassistant.schema.plugin.v1.JqassistantPlugin 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 org.jqassistant.schema.plugin.v1.JqassistantPlugin in project jqa-core-framework by buschmais.
the class AnalyzerPluginRepositoryImpl method initialize.
@Override
public void initialize() {
for (JqassistantPlugin plugin : plugins) {
IdClassListType reportTypes = plugin.getReport();
initializeReportPlugins(reportTypes);
initializeRuleInterpreterPlugins(plugin);
}
}
use of org.jqassistant.schema.plugin.v1.JqassistantPlugin in project jqa-core-framework by buschmais.
the class AnalyzerPluginRepositoryImpl method initializeRuleInterpreterPlugins.
private void initializeRuleInterpreterPlugins(JqassistantPlugin plugin) {
IdClassListType ruleInterpreters = plugin.getRuleInterpreter();
if (ruleInterpreters != null) {
for (IdClassType pluginType : ruleInterpreters.getClazz()) {
RuleInterpreterPlugin ruleInterpreterPlugin = createInstance(pluginType.getValue());
ruleInterpreterPlugin.initialize();
for (String language : ruleInterpreterPlugin.getLanguages()) {
Collection<RuleInterpreterPlugin> plugins = ruleInterpreterPlugins.get(language.toLowerCase());
if (plugins == null) {
plugins = new ArrayList<>();
ruleInterpreterPlugins.put(language.toLowerCase(), plugins);
}
plugins.add(ruleInterpreterPlugin);
}
}
}
}
use of org.jqassistant.schema.plugin.v1.JqassistantPlugin in project jqa-core-framework by buschmais.
the class PluginIdGenerator method apply.
@Override
public JqassistantPlugin apply(JqassistantPlugin plugin) {
if (StringUtils.isBlank(plugin.getId())) {
String name = plugin.getName().toLowerCase();
IntUnaryOperator replacer = i -> (Character.isWhitespace(i)) ? UNDERSCORE : i;
StringBuilder generate = new StringBuilder();
for (int index = 0; index < name.length(); index++) {
int updated = replacer.applyAsInt(name.charAt(index));
int lastChar = getLastChar(generate);
if (!(updated == UNDERSCORE && lastChar == UNDERSCORE)) {
generate.appendCodePoint(updated);
}
}
plugin.setId(generate.toString());
LOGGER.debug("Assigned generated plugin id '{}' to plugin named '{}'", plugin.getName(), plugin.getId());
}
return plugin;
}
use of org.jqassistant.schema.plugin.v1.JqassistantPlugin in project jqa-core-framework by buschmais.
the class ScannerPluginRepositoryImpl method getScopes.
private Map<String, Scope> getScopes(List<JqassistantPlugin> plugins) {
Map<String, Scope> scopes = new HashMap<>();
for (JqassistantPlugin plugin : plugins) {
ClassListType scopeTypes = plugin.getScope();
if (scopeTypes != null) {
for (String scopePluginName : scopeTypes.getClazz()) {
Class<? extends Enum<?>> type = getType(scopePluginName);
for (Enum enumConstant : type.getEnumConstants()) {
Scope scope = (Scope) enumConstant;
String scopeName = scope.getPrefix() + ":" + scope.getName();
scopes.put(scopeName.toLowerCase(), scope);
}
}
}
}
return scopes;
}
Aggregations