@Test
public void testToAndFromPbDestination() {
BucketDestination bucketDestination = Destination.fromPb(BUCKET_DESTINATION.toPb("other"));
assertEquals(Destination.Type.BUCKET, bucketDestination.getType());
assertEquals("bucket", bucketDestination.getBucket());
compareBucketDestination(BUCKET_DESTINATION, bucketDestination);
DatasetDestination datasetDestination = Destination.fromPb(DATASET_DESTINATION.toPb("other"));
assertEquals(Destination.Type.DATASET, datasetDestination.getType());
assertEquals("project", datasetDestination.getProject());
assertEquals("dataset", datasetDestination.getDataset());
compareDatasetDestination(DATASET_DESTINATION, datasetDestination);
TopicDestination topicDestination = Destination.fromPb(TOPIC_DESTINATION.toPb("other"));
assertEquals(Destination.Type.TOPIC, topicDestination.getType());
assertEquals("project", topicDestination.getProject());
assertEquals("topic", topicDestination.getTopic());
compareTopicDestination(TOPIC_DESTINATION, topicDestination);
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("wrongDestination is not a valid sink destination");
Destination.fromPb("wrongDestination");
}