diff --git a/pom.xml b/pom.xml
index 1aa2275..0a2984d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,7 @@
atlassian-plugin
+ UTF-8
2.3.1
2.3.1
4.1.7
@@ -100,6 +101,11 @@
${common-lang.version}
+
+ com.atlassian.stash
+ stash-service-impl
+ test
+
com.atlassian.plugins
atlassian-plugins-osgi-testrunner
diff --git a/src/main/java/com/englishtown/stash/hook/DefaultSettingsReflectionHelper.java b/src/main/java/com/englishtown/stash/hook/DefaultSettingsReflectionHelper.java
index 01fadfd..00110da 100644
--- a/src/main/java/com/englishtown/stash/hook/DefaultSettingsReflectionHelper.java
+++ b/src/main/java/com/englishtown/stash/hook/DefaultSettingsReflectionHelper.java
@@ -3,7 +3,6 @@ package com.englishtown.stash.hook;
import com.atlassian.stash.setting.Settings;
import java.lang.reflect.Field;
-import java.util.HashMap;
import java.util.Map;
/**
diff --git a/src/main/java/com/englishtown/stash/hook/MirrorRepositoryHook.java b/src/main/java/com/englishtown/stash/hook/MirrorRepositoryHook.java
index fe7c40a..f6d1a4a 100644
--- a/src/main/java/com/englishtown/stash/hook/MirrorRepositoryHook.java
+++ b/src/main/java/com/englishtown/stash/hook/MirrorRepositoryHook.java
@@ -18,7 +18,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
-import java.lang.reflect.Field;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
@@ -28,7 +27,7 @@ import java.util.concurrent.TimeUnit;
public class MirrorRepositoryHook implements AsyncPostReceiveRepositoryHook, RepositorySettingsValidator {
- static class MirrorSettings {
+ protected static class MirrorSettings {
String mirrorRepoUrl;
String username;
String password;
@@ -147,7 +146,7 @@ public class MirrorRepositoryHook implements AsyncPostReceiveRepositoryHook, Rep
}
}
- URI getAuthenticatedUrl(String mirrorRepoUrl, String username, String password) throws URISyntaxException {
+ protected URI getAuthenticatedUrl(String mirrorRepoUrl, String username, String password) throws URISyntaxException {
URI uri = URI.create(mirrorRepoUrl);
String userInfo = username + ":" + password;
@@ -197,7 +196,7 @@ public class MirrorRepositoryHook implements AsyncPostReceiveRepositoryHook, Rep
}
- List getMirrorSettings(Settings settings) {
+ protected List getMirrorSettings(Settings settings) {
List results = new ArrayList();
Map allSettings = settings.asMap();
@@ -221,7 +220,7 @@ public class MirrorRepositoryHook implements AsyncPostReceiveRepositoryHook, Rep
return results;
}
- boolean validate(MirrorSettings ms, Settings settings, SettingsValidationErrors errors) {
+ protected boolean validate(MirrorSettings ms, Settings settings, SettingsValidationErrors errors) {
boolean result = true;
@@ -258,7 +257,7 @@ public class MirrorRepositoryHook implements AsyncPostReceiveRepositoryHook, Rep
return result;
}
- void updateSettings(List mirrorSettings, Settings settings) {
+ protected void updateSettings(List mirrorSettings, Settings settings) {
Map values = new HashMap();
@@ -274,4 +273,4 @@ public class MirrorRepositoryHook implements AsyncPostReceiveRepositoryHook, Rep
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/englishtown/stash/hook/DefaultSettingsReflectionHelperTest.java b/src/test/java/com/englishtown/stash/hook/DefaultSettingsReflectionHelperTest.java
new file mode 100644
index 0000000..94961aa
--- /dev/null
+++ b/src/test/java/com/englishtown/stash/hook/DefaultSettingsReflectionHelperTest.java
@@ -0,0 +1,40 @@
+package com.englishtown.stash.hook;
+
+import com.atlassian.stash.internal.setting.MapSettingsBuilder;
+import com.atlassian.stash.setting.Settings;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: adriangonzalez
+ * Date: 5/13/13
+ * Time: 3:54 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class DefaultSettingsReflectionHelperTest {
+
+ @Test
+ public void testSet() throws Exception {
+
+ DefaultSettingsReflectionHelper helper = new DefaultSettingsReflectionHelper();
+ MapSettingsBuilder builder = new MapSettingsBuilder();
+ Map values = new HashMap();
+
+ builder.add("old", "old");
+ values.put("new", "new");
+
+ Settings settings = builder.build();
+ helper.set(values, settings);
+
+ assertNull(settings.getString("old"));
+ assertEquals("new", settings.getString("new"));
+
+ }
+
+}