### Question:
SizeRequestProcessor implements SQSRequestProcessor { @Override public SQSQueueResult processRequest(SQSRequestContext sqsRequestContext) { SQSQueueResult result = new SQSQueueResult(); GetQueueAttributesRequest queueAttributesRequest = new GetQueueAttributesRequest() .withQueueUrl(sqsRequestContext.getQueueURL()) .withAttributeNames( QueueAttributeName.ApproximateNumberOfMessages.name() ); GetQueueAttributesResult queueAttributesResult = sqsRequestContext.getSqsClient().getQueueAttributes(queueAttributesRequest); String messageCount = queueAttributesResult.getAttributes().get(QueueAttributeName.ApproximateNumberOfMessages.name()); result.setSuccessful(messageCount != null); result.setMessage(messageCount); return result; }  @Override SQSQueueResult processRequest(SQSRequestContext sqsRequestContext);  }### Answer:
@Test public void testMissingAttribute() { GetQueueAttributesResult getQueueAttributesResult = new GetQueueAttributesResult(); getQueueAttributesResult.setAttributes(new HashMap<>()); doReturn(getQueueAttributesResult).when(mockAmazonSQS).getQueueAttributes(any(GetQueueAttributesRequest.class)); QueueResult result = sizeRequestProcessor.processRequest( new SQSRequestContext(mockAmazonSQS, new QueueRequest(), null)); Assert.assertFalse(result.isSuccessful()); }
@Test public void testNormal() { final String EXPECTED_VALUE = "expected"; GetQueueAttributesResult getQueueAttributesResult = new GetQueueAttributesResult(); Map<String, String> attributeMap = new HashMap<>(); attributeMap.put(QueueAttributeName.ApproximateNumberOfMessages.name(), EXPECTED_VALUE); getQueueAttributesResult.setAttributes(attributeMap); doReturn(getQueueAttributesResult).when(mockAmazonSQS).getQueueAttributes(any(GetQueueAttributesRequest.class)); QueueResult result = sizeRequestProcessor.processRequest( new SQSRequestContext(mockAmazonSQS, new QueueRequest(), null)); Assert.assertTrue(result.isSuccessful()); Assert.assertEquals(result.getMessage(), EXPECTED_VALUE); }