mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 02:31:14 +01:00
Peer review
This commit is contained in:
@@ -38,7 +38,7 @@ public class FieldContainerResponseFilterTest {
|
||||
@Test
|
||||
public void testFilter() throws IOException {
|
||||
applyFields("one");
|
||||
JsonNode node = applyEntity("filter-test-002");
|
||||
JsonNode node = applyEntity("filter-test-nested");
|
||||
|
||||
filter.filter(requestContext, responseContext);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class FieldContainerResponseFilterTest {
|
||||
@Test
|
||||
public void testFilterWithMultiple() throws IOException {
|
||||
applyFields("one", "five");
|
||||
JsonNode node = applyEntity("filter-test-002");
|
||||
JsonNode node = applyEntity("filter-test-nested");
|
||||
|
||||
filter.filter(requestContext, responseContext);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class FieldContainerResponseFilterTest {
|
||||
@Test
|
||||
public void testFilterCommaSeparated() throws IOException {
|
||||
applyFields("one,five");
|
||||
JsonNode node = applyEntity("filter-test-002");
|
||||
JsonNode node = applyEntity("filter-test-nested");
|
||||
|
||||
filter.filter(requestContext, responseContext);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class FieldContainerResponseFilterTest {
|
||||
@Test
|
||||
public void testFilterEmpty() throws IOException {
|
||||
applyFields();
|
||||
JsonNode node = applyEntity("filter-test-002");
|
||||
JsonNode node = applyEntity("filter-test-nested");
|
||||
|
||||
filter.filter(requestContext, responseContext);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class FieldContainerResponseFilterTest {
|
||||
@Test
|
||||
public void testFilterNotSet() throws IOException {
|
||||
applyFields((List) null);
|
||||
JsonNode node = applyEntity("filter-test-002");
|
||||
JsonNode node = applyEntity("filter-test-nested");
|
||||
|
||||
filter.filter(requestContext, responseContext);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.junit.Test;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
@@ -19,9 +20,9 @@ public class JsonFiltersTest {
|
||||
|
||||
@Test
|
||||
public void testFilterByFields() throws IOException {
|
||||
JsonNode node = readJson("filter-test-001");
|
||||
JsonNode node = readJson("filter-test-simple");
|
||||
|
||||
JsonFilters.filterByFields(node, Lists.newArrayList("one"));
|
||||
JsonFilters.filterByFields(node, asList("one"));
|
||||
|
||||
assertEquals(1, node.get("one").intValue());
|
||||
assertFalse(node.has("two"));
|
||||
@@ -30,9 +31,9 @@ public class JsonFiltersTest {
|
||||
|
||||
@Test
|
||||
public void testFilterByFieldsWithMultipleFields() throws IOException {
|
||||
JsonNode node = readJson("filter-test-001");
|
||||
JsonNode node = readJson("filter-test-simple");
|
||||
|
||||
JsonFilters.filterByFields(node, Lists.newArrayList("one", "three"));
|
||||
JsonFilters.filterByFields(node, asList("one", "three"));
|
||||
|
||||
assertEquals(1, node.get("one").intValue());
|
||||
assertFalse(node.has("two"));
|
||||
@@ -41,22 +42,22 @@ public class JsonFiltersTest {
|
||||
|
||||
@Test
|
||||
public void testFilterByFieldsWithNonPrimitive() throws IOException {
|
||||
JsonNode node = readJson("filter-test-002");
|
||||
JsonFilters.filterByFields(node, Lists.newArrayList("two"));
|
||||
JsonNode node = readJson("filter-test-nested");
|
||||
JsonFilters.filterByFields(node, asList("two"));
|
||||
assertEquals("{\"two\":{\"three\":3,\"four\":4}}", objectMapper.writeValueAsString(node));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterByFieldsWithDeepField() throws IOException {
|
||||
JsonNode node = readJson("filter-test-002");
|
||||
JsonFilters.filterByFields(node, Lists.newArrayList("two.three"));
|
||||
JsonNode node = readJson("filter-test-nested");
|
||||
JsonFilters.filterByFields(node, asList("two.three"));
|
||||
assertEquals("{\"two\":{\"three\":3}}", objectMapper.writeValueAsString(node));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterByFieldsWithVeryDeepField() throws IOException {
|
||||
JsonNode node = readJson("filter-test-003");
|
||||
JsonFilters.filterByFields(node, Lists.newArrayList("two.three.four.five"));
|
||||
JsonNode node = readJson("filter-test-deep-path");
|
||||
JsonFilters.filterByFields(node, asList("two.three.four.five"));
|
||||
assertFalse(node.has("one"));
|
||||
String json = objectMapper.writeValueAsString(node.get("two").get("three").get("four").get("five"));
|
||||
assertEquals("{\"six\":6,\"seven\":7}", json);
|
||||
@@ -64,10 +65,10 @@ public class JsonFiltersTest {
|
||||
|
||||
@Test
|
||||
public void testFilterByFieldsWithArray() throws IOException {
|
||||
JsonNode node = readJson("filter-test-004");
|
||||
JsonFilters.filterByFields(node, Lists.newArrayList("one.two"));
|
||||
JsonNode node = readJson("filter-test-arrays");
|
||||
JsonFilters.filterByFields(node, asList("one.two"));
|
||||
ArrayNode one = (ArrayNode) node.get("one");
|
||||
assertEquals(one.size(), 2);
|
||||
assertEquals(2, one.size());
|
||||
for (int i=0; i<one.size(); i++) {
|
||||
JsonNode childOfOne = one.get(i);
|
||||
assertFalse(childOfOne.has("three"));
|
||||
@@ -79,5 +80,4 @@ public class JsonFiltersTest {
|
||||
URL resource = Resources.getResource("sonia/scm/api/v2/" + name + ".json");
|
||||
return objectMapper.readTree(resource);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user