mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 19:15:52 +01:00
Fix peer review issues
This commit is contained in:
@@ -18,8 +18,8 @@ public abstract class JsonEnricherBase implements JsonEnricher {
|
||||
return mediaType.equals(context.getResponseMediaType().toString());
|
||||
}
|
||||
|
||||
protected JsonNode value(Object gitConfigUrl) {
|
||||
return objectMapper.convertValue(gitConfigUrl, JsonNode.class);
|
||||
protected JsonNode value(Object object) {
|
||||
return objectMapper.convertValue(object, JsonNode.class);
|
||||
}
|
||||
|
||||
protected ObjectNode createObject() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import java.net.URI;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
@SubjectAware(configuration = "classpath:sonia/scm/configuration/shiro.ini")
|
||||
public class GitConfigInIndexResourceTest {
|
||||
@@ -39,7 +40,6 @@ public class GitConfigInIndexResourceTest {
|
||||
|
||||
gitConfigInIndexResource.enrich(context);
|
||||
|
||||
System.out.println(root);
|
||||
assertEquals("/v2/config/git", root.get("_links").get("gitConfig").get("href").asText());
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GitConfigInIndexResourceTest {
|
||||
|
||||
gitConfigInIndexResource.enrich(context);
|
||||
|
||||
System.out.println(root);
|
||||
assertFalse(root.get("_links").iterator().hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,6 +59,6 @@ public class GitConfigInIndexResourceTest {
|
||||
|
||||
gitConfigInIndexResource.enrich(context);
|
||||
|
||||
System.out.println(root);
|
||||
assertFalse(root.get("_links").iterator().hasNext());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ public class HgConfigInIndexResource extends JsonEnricherBase {
|
||||
@Override
|
||||
public void enrich(JsonEnricherContext context) {
|
||||
if (resultHasMediaType(INDEX, context) && ConfigurationPermissions.list().isPermitted()) {
|
||||
String gitConfigUrl = new LinkBuilder(scmPathInfoStore.get().get(), HgConfigResource.class)
|
||||
String hgConfigUrl = new LinkBuilder(scmPathInfoStore.get().get(), HgConfigResource.class)
|
||||
.method("get")
|
||||
.parameters()
|
||||
.href();
|
||||
|
||||
JsonNode hgConfigRefNode = createObject(singletonMap("href", value(gitConfigUrl)));
|
||||
JsonNode hgConfigRefNode = createObject(singletonMap("href", value(hgConfigUrl)));
|
||||
|
||||
addPropertyNode(context.getResponseEntity().get("_links"), "hgConfig", hgConfigRefNode);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import java.net.URI;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
@SubjectAware(configuration = "classpath:sonia/scm/configuration/shiro.ini")
|
||||
public class HgConfigInIndexResourceTest {
|
||||
@@ -39,7 +40,6 @@ public class HgConfigInIndexResourceTest {
|
||||
|
||||
hgConfigInIndexResource.enrich(context);
|
||||
|
||||
System.out.println(root);
|
||||
assertEquals("/v2/config/hg", root.get("_links").get("hgConfig").get("href").asText());
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class HgConfigInIndexResourceTest {
|
||||
|
||||
hgConfigInIndexResource.enrich(context);
|
||||
|
||||
System.out.println(root);
|
||||
assertFalse(root.get("_links").iterator().hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,6 +59,6 @@ public class HgConfigInIndexResourceTest {
|
||||
|
||||
hgConfigInIndexResource.enrich(context);
|
||||
|
||||
System.out.println(root);
|
||||
assertFalse(root.get("_links").iterator().hasNext());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ public class SvnConfigInIndexResource extends JsonEnricherBase {
|
||||
@Override
|
||||
public void enrich(JsonEnricherContext context) {
|
||||
if (resultHasMediaType(INDEX, context) && ConfigurationPermissions.list().isPermitted()) {
|
||||
String gitConfigUrl = new LinkBuilder(scmPathInfoStore.get().get(), SvnConfigResource.class)
|
||||
String svnConfigUrl = new LinkBuilder(scmPathInfoStore.get().get(), SvnConfigResource.class)
|
||||
.method("get")
|
||||
.parameters()
|
||||
.href();
|
||||
|
||||
JsonNode gitConfigRefNode = createObject(singletonMap("href", value(gitConfigUrl)));
|
||||
JsonNode svnConfigRefNode = createObject(singletonMap("href", value(svnConfigUrl)));
|
||||
|
||||
addPropertyNode(context.getResponseEntity().get("_links"), "svnConfig", gitConfigRefNode);
|
||||
addPropertyNode(context.getResponseEntity().get("_links"), "svnConfig", svnConfigRefNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import java.net.URI;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
@SubjectAware(configuration = "classpath:sonia/scm/configuration/shiro.ini")
|
||||
public class SvnConfigInIndexResourceTest {
|
||||
@@ -39,7 +40,6 @@ public class SvnConfigInIndexResourceTest {
|
||||
|
||||
svnConfigInIndexResource.enrich(context);
|
||||
|
||||
System.out.println(root);
|
||||
assertEquals("/v2/config/svn", root.get("_links").get("svnConfig").get("href").asText());
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SvnConfigInIndexResourceTest {
|
||||
|
||||
svnConfigInIndexResource.enrich(context);
|
||||
|
||||
System.out.println(root);
|
||||
assertFalse(root.get("_links").iterator().hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,6 +59,6 @@ public class SvnConfigInIndexResourceTest {
|
||||
|
||||
svnConfigInIndexResource.enrich(context);
|
||||
|
||||
System.out.println(root);
|
||||
assertFalse(root.get("_links").iterator().hasNext());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user