mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
refactor plugin backend + fix tests
This commit is contained in:
@@ -36,6 +36,8 @@ public class ResourceLinksMock {
|
||||
when(resourceLinks.modifications()).thenReturn(new ResourceLinks.ModificationsLinks(uriInfo));
|
||||
when(resourceLinks.repositoryType()).thenReturn(new ResourceLinks.RepositoryTypeLinks(uriInfo));
|
||||
when(resourceLinks.repositoryTypeCollection()).thenReturn(new ResourceLinks.RepositoryTypeCollectionLinks(uriInfo));
|
||||
when(resourceLinks.pluginCollection()).thenReturn(new ResourceLinks.PluginCollectionLinks(uriInfo));
|
||||
when(resourceLinks.plugin()).thenReturn(new ResourceLinks.PluginLinks(uriInfo));
|
||||
when(resourceLinks.uiPluginCollection()).thenReturn(new ResourceLinks.UIPluginCollectionLinks(uriInfo));
|
||||
when(resourceLinks.uiPlugin()).thenReturn(new ResourceLinks.UIPluginLinks(uriInfo));
|
||||
when(resourceLinks.authentication()).thenReturn(new ResourceLinks.AuthenticationLinks(uriInfo));
|
||||
|
||||
@@ -60,12 +60,12 @@ public class ExplodedSmpTest
|
||||
@Test
|
||||
public void testCompareTo()
|
||||
{
|
||||
ExplodedSmp e1 = create("a", "c", "1", "a:a");
|
||||
ExplodedSmp e1 = create("a", "c", "1", "a");
|
||||
ExplodedSmp e3 = create("a", "a", "1");
|
||||
ExplodedSmp e2 = create("a", "b", "1");
|
||||
List<ExplodedSmp> es = list(e1, e2, e3);
|
||||
|
||||
is(es, 2, "c");
|
||||
is(es, 2, "a");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,9 +75,9 @@ public class ExplodedSmpTest
|
||||
@Test(expected = PluginCircularDependencyException.class)
|
||||
public void testCompareToCyclicDependency()
|
||||
{
|
||||
ExplodedSmp e1 = create("a", "a", "1", "a:c");
|
||||
ExplodedSmp e2 = create("a", "b", "1");
|
||||
ExplodedSmp e3 = create("a", "c", "1", "a:a");
|
||||
ExplodedSmp e1 = create("a", "1", "c");
|
||||
ExplodedSmp e2 = create("b", "1");
|
||||
ExplodedSmp e3 = create("c", "1", "a");
|
||||
|
||||
list(e1, e2, e3);
|
||||
}
|
||||
@@ -89,9 +89,9 @@ public class ExplodedSmpTest
|
||||
@Test
|
||||
public void testCompareToTransitiveDependencies()
|
||||
{
|
||||
ExplodedSmp e1 = create("a", "a", "1", "a:b");
|
||||
ExplodedSmp e2 = create("a", "b", "1");
|
||||
ExplodedSmp e3 = create("a", "c", "1", "a:a");
|
||||
ExplodedSmp e1 = create("a", "1", "b");
|
||||
ExplodedSmp e2 = create("b", "1");
|
||||
ExplodedSmp e3 = create("c", "1", "a");
|
||||
|
||||
List<ExplodedSmp> es = list(e1, e2, e3);
|
||||
|
||||
@@ -107,9 +107,9 @@ public class ExplodedSmpTest
|
||||
@Test
|
||||
public void testMultipleDependencies()
|
||||
{
|
||||
ExplodedSmp e1 = create("a", "a", "1", "a:b", "a:c");
|
||||
ExplodedSmp e2 = create("a", "b", "1", "a:c");
|
||||
ExplodedSmp e3 = create("a", "c", "1");
|
||||
ExplodedSmp e1 = create("a", "1", "b", "c");
|
||||
ExplodedSmp e2 = create("b", "1", "c");
|
||||
ExplodedSmp e3 = create("c", "1");
|
||||
List<ExplodedSmp> es = list(e1, e2, e3);
|
||||
|
||||
is(es, 2, "a");
|
||||
@@ -119,20 +119,18 @@ public class ExplodedSmpTest
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param groupId
|
||||
* @param artifactId
|
||||
* @param name
|
||||
* @param version
|
||||
* @param dependencies
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private ExplodedSmp create(String groupId, String artifactId, String version,
|
||||
private ExplodedSmp create(String name, String version,
|
||||
String... dependencies)
|
||||
{
|
||||
PluginInformation info = new PluginInformation();
|
||||
|
||||
info.setGroupId(groupId);
|
||||
info.setArtifactId(artifactId);
|
||||
info.setName(name);
|
||||
info.setVersion(version);
|
||||
|
||||
Plugin plugin = new Plugin(2, info, null, null, false,
|
||||
@@ -170,6 +168,6 @@ public class ExplodedSmpTest
|
||||
*/
|
||||
private void is(List<ExplodedSmp> es, int p, String a)
|
||||
{
|
||||
assertEquals(a, es.get(p).getPlugin().getInformation().getArtifactId());
|
||||
assertEquals(a, es.get(p).getPlugin().getInformation().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,37 +71,37 @@ public class PluginProcessorTest
|
||||
/** Field description */
|
||||
private static final PluginResource PLUGIN_A =
|
||||
new PluginResource("sonia/scm/plugin/scm-a-plugin.smp", "scm-a-plugin.smp",
|
||||
"sonia.scm.plugins:scm-a-plugin:1.0.0-SNAPSHOT");
|
||||
"scm-a-plugin:1.0.0-SNAPSHOT");
|
||||
|
||||
/** Field description */
|
||||
private static final PluginResource PLUGIN_B =
|
||||
new PluginResource("sonia/scm/plugin/scm-b-plugin.smp", "scm-b-plugin.smp",
|
||||
"sonia.scm.plugins:scm-b-plugin:1.0.0-SNAPSHOT");
|
||||
"scm-b-plugin:1.0.0-SNAPSHOT");
|
||||
|
||||
/** Field description */
|
||||
private static final PluginResource PLUGIN_C =
|
||||
new PluginResource("sonia/scm/plugin/scm-c-plugin.smp", "scm-c-plugin.smp",
|
||||
"sonia.scm.plugins:scm-c-plugin:1.0.0-SNAPSHOT");
|
||||
"scm-c-plugin:1.0.0-SNAPSHOT");
|
||||
|
||||
/** Field description */
|
||||
private static final PluginResource PLUGIN_D =
|
||||
new PluginResource("sonia/scm/plugin/scm-d-plugin.smp", "scm-d-plugin.smp",
|
||||
"sonia.scm.plugins:scm-d-plugin:1.0.0-SNAPSHOT");
|
||||
"scm-d-plugin:1.0.0-SNAPSHOT");
|
||||
|
||||
/** Field description */
|
||||
private static final PluginResource PLUGIN_E =
|
||||
new PluginResource("sonia/scm/plugin/scm-e-plugin.smp", "scm-e-plugin.smp",
|
||||
"sonia.scm.plugins:scm-e-plugin:1.0.0-SNAPSHOT");
|
||||
"scm-e-plugin:1.0.0-SNAPSHOT");
|
||||
|
||||
/** Field description */
|
||||
private static final PluginResource PLUGIN_F_1_0_0 =
|
||||
new PluginResource("sonia/scm/plugin/scm-f-plugin-1.0.0.smp",
|
||||
"scm-f-plugin.smp", "sonia.scm.plugins:scm-f-plugin:1.0.0");
|
||||
"scm-f-plugin.smp", "scm-f-plugin:1.0.0");
|
||||
|
||||
/** Field description */
|
||||
private static final PluginResource PLUGIN_F_1_0_1 =
|
||||
new PluginResource("sonia/scm/plugin/scm-f-plugin-1.0.1.smp",
|
||||
"scm-f-plugin.smp", "sonia.scm.plugins:scm-f-plugin:1.0.1");
|
||||
"scm-f-plugin.smp", "scm-f-plugin:1.0.1");
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PluginTreeTest
|
||||
{
|
||||
PluginCondition condition = new PluginCondition("999",
|
||||
new ArrayList<String>(), "hit");
|
||||
Plugin plugin = new Plugin(2, createInfo("a", "b", "1"), null, condition,
|
||||
Plugin plugin = new Plugin(2, createInfo("a", "1"), null, condition,
|
||||
false, null);
|
||||
ExplodedSmp smp = createSmp(plugin);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class PluginTreeTest
|
||||
List<ExplodedSmp> smps = createSmps("a", "b", "c");
|
||||
List<String> nodes = unwrapIds(new PluginTree(smps).getRootNodes());
|
||||
|
||||
assertThat(nodes, containsInAnyOrder("a:a", "b:b", "c:c"));
|
||||
assertThat(nodes, containsInAnyOrder("a", "b", "c"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ public class PluginTreeTest
|
||||
@Test(expected = PluginException.class)
|
||||
public void testScmVersion() throws IOException
|
||||
{
|
||||
Plugin plugin = new Plugin(1, createInfo("a", "b", "1"), null, null, false,
|
||||
Plugin plugin = new Plugin(1, createInfo("a", "1"), null, null, false,
|
||||
null);
|
||||
ExplodedSmp smp = createSmp(plugin);
|
||||
|
||||
@@ -141,34 +141,32 @@ public class PluginTreeTest
|
||||
PluginTree tree = new PluginTree(smps);
|
||||
List<PluginNode> rootNodes = tree.getRootNodes();
|
||||
|
||||
assertThat(unwrapIds(rootNodes), containsInAnyOrder("a:a"));
|
||||
assertThat(unwrapIds(rootNodes), containsInAnyOrder("a"));
|
||||
|
||||
PluginNode a = rootNodes.get(0);
|
||||
|
||||
assertThat(unwrapIds(a.getChildren()), containsInAnyOrder("b:b", "c:c"));
|
||||
assertThat(unwrapIds(a.getChildren()), containsInAnyOrder("b", "c"));
|
||||
|
||||
PluginNode b = a.getChild("b:b");
|
||||
PluginNode b = a.getChild("b");
|
||||
|
||||
assertThat(unwrapIds(b.getChildren()), containsInAnyOrder("c:c"));
|
||||
assertThat(unwrapIds(b.getChildren()), containsInAnyOrder("c"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param groupId
|
||||
* @param artifactId
|
||||
* @param name
|
||||
* @param version
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private PluginInformation createInfo(String groupId, String artifactId,
|
||||
private PluginInformation createInfo(String name,
|
||||
String version)
|
||||
{
|
||||
PluginInformation info = new PluginInformation();
|
||||
|
||||
info.setGroupId(groupId);
|
||||
info.setArtifactId(artifactId);
|
||||
info.setName(name);
|
||||
info.setVersion(version);
|
||||
|
||||
return info;
|
||||
@@ -201,7 +199,7 @@ public class PluginTreeTest
|
||||
*/
|
||||
private ExplodedSmp createSmp(String name) throws IOException
|
||||
{
|
||||
return createSmp(new Plugin(2, createInfo(name, name, "1.0.0"), null, null,
|
||||
return createSmp(new Plugin(2, createInfo(name, "1.0.0"), null, null,
|
||||
false, null));
|
||||
}
|
||||
|
||||
@@ -224,10 +222,10 @@ public class PluginTreeTest
|
||||
|
||||
for (String d : dependencies)
|
||||
{
|
||||
dependencySet.add(d.concat(":").concat(d));
|
||||
dependencySet.add(d);
|
||||
}
|
||||
|
||||
Plugin plugin = new Plugin(2, createInfo(name, name, "1"), null, null,
|
||||
Plugin plugin = new Plugin(2, createInfo(name, "1"), null, null,
|
||||
false, dependencySet);
|
||||
|
||||
return createSmp(plugin);
|
||||
|
||||
Reference in New Issue
Block a user