mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
Enable plugins to create config stores for repository config
Therefore we have to - add an API to create stores for repository ids, not only for repositories, - make v1 properties available in scm-core - make sure that properties are extracted from repositories before the update step of a plugin runs (this is done by sorting the update steps in a way so that "core" update steps are executed before plugin update steps with the same version)
This commit is contained in:
@@ -32,7 +32,21 @@ class UpdateEngineTest {
|
||||
updateEngine.update();
|
||||
|
||||
assertThat(processedUpdates)
|
||||
.containsExactly("1.1.0", "1.1.1", "1.2.0");
|
||||
.containsExactly("test:1.1.0", "test:1.1.1", "test:1.2.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldProcessCoreStepsBeforeOther() {
|
||||
LinkedHashSet<UpdateStep> updateSteps = new LinkedHashSet<>();
|
||||
|
||||
updateSteps.add(new FixedVersionUpdateStep("test", "1.2.0"));
|
||||
updateSteps.add(new CoreFixedVersionUpdateStep("core", "1.2.0"));
|
||||
|
||||
UpdateEngine updateEngine = new UpdateEngine(updateSteps, storeFactory);
|
||||
updateEngine.update();
|
||||
|
||||
assertThat(processedUpdates)
|
||||
.containsExactly("core:1.2.0", "test:1.2.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +81,7 @@ class UpdateEngineTest {
|
||||
updateEngine = new UpdateEngine(updateSteps, storeFactory);
|
||||
updateEngine.update();
|
||||
|
||||
assertThat(processedUpdates).containsExactly("1.1.1");
|
||||
assertThat(processedUpdates).containsExactly("other:1.1.1");
|
||||
}
|
||||
|
||||
class FixedVersionUpdateStep implements UpdateStep {
|
||||
@@ -91,7 +105,13 @@ class UpdateEngineTest {
|
||||
|
||||
@Override
|
||||
public void doUpdate() {
|
||||
processedUpdates.add(version);
|
||||
processedUpdates.add(type + ":" + version);
|
||||
}
|
||||
}
|
||||
|
||||
class CoreFixedVersionUpdateStep extends FixedVersionUpdateStep implements CoreUpdateStep {
|
||||
CoreFixedVersionUpdateStep(String type, String version) {
|
||||
super(type, version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ import sonia.scm.group.xml.XmlGroupDAO;
|
||||
import sonia.scm.store.ConfigurationEntryStore;
|
||||
import sonia.scm.store.InMemoryConfigurationEntryStoreFactory;
|
||||
import sonia.scm.update.UpdateStepTestUtil;
|
||||
import sonia.scm.update.properties.V1Properties;
|
||||
import sonia.scm.update.properties.V1Property;
|
||||
import sonia.scm.update.V1Properties;
|
||||
import sonia.scm.update.V1Property;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import java.io.IOException;
|
||||
@@ -89,13 +89,10 @@ class XmlGroupV1UpdateStepTest {
|
||||
@Test
|
||||
void shouldExtractProperties() throws JAXBException {
|
||||
updateStep.doUpdate();
|
||||
ConfigurationEntryStore<V1Properties> propertiesStore = storeFactory.<V1Properties>get("group-properties-v1");
|
||||
assertThat(propertiesStore.get("normals"))
|
||||
.isNotNull()
|
||||
.extracting(V1Properties::getProperties)
|
||||
.first()
|
||||
.asList()
|
||||
.contains(new V1Property("mostly", "humans"));
|
||||
ConfigurationEntryStore<V1Properties> propertiesStore = storeFactory.get("group-properties-v1");
|
||||
V1Properties properties = propertiesStore.get("normals");
|
||||
assertThat(properties).isNotNull();
|
||||
assertThat(properties.get("mostly")).isEqualTo("humans");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ import sonia.scm.security.AssignedPermission;
|
||||
import sonia.scm.store.ConfigurationEntryStore;
|
||||
import sonia.scm.store.InMemoryConfigurationEntryStoreFactory;
|
||||
import sonia.scm.update.UpdateStepTestUtil;
|
||||
import sonia.scm.update.properties.V1Properties;
|
||||
import sonia.scm.update.properties.V1Property;
|
||||
import sonia.scm.update.V1Properties;
|
||||
import sonia.scm.update.V1Property;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.user.xml.XmlUserDAO;
|
||||
|
||||
@@ -105,14 +105,10 @@ class XmlUserV1UpdateStepTest {
|
||||
void shouldExtractProperties() throws JAXBException {
|
||||
updateStep.doUpdate();
|
||||
ConfigurationEntryStore<V1Properties> propertiesStore = storeFactory.<V1Properties>get("user-properties-v1");
|
||||
assertThat(propertiesStore.get("dent"))
|
||||
.isNotNull()
|
||||
.extracting(V1Properties::getProperties)
|
||||
.first()
|
||||
.asList()
|
||||
.contains(
|
||||
new V1Property("born.on", "earth"),
|
||||
new V1Property("last.seen", "end of the universe"));
|
||||
V1Properties properties = propertiesStore.get("dent");
|
||||
assertThat(properties).isNotNull();
|
||||
assertThat(properties.get("born.on")).isEqualTo("earth");
|
||||
assertThat(properties.get("last.seen")).isEqualTo("end of the universe");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user