use of com.google.api.gax.httpjson.testing.FakeApiMessage in project gax-java by googleapis.
the class ApiMessageOperationTransformersTest method testResponseTransformer_mismatchedTypes.
@Test
public void testResponseTransformer_mismatchedTypes() {
ResponseTransformer<EmptyMessage> transformer = ResponseTransformer.create(EmptyMessage.class);
FakeMetadataMessage<?> metadata = new FakeMetadataMessage<>(Status.PENDING, Code.OK);
ApiMessage bananaResponse = new FakeApiMessage(ImmutableMap.<String, Object>of("name", "banana"), null, null);
OperationSnapshot operationSnapshot = new OperationSnapshotImpl(new FakeOperationMessage<>("No response method", bananaResponse, metadata));
try {
transformer.apply(operationSnapshot);
Assert.fail("ResponseTransformer should have thrown an exception");
} catch (ApiException expected) {
Truth.assertThat(expected).hasMessageThat().contains("cannot be cast");
}
}
use of com.google.api.gax.httpjson.testing.FakeApiMessage in project gax-java by googleapis.
the class ApiMessageOperationTransformersTest method testMetadataTransformer_mismatchedTypes.
@Test
public void testMetadataTransformer_mismatchedTypes() {
MetadataTransformer<FakeOperationMessage> transformer = MetadataTransformer.create(FakeOperationMessage.class);
FakeMetadataMessage<?> metadataMessage = new FakeMetadataMessage<>(Status.PENDING, Code.OK);
ApiMessage bananaResponse = new FakeApiMessage(ImmutableMap.<String, Object>of("name", "banana"), null, null);
FakeOperationMessage<?, ?> metadata = new FakeOperationMessage<>("No response method", bananaResponse, metadataMessage);
OperationSnapshot operationSnapshot = new OperationSnapshotImpl(metadata);
try {
transformer.apply(operationSnapshot);
Assert.fail("MetadataTransformer should have thrown an exception");
} catch (ApiException expected) {
Truth.assertThat(expected).hasMessageThat().contains("cannot be cast");
}
}
Aggregations