Index: third_party/protobuf/java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java |
diff --git a/third_party/protobuf/java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java b/third_party/protobuf/java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java |
index 1a998570532b9a39d7e5d25b4ff332f911363452..194f7b9c737b85e21030a2a7884ba7c0941668b0 100644 |
--- a/third_party/protobuf/java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java |
+++ b/third_party/protobuf/java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java |
@@ -41,55 +41,52 @@ public class FieldMaskUtilTest extends TestCase { |
public void testIsValid() throws Exception { |
assertTrue(FieldMaskUtil.isValid(NestedTestAllTypes.class, "payload")); |
assertFalse(FieldMaskUtil.isValid(NestedTestAllTypes.class, "nonexist")); |
- assertTrue(FieldMaskUtil.isValid(NestedTestAllTypes.class, "payload.optional_int32")); |
- assertTrue(FieldMaskUtil.isValid(NestedTestAllTypes.class, "payload.repeated_int32")); |
- assertTrue(FieldMaskUtil.isValid(NestedTestAllTypes.class, "payload.optional_nested_message")); |
- assertTrue(FieldMaskUtil.isValid(NestedTestAllTypes.class, "payload.repeated_nested_message")); |
- assertFalse(FieldMaskUtil.isValid(NestedTestAllTypes.class, "payload.nonexist")); |
- |
- assertTrue( |
- FieldMaskUtil.isValid(NestedTestAllTypes.class, FieldMaskUtil.fromString("payload"))); |
- assertFalse( |
- FieldMaskUtil.isValid(NestedTestAllTypes.class, FieldMaskUtil.fromString("nonexist"))); |
- assertFalse( |
- FieldMaskUtil.isValid( |
- NestedTestAllTypes.class, FieldMaskUtil.fromString("payload,nonexist"))); |
- |
+ assertTrue(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, "payload.optional_int32")); |
+ assertTrue(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, "payload.repeated_int32")); |
+ assertTrue(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, "payload.optional_nested_message")); |
+ assertTrue(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, "payload.repeated_nested_message")); |
+ assertFalse(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, "payload.nonexist")); |
+ |
+ assertTrue(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, FieldMaskUtil.fromString("payload"))); |
+ assertFalse(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, FieldMaskUtil.fromString("nonexist"))); |
+ assertFalse(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, FieldMaskUtil.fromString("payload,nonexist"))); |
+ |
assertTrue(FieldMaskUtil.isValid(NestedTestAllTypes.getDescriptor(), "payload")); |
assertFalse(FieldMaskUtil.isValid(NestedTestAllTypes.getDescriptor(), "nonexist")); |
- |
- assertTrue( |
- FieldMaskUtil.isValid( |
- NestedTestAllTypes.getDescriptor(), FieldMaskUtil.fromString("payload"))); |
- assertFalse( |
- FieldMaskUtil.isValid( |
- NestedTestAllTypes.getDescriptor(), FieldMaskUtil.fromString("nonexist"))); |
- |
- assertTrue( |
- FieldMaskUtil.isValid(NestedTestAllTypes.class, "payload.optional_nested_message.bb")); |
+ |
+ assertTrue(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.getDescriptor(), FieldMaskUtil.fromString("payload"))); |
+ assertFalse(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.getDescriptor(), FieldMaskUtil.fromString("nonexist"))); |
+ |
+ assertTrue(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, "payload.optional_nested_message.bb")); |
// Repeated fields cannot have sub-paths. |
- assertFalse( |
- FieldMaskUtil.isValid(NestedTestAllTypes.class, "payload.repeated_nested_message.bb")); |
+ assertFalse(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, "payload.repeated_nested_message.bb")); |
// Non-message fields cannot have sub-paths. |
- assertFalse(FieldMaskUtil.isValid(NestedTestAllTypes.class, "payload.optional_int32.bb")); |
+ assertFalse(FieldMaskUtil.isValid( |
+ NestedTestAllTypes.class, "payload.optional_int32.bb")); |
} |
- |
+ |
public void testToString() throws Exception { |
assertEquals("", FieldMaskUtil.toString(FieldMask.getDefaultInstance())); |
FieldMask mask = FieldMask.newBuilder().addPaths("foo").build(); |
assertEquals("foo", FieldMaskUtil.toString(mask)); |
mask = FieldMask.newBuilder().addPaths("foo").addPaths("bar").build(); |
assertEquals("foo,bar", FieldMaskUtil.toString(mask)); |
- |
+ |
// Empty field paths are ignored. |
- mask = |
- FieldMask.newBuilder() |
- .addPaths("") |
- .addPaths("foo") |
- .addPaths("") |
- .addPaths("bar") |
- .addPaths("") |
- .build(); |
+ mask = FieldMask.newBuilder().addPaths("").addPaths("foo").addPaths(""). |
+ addPaths("bar").addPaths("").build(); |
assertEquals("foo,bar", FieldMaskUtil.toString(mask)); |
} |
@@ -114,7 +111,8 @@ public class FieldMaskUtilTest extends TestCase { |
mask = FieldMaskUtil.fromString(NestedTestAllTypes.class, ",payload"); |
try { |
- mask = FieldMaskUtil.fromString(NestedTestAllTypes.class, "payload,nonexist"); |
+ mask = FieldMaskUtil.fromString( |
+ NestedTestAllTypes.class, "payload,nonexist"); |
fail("Exception is expected."); |
} catch (IllegalArgumentException e) { |
// Expected. |
@@ -145,33 +143,7 @@ public class FieldMaskUtilTest extends TestCase { |
} catch (IllegalArgumentException expected) { |
} |
} |
- |
- public void testToJsonString() throws Exception { |
- FieldMask mask = FieldMask.getDefaultInstance(); |
- assertEquals("", FieldMaskUtil.toJsonString(mask)); |
- mask = FieldMask.newBuilder().addPaths("foo").build(); |
- assertEquals("foo", FieldMaskUtil.toJsonString(mask)); |
- mask = FieldMask.newBuilder().addPaths("foo.bar_baz").addPaths("").build(); |
- assertEquals("foo.barBaz", FieldMaskUtil.toJsonString(mask)); |
- mask = FieldMask.newBuilder().addPaths("foo").addPaths("bar_baz").build(); |
- assertEquals("foo,barBaz", FieldMaskUtil.toJsonString(mask)); |
- } |
- |
- public void testFromJsonString() throws Exception { |
- FieldMask mask = FieldMaskUtil.fromJsonString(""); |
- assertEquals(0, mask.getPathsCount()); |
- mask = FieldMaskUtil.fromJsonString("foo"); |
- assertEquals(1, mask.getPathsCount()); |
- assertEquals("foo", mask.getPaths(0)); |
- mask = FieldMaskUtil.fromJsonString("foo.barBaz"); |
- assertEquals(1, mask.getPathsCount()); |
- assertEquals("foo.bar_baz", mask.getPaths(0)); |
- mask = FieldMaskUtil.fromJsonString("foo,barBaz"); |
- assertEquals(2, mask.getPathsCount()); |
- assertEquals("foo", mask.getPaths(0)); |
- assertEquals("bar_baz", mask.getPaths(1)); |
- } |
- |
+ |
public void testUnion() throws Exception { |
// Only test a simple case here and expect |
// {@link FieldMaskTreeTest#testAddFieldPath} to cover all scenarios. |
@@ -189,7 +161,7 @@ public class FieldMaskUtilTest extends TestCase { |
FieldMask result = FieldMaskUtil.union(mask1, mask2, mask3, mask4); |
assertEquals("bar,foo", FieldMaskUtil.toString(result)); |
} |
- |
+ |
public void testIntersection() throws Exception { |
// Only test a simple case here and expect |
// {@link FieldMaskTreeTest#testIntersectFieldPath} to cover all scenarios. |
@@ -198,14 +170,13 @@ public class FieldMaskUtilTest extends TestCase { |
FieldMask result = FieldMaskUtil.intersection(mask1, mask2); |
assertEquals("bar.baz,bar.quz,foo.bar", FieldMaskUtil.toString(result)); |
} |
- |
+ |
public void testMerge() throws Exception { |
// Only test a simple case here and expect |
// {@link FieldMaskTreeTest#testMerge} to cover all scenarios. |
- NestedTestAllTypes source = |
- NestedTestAllTypes.newBuilder() |
- .setPayload(TestAllTypes.newBuilder().setOptionalInt32(1234)) |
- .build(); |
+ NestedTestAllTypes source = NestedTestAllTypes.newBuilder() |
+ .setPayload(TestAllTypes.newBuilder().setOptionalInt32(1234)) |
+ .build(); |
NestedTestAllTypes.Builder builder = NestedTestAllTypes.newBuilder(); |
FieldMaskUtil.merge(FieldMaskUtil.fromString("payload"), source, builder); |
assertEquals(1234, builder.getPayload().getOptionalInt32()); |