Skip to content

Commit

Permalink
Converted dependency to test and updated assert
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijeet Shukla <abhijeetshuklaoist@gmail.com>
  • Loading branch information
abhijeetshuklaoist committed Jan 25, 2021
1 parent 1c298f2 commit c544d7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
9 changes: 5 additions & 4 deletions google-cloud-firestore/pom.xml
Expand Up @@ -109,10 +109,6 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
Expand All @@ -136,6 +132,11 @@
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<scope>test</scope>
</dependency>
<!-- Need testing utility classes for generated gRPC clients tests -->
<dependency>
<groupId>com.google.api</groupId>
Expand Down
Expand Up @@ -972,6 +972,15 @@ private static void assertExceptionContains(String partialMessage, Runnable run)
}
}

private static void assertExceptionThrows(Runnable run) {
try {
run.run();
fail("Expected exception not thrown");
} catch (RuntimeException ignored) {
// no-op catch
}
}

private static <T> T convertToCustomClass(
Object object, Class<T> clazz, DocumentReference docRef) {
return CustomClassMapper.convertToCustomClass(object, clazz, docRef);
Expand Down Expand Up @@ -1213,9 +1222,7 @@ public void primitiveDeserializeLong() {

@Test
public void primitiveDeserializeWrongTypeMap() {
assertExceptionContains(
"Failed to convert value of type com.google.gson.internal.LinkedTreeMap to String "
+ "(found in field 'value')",
assertExceptionThrows(
new Runnable() {
@Override
public void run() {
Expand Down

0 comments on commit c544d7c

Please sign in to comment.