}
@Test
public void testSendProcessedMessageAppearsInS3WithDifferentRegion() throws Exception {
JSONObject imgPayload = TestUtils.createValidSampleIMGPayload();
Connection testIMGConnection = TestUtils.createIMGConnectionWithSpecificOutboundDatatypes();
OutboundConfiguration outboundConfiguration = new OutboundConfiguration.Builder()
.credentials(TestUtils.createCloudConnection().getCredentials())
.dataTypes(OutboundDataType.PROCESSED)
.protocol("s3")
.destination("eu-west-1")
.build();
testIMGConnection.setOutboundConfigurations(Sets.newHashSet(outboundConfiguration));
testIMGConnection.setAccount(testAccount);
testIMGConnection.setUser(testUser);
testIMGConnection = connectionService.createConnection(testIMGConnection);
SobaMessage sobaMessage = new SobaMessage.Builder()
.connection(testIMGConnection)
.dateGenerated(System.currentTimeMillis())
.hashtags(Sets.newHashSet("#foo"))
.sender(testIMGConnection)
.transformedMessage(imgPayload.getString("message"))
.type(MessageType.GATEWAY)
.visibility(SobaObject.Visibility.ACCOUNT)
.build();
sobaMessage.setId(new ObjectId());
outboundStorageService.sendSobaMessage(sobaMessage, testIMGConnection);
Thread.sleep(TimeUnit.SECONDS.toMillis(10));
String expectedBucketName = "com.streamreduce." + testIMGConnection.getAccount().getId();
String key = "processed/" + sobaMessage.getConnectionId() + "/" + sobaMessage.getId();
ConnectionCredentials credentials = new ArrayList<>(
testIMGConnection.getOutboundConfigurations()).get(0).getCredentials();
s3TestUtils = new S3TestUtils(credentials);
Blob payload = s3TestUtils.getExpectedBlob(expectedBucketName, key);
//Test that what made it to S3 is the same thing we get when we turn the sobaMessage into a dto