Skip to content

Commit

Permalink
fix: Made test exception text useful
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijeetshuklaoist committed Jan 28, 2021
1 parent aa22a9d commit 9824050
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -20,6 +20,7 @@
import static com.google.cloud.firestore.LocalFirestoreHelper.mapAnyType;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -1236,9 +1237,15 @@ public void primitiveDeserializeLong() {
}
}

@Test(expected = RuntimeException.class)
@Test
public void primitiveDeserializeWrongTypeMap() {
deserialize("{'value': {'foo': 'bar'}}", StringBean.class);
String expectedExceptionMessage =
".* Failed to convert value of type .*Map to String \\(found in field 'value'\\).*";
Throwable exception =
assertThrows(
RuntimeException.class,
() -> deserialize("{'value': {'foo': 'bar'}}", StringBean.class));
assertTrue(exception.getMessage().matches(expectedExceptionMessage));
}

@Test
Expand Down Expand Up @@ -2517,7 +2524,7 @@ public void settersCanOverridePrimitiveSettersParsing() {
NonConflictingSetterSubBean bean =
deserialize("{'value': 2}", NonConflictingSetterSubBean.class);
// sub-bean converts to negative value
assertEquals(-2, bean.value, 0);
assertEquals(-2, bean.value);
}

@Test
Expand Down

0 comments on commit 9824050

Please sign in to comment.