Skip to content

Commit 9824050

Browse files
fix: Made test exception text useful
1 parent aa22a9d commit 9824050

File tree

1 file changed

+10
-3
lines changed
  • google-cloud-firestore/src/test/java/com/google/cloud/firestore

1 file changed

+10
-3
lines changed

google-cloud-firestore/src/test/java/com/google/cloud/firestore/MapperTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static com.google.cloud.firestore.LocalFirestoreHelper.mapAnyType;
2121
import static org.junit.Assert.assertEquals;
2222
import static org.junit.Assert.assertNull;
23+
import static org.junit.Assert.assertThrows;
2324
import static org.junit.Assert.assertTrue;
2425
import static org.junit.Assert.fail;
2526

@@ -1236,9 +1237,15 @@ public void primitiveDeserializeLong() {
12361237
}
12371238
}
12381239

1239-
@Test(expected = RuntimeException.class)
1240+
@Test
12401241
public void primitiveDeserializeWrongTypeMap() {
1241-
deserialize("{'value': {'foo': 'bar'}}", StringBean.class);
1242+
String expectedExceptionMessage =
1243+
".* Failed to convert value of type .*Map to String \\(found in field 'value'\\).*";
1244+
Throwable exception =
1245+
assertThrows(
1246+
RuntimeException.class,
1247+
() -> deserialize("{'value': {'foo': 'bar'}}", StringBean.class));
1248+
assertTrue(exception.getMessage().matches(expectedExceptionMessage));
12421249
}
12431250

12441251
@Test
@@ -2517,7 +2524,7 @@ public void settersCanOverridePrimitiveSettersParsing() {
25172524
NonConflictingSetterSubBean bean =
25182525
deserialize("{'value': 2}", NonConflictingSetterSubBean.class);
25192526
// sub-bean converts to negative value
2520-
assertEquals(-2, bean.value, 0);
2527+
assertEquals(-2, bean.value);
25212528
}
25222529

25232530
@Test

0 commit comments

Comments
 (0)