private void computeVariation(Resource resource, DecoratorContext context, PastSnapshot pastSnapshot) {
List<Object[]> pastMeasures = pastMeasuresLoader.getPastMeasures(resource, pastSnapshot);
- compareWithPastMeasures(resource, context, pastSnapshot.getIndex(), pastMeasures);
+ compareWithPastMeasures(context, pastSnapshot.getIndex(), pastMeasures);
}
- void compareWithPastMeasures(Resource resource, DecoratorContext context, int index, List<Object[]> pastMeasures) {
+ private void compareWithPastMeasures(DecoratorContext context, int index, List<Object[]> pastMeasures) {
Map<MeasureKey, Object[]> pastMeasuresByKey = Maps.newHashMap();
for (Object[] pastMeasure : pastMeasures) {
pastMeasuresByKey.put(new MeasureKey(pastMeasure), pastMeasure);
public static class BatchMediumTesterBuilder {
private final FakeGlobalReferentialsLoader globalRefProvider = new FakeGlobalReferentialsLoader();
private final FakeProjectReferentialsLoader projectRefProvider = new FakeProjectReferentialsLoader();
- private final FackPluginsReferential pluginsReferential = new FackPluginsReferential();
+ private final FakePluginsReferential pluginsReferential = new FakePluginsReferential();
private final Map<String, String> bootstrapProperties = new HashMap<String, String>();
public BatchMediumTester build() {
}
}
- private static class FackPluginsReferential implements PluginsReferential {
+ private static class FakePluginsReferential implements PluginsReferential {
private List<RemotePlugin> pluginList = new ArrayList<RemotePlugin>();
private Map<RemotePlugin, File> pluginFiles = new HashMap<RemotePlugin, File>();
return pluginFiles.get(remote);
}
- public FackPluginsReferential addPlugin(String pluginKey, File location) {
+ public FakePluginsReferential addPlugin(String pluginKey, File location) {
RemotePlugin plugin = new RemotePlugin(pluginKey, false);
pluginList.add(plugin);
pluginFiles.put(plugin, location);
return this;
}
- public FackPluginsReferential addPlugin(String pluginKey, SonarPlugin pluginInstance) {
- localPlugins.put(DefaultPluginMetadata.create(null).setKey(pluginKey), pluginInstance);
+ public FakePluginsReferential addPlugin(String pluginKey, SonarPlugin pluginInstance) {
+ localPlugins.put(DefaultPluginMetadata.create(pluginKey), pluginInstance);
return this;
}
return new DefaultPluginMetadata().setFile(file);
}
+ public static DefaultPluginMetadata create(String key) {
+ return new DefaultPluginMetadata().setKey(key);
+ }
+
public File getFile() {
return file;
}
RemotePlugin result = new RemotePlugin(fields[0], Boolean.parseBoolean(fields[1]));
if (fields.length > 2) {
String[] nameAndHash = StringUtils.split(fields[2], "|");
- result.setFile(nameAndHash[0], nameAndHash.length > 1 ? nameAndHash[1] : null);
+ result.setFile(nameAndHash[0], nameAndHash[1]);
}
return result;
}
}
public RemotePlugin setFile(File f) {
- return this.setFile(f.getName(), f.exists() ? new FileHashes().of(f) : null);
+ return this.setFile(f.getName(), new FileHashes().of(f));
}
public RemotePluginFile file() {
public void testGettersAndSetters() {
DefaultPluginMetadata metadata = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar"));
metadata.setKey("checkstyle")
- .setParent("java")
- .setLicense("LGPL")
- .setDescription("description")
- .setHomepage("http://home")
- .setIssueTrackerUrl("http://jira.codehuas.org")
- .setMainClass("org.Main")
- .setOrganization("SonarSource")
- .setOrganizationUrl("http://sonarsource.org")
- .setVersion("1.1")
- .setSonarVersion("3.0")
- .setUseChildFirstClassLoader(true)
- .setCore(false)
- .setImplementationBuild("abcdef");
+ .setParent("java")
+ .setLicense("LGPL")
+ .setDescription("description")
+ .setHomepage("http://home")
+ .setIssueTrackerUrl("http://jira.codehuas.org")
+ .setMainClass("org.Main")
+ .setOrganization("SonarSource")
+ .setOrganizationUrl("http://sonarsource.org")
+ .setVersion("1.1")
+ .setSonarVersion("3.0")
+ .setUseChildFirstClassLoader(true)
+ .setCore(false)
+ .setImplementationBuild("abcdef");
assertThat(metadata.getKey()).isEqualTo("checkstyle");
assertThat(metadata.getParent()).isEqualTo("java");
@Test
public void testDeployedFiles() {
DefaultPluginMetadata metadata = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar"))
- .addDeployedFile(new File("foo.jar"))
- .addDeployedFile(new File("bar.jar"));
+ .addDeployedFile(new File("foo.jar"))
+ .addDeployedFile(new File("bar.jar"));
assertThat(metadata.getDeployedFiles()).hasSize(2);
}
@Test
public void testInternalPathToDependencies() {
DefaultPluginMetadata metadata = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar"))
- .setPathsToInternalDeps(newArrayList("META-INF/lib/commons-lang.jar", "META-INF/lib/commons-io.jar"));
+ .setPathsToInternalDeps(newArrayList("META-INF/lib/commons-lang.jar", "META-INF/lib/commons-io.jar"));
assertThat(metadata.getPathsToInternalDeps()).containsOnly("META-INF/lib/commons-lang.jar", "META-INF/lib/commons-io.jar");
}
@Test
public void shouldCompare() {
DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar"))
- .setKey("checkstyle")
- .setName("Checkstyle");
+ .setKey("checkstyle")
+ .setName("Checkstyle");
DefaultPluginMetadata pmd = DefaultPluginMetadata.create(new File("sonar-pmd-plugin.jar"))
- .setKey("pmd")
- .setName("PMD");
+ .setKey("pmd")
+ .setName("PMD");
List<DefaultPluginMetadata> plugins = Arrays.asList(pmd, checkstyle);
assertThat(natural().sortedCopy(plugins)).onProperty("key").containsExactly("checkstyle", "pmd");
}
static DefaultPluginMetadata pluginWithVersion(String version) {
- return DefaultPluginMetadata.create(null).setSonarVersion(version);
+ return DefaultPluginMetadata.create("foo").setSonarVersion(version);
}
}
@Test
public void shouldImport() throws Exception {
- classloaders.add(DefaultPluginMetadata.create(null).setKey("foo").addDeployedFile(getFile("PluginClassloadersTest/foo.jar")));
- classloaders.add(DefaultPluginMetadata.create(null).setKey("bar").addDeployedFile(getFile("PluginClassloadersTest/bar.jar")));
+ classloaders.add(DefaultPluginMetadata.create("foo").addDeployedFile(getFile("PluginClassloadersTest/foo.jar")));
+ classloaders.add(DefaultPluginMetadata.create("bar").addDeployedFile(getFile("PluginClassloadersTest/bar.jar")));
classloaders.done();
String resourceName = "org/sonar/plugins/bar/api/resource.txt";
@Test
public void shouldCreateBaseClassloader() {
classloaders = new PluginClassloaders(getClass().getClassLoader());
- DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(null)
- .setKey("checkstyle")
+ DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create("checkstyle")
.setMainClass("org.sonar.plugins.checkstyle.CheckstylePlugin")
.addDeployedFile(getFile("sonar-checkstyle-plugin-2.8.jar"));
public void shouldExtendPlugin() {
classloaders = new PluginClassloaders(getClass().getClassLoader());
- DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(null)
- .setKey("checkstyle")
+ DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create("checkstyle")
.setMainClass("org.sonar.plugins.checkstyle.CheckstylePlugin")
.addDeployedFile(getFile("sonar-checkstyle-plugin-2.8.jar"));
- DefaultPluginMetadata checkstyleExt = DefaultPluginMetadata.create(null)
- .setKey("checkstyle-ext")
+ DefaultPluginMetadata checkstyleExt = DefaultPluginMetadata.create("checkstyle-ext")
.setBasePlugin("checkstyle")
.setMainClass("com.mycompany.sonar.checkstyle.CheckstyleExtensionsPlugin")
.addDeployedFile(getFile("sonar-checkstyle-extensions-plugin-0.1-SNAPSHOT.jar"));
classloaders = new PluginClassloaders(getClass().getClassLoader(), world);
- DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(null)
- .setKey("checkstyle")
+ DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create("checkstyle")
.setMainClass("org.sonar.plugins.checkstyle.CheckstylePlugin")
.addDeployedFile(getFile("sonar-checkstyle-plugin-2.8.jar"));