Search in sources :

Example 11 with S3Entity

use of com.amazonaws.services.s3.event.S3EventNotification.S3Entity in project bender by Nextdoor.

the class S3HandlerTest method getTestEvent.

private S3EventNotification getTestEvent(String bucket, boolean doPut) throws Exception {
    /*
     * Upload a test resoruce to the mock S3
     */
    if (doPut) {
        String payload = IOUtils.toString(new InputStreamReader(this.getClass().getResourceAsStream("basic_input.log"), "UTF-8"));
        this.client.putObject(bucket, "basic_input.log", payload);
    }
    /*
     * Create a S3EventNotification event
     */
    S3ObjectEntity objEntity = new S3ObjectEntity("basic_input.log", 1L, null, null);
    S3BucketEntity bucketEntity = new S3BucketEntity(bucket, null, null);
    S3Entity entity = new S3Entity(null, bucketEntity, objEntity, null);
    S3EventNotificationRecord rec = new S3EventNotificationRecord(null, null, null, "1970-01-01T00:00:00.000Z", null, null, null, entity, null);
    List<S3EventNotificationRecord> notifications = new ArrayList<S3EventNotificationRecord>(2);
    notifications.add(rec);
    return new S3EventNotification(notifications);
}
Also used : S3EventNotification(com.amazonaws.services.s3.event.S3EventNotification) S3ObjectEntity(com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity) S3Entity(com.amazonaws.services.s3.event.S3EventNotification.S3Entity) InputStreamReader(java.io.InputStreamReader) S3EventNotificationRecord(com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord) ArrayList(java.util.ArrayList) S3BucketEntity(com.amazonaws.services.s3.event.S3EventNotification.S3BucketEntity)

Aggregations

S3EventNotification (com.amazonaws.services.s3.event.S3EventNotification)11 S3Entity (com.amazonaws.services.s3.event.S3EventNotification.S3Entity)11 S3EventNotificationRecord (com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord)11 S3ObjectEntity (com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity)11 ArrayList (java.util.ArrayList)11 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)6 Test (org.junit.Test)6 S3BucketEntity (com.amazonaws.services.s3.event.S3EventNotification.S3BucketEntity)5 InputStreamReader (java.io.InputStreamReader)4 Attribute (org.finra.herd.model.api.xml.Attribute)3 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)3 SNSEvent (com.amazonaws.services.lambda.runtime.events.SNSEvent)2 SNSRecord (com.amazonaws.services.lambda.runtime.events.SNSEvent.SNSRecord)2 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)2 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)2 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)2 UploadSingleInitiationResponse (org.finra.herd.model.api.xml.UploadSingleInitiationResponse)2 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)2