### Question:
BucketNotificationConfigurationStaxUnmarshaller implements
        Unmarshaller<BucketNotificationConfiguration, InputStream> { @Override public BucketNotificationConfiguration unmarshall(InputStream inputStream) throws Exception { final XmlPullParser xpp = xmlPullParserFactory.newPullParser(); xpp.setInput(inputStream, null); final StaxUnmarshallerContext context = new StaxUnmarshallerContext(xpp, null); final int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) { targetDepth += 1; } final BucketNotificationConfiguration config = new BucketNotificationConfiguration(); while (true) { final int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) { break; } else if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("TopicConfiguration", targetDepth)) { final Entry<String, NotificationConfiguration> entry = TopicConfigurationStaxUnmarshaller.getInstance() .unmarshall(context); config.addConfiguration(entry.getKey(), entry.getValue()); } else if (context.testExpression("QueueConfiguration", targetDepth)) { final Entry<String, NotificationConfiguration> entry = QueueConfigurationStaxUnmarshaller.getInstance() .unmarshall(context); config.addConfiguration(entry.getKey(), entry.getValue()); } else if (context.testExpression("CloudFunctionConfiguration", targetDepth)) { final Entry<String, NotificationConfiguration> entry = LambdaConfigurationStaxUnmarshaller.getInstance() .unmarshall(context); config.addConfiguration(entry.getKey(), entry.getValue()); } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return config; } } } return config; } private  BucketNotificationConfigurationStaxUnmarshaller(); static BucketNotificationConfigurationStaxUnmarshaller getInstance(); @Override BucketNotificationConfiguration unmarshall(InputStream inputStream);  }### Answer:
@Test public void unmarshall_ValidTopicConfiguration() throws Exception { final BucketNotificationConfiguration config = unmarshaller.unmarshall(getResource(TOPIC_INPUT)); final TopicConfiguration topicConfig = (TopicConfiguration) config.getConfigurationByName("TopicConfigId"); assertEquals("some-topic-arn", topicConfig.getTopicARN()); assertEventsUnmarshalledCorrectly(topicConfig.getEvents()); assertFilterRulesUnmarshalledCorrectly(topicConfig.getFilter().getS3KeyFilter().getFilterRules()); }
@Test public void unmarshall_ValidQueueConfiguration() throws Exception { final BucketNotificationConfiguration config = unmarshaller.unmarshall(getResource(QUEUE_INPUT)); final QueueConfiguration queueConfig = (QueueConfiguration) config.getConfigurationByName("QueueConfigId"); assertEquals("some-queue-arn", queueConfig.getQueueARN()); assertEventsUnmarshalledCorrectly(queueConfig.getEvents()); assertFilterRulesUnmarshalledCorrectly(queueConfig.getFilter().getS3KeyFilter().getFilterRules()); }
@Test public void unmarshall_ValidLambdaConfiguration() throws Exception { final BucketNotificationConfiguration config = unmarshaller.unmarshall(getResource(LAMBDA_INPUT)); final LambdaConfiguration lambdaConfig = (LambdaConfiguration) config.getConfigurationByName("LambdaConfigId"); assertEquals("some-lambda-function-arn", lambdaConfig.getFunctionARN()); assertEventsUnmarshalledCorrectly(lambdaConfig.getEvents()); assertFilterRulesUnmarshalledCorrectly(lambdaConfig.getFilter().getS3KeyFilter().getFilterRules()); }
@Test public void unmarshall_ValidCloudFunctionConfiguration() throws Exception { final BucketNotificationConfiguration config = unmarshaller.unmarshall(getResource(CLOUD_FUNCTION_INPUT)); final CloudFunctionConfiguration cloudFunctionConfig = (CloudFunctionConfiguration) config .getConfigurationByName("CloudFunctionConfigId"); assertEquals("some-cloud-function-arn", cloudFunctionConfig.getCloudFunctionARN()); assertEquals("some-cloud-invoc-role", cloudFunctionConfig.getInvocationRoleARN()); assertEventsUnmarshalledCorrectly(cloudFunctionConfig.getEvents()); assertFilterRulesUnmarshalledCorrectly(cloudFunctionConfig.getFilter().getS3KeyFilter().getFilterRules()); }