@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"); }
private void compareTopicDestination(TopicDestination expected, TopicDestination value) { assertEquals(expected, value); assertEquals(expected.getProject(), value.getProject()); assertEquals(expected.getTopic(), value.getTopic()); assertEquals(expected.hashCode(), value.hashCode()); assertEquals(expected.toString(), value.toString()); }
@Test public void testOfTopicDestination() { assertEquals(Destination.Type.TOPIC, TOPIC_DESTINATION.getType()); assertEquals("project", TOPIC_DESTINATION.getProject()); assertEquals("topic", TOPIC_DESTINATION.getTopic()); TopicDestination topicDestination = TopicDestination.of("topic"); assertNull(topicDestination.getProject()); assertEquals("topic", topicDestination.getTopic()); }