### Question:
QueueManager { @PostConstruct public void postConstruct() { String queuesProperty = StringUtils.trim(config.getString(QUEUE_NAMES_PROPERTY)); Validate.notEmpty(queuesProperty); String[] queues = StringUtils.split(queuesProperty, "| "); Map<String, LinkedBlockingQueue<Message>> tempMessagesMap = new HashMap<>(queues.length); Map<String, String> tempQueueUrls = new HashMap<>(queues.length); for (String queue : queues) { queue = StringUtils.trim(queue); String queueUrl; logger.info("Initializing queue " + queue); try { queueUrl = sqsClient.getQueueUrl(queue).getQueueUrl(); } catch (QueueDoesNotExistException ex) { queueUrl = sqsClient.createQueue(queue).getQueueUrl(); } tempMessagesMap.put(queue, new LinkedBlockingQueue<>()); tempQueueUrls.put(queue, queueUrl); } messagesMap = Collections.unmodifiableMap(tempMessagesMap); queueUrls = Collections.unmodifiableMap(tempQueueUrls); executorService.submit(messagePoller); }  @PostConstruct void postConstruct(); Message nextMessage(String queueName); void confirmReceipt(String queueName, String receiptHandle); void enqueue(String queueName, String messageBody); static final String QUEUE_NAMES_PROPERTY; }### Answer:
@Test public void postConstruct_queuePropertyExistsAndQueuesExist_messagesMapCreated() throws Exception { setupStandard(); replay(configMock, sqsAsyncClientMock, executorServiceMock); this.queueManager.postConstruct(); verify(configMock, sqsAsyncClientMock, executorServiceMock); }
@Test(expected = NullPointerException.class) public void postConstruct_queuePropertyIsNull_NullPointerExceptionThrown() throws Exception { configMock = createMock(Config.class); expect(configMock.getString(QueueManager.QUEUE_NAMES_PROPERTY)).andReturn(null); FieldUtils.writeField(this.queueManager, "config", configMock, true); replay(configMock); this.queueManager.postConstruct(); }
@Test(expected = IllegalArgumentException.class) public void postConstruct_queuePropertyIsEmpty_IllegalArgumentExceptionThrown() throws Exception { configMock = createMock(Config.class); expect(configMock.getString(QueueManager.QUEUE_NAMES_PROPERTY)).andReturn(""); FieldUtils.writeField(this.queueManager, "config", configMock, true); replay(configMock); this.queueManager.postConstruct(); }
@Test(expected = IllegalArgumentException.class) public void postConstruct_queuePropertyIsWhitespace_IllegalArgumentExceptionThrown() throws Exception { configMock = createMock(Config.class); expect(configMock.getString(QueueManager.QUEUE_NAMES_PROPERTY)).andReturn(" "); FieldUtils.writeField(this.queueManager, "config", configMock, true); replay(configMock); this.queueManager.postConstruct(); }
@Test public void postConstruct_queuePropertyContainsNonExistentQueue_createsQueue() throws Exception { setupConfig(); sqsAsyncClientMock = createMock(AmazonSQSAsyncClient.class); for (String queueName : new String[] { "foo", "bar" }) { expect(sqsAsyncClientMock.getQueueUrl(queueName)) .andReturn(new GetQueueUrlResult().withQueueUrl(queueName + ".queueUrl")).once(); } expect(sqsAsyncClientMock.getQueueUrl("baz")).andThrow(new QueueDoesNotExistException("lol")).once(); expect(sqsAsyncClientMock.createQueue("baz")).andReturn(new CreateQueueResult().withQueueUrl("baz.queueurl")).once(); FieldUtils.writeField(this.queueManager, "sqsClient", sqsAsyncClientMock, true); setupExecutorService(); replay(configMock, sqsAsyncClientMock, executorServiceMock); this.queueManager.postConstruct(); verify(configMock, sqsAsyncClientMock, executorServiceMock); }