SqsIO { public static Write write() { return new AutoValue_SqsIO_Write.Builder().build(); } private  SqsIO(); static Read read(); static Write write();  }
@Test public void testWrite() { final AmazonSQS client = embeddedSqsRestServer.getClient(); final String queueUrl = embeddedSqsRestServer.getQueueUrl(); List<SendMessageRequest> messages = new ArrayList<>(); for (int i = 0; i < 100; i++) { final SendMessageRequest request = new SendMessageRequest(queueUrl, "This is a test " + i); messages.add(request); } pipeline.apply(Create.of(messages)).apply(SqsIO.write()); pipeline.run().waitUntilFinish(); List<String> received = new ArrayList<>(); while (received.size() < 100) { final ReceiveMessageResult receiveMessageResult = client.receiveMessage(queueUrl); if (receiveMessageResult.getMessages() != null) { for (Message message : receiveMessageResult.getMessages()) { received.add(message.getBody()); } } } assertEquals(100, received.size()); for (int i = 0; i < 100; i++) { received.contains("This is a test " + i); } }
@Test public void testWrite() { final SqsClient client = EmbeddedSqsServer.getClient(); final String queueUrl = EmbeddedSqsServer.getQueueUrl(); List<SendMessageRequest> messages = new ArrayList<>(); for (int i = 0; i < 100; i++) { final SendMessageRequest request = SendMessageRequest.builder() .queueUrl(queueUrl) .messageBody("This is a test " + i) .build(); messages.add(request); } pipeline .apply(Create.of(messages)) .apply(SqsIO.write().withSqsClientProvider(SqsClientProviderMock.of(client))); pipeline.run().waitUntilFinish(); List<String> received = new ArrayList<>(); while (received.size() < 100) { ReceiveMessageRequest receiveMessageRequest = ReceiveMessageRequest.builder().queueUrl(queueUrl).build(); final ReceiveMessageResponse receiveMessageResponse = client.receiveMessage(receiveMessageRequest); if (receiveMessageResponse != null) { for (Message message : receiveMessageResponse.messages()) { received.add(message.body()); } } } assertEquals(100, received.size()); for (int i = 0; i < 100; i++) { received.contains("This is a test " + i); } }