-
Notifications
You must be signed in to change notification settings - Fork 909
Added support for s3-event-notifications in migration tool #6059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f9f84c9
initial recipe added for s3 event notification
Fred1155 a084fd0
WIP
Fred1155 988c754
WIP
Fred1155 3ee666e
Merge branch 'master' into bole/s3-event-notification-migration
Fred1155 3b0510c
test case added and fixed
Fred1155 7a35010
getEventNameAsEnum test added
Fred1155 642ad12
Merge branch 'master' into bole/s3-event-notification-migration
Fred1155 056a76d
delete unnecessary method
Fred1155 3cd160f
comments for DateTime added
Fred1155 5f73a47
Merge branch 'master' into bole/s3-event-notification-migration
Fred1155 f539eb8
added recipe for getEventTime
Fred1155 b70c079
one more method covered
Fred1155 f59fec0
checkstyle fixed
Fred1155 2d0e0c5
updated recipe with tm
Fred1155 e93b08e
Merge branch 'master' into bole/s3-event-notification-migration
Fred1155 ac1df7e
test module merged
Fred1155 25c8d23
Merge branch 'master' into bole/s3-event-notification-migration
Fred1155 354e174
test case fixed
Fred1155 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...s/src/test/java/software/amazon/awssdk/v2migrationtests/MavenS3EventNotificationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.v2migrationtests; | ||
|
||
import static software.amazon.awssdk.v2migrationtests.TestUtils.replaceVersion; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import org.apache.commons.io.FileUtils; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledIf; | ||
|
||
public class MavenS3EventNotificationTest extends MavenTestBase { | ||
|
||
@BeforeAll | ||
static void setUp() throws IOException { | ||
mavenBefore = new File(MavenS3EventNotificationTest.class.getResource("maven-en/before").getFile()).toPath(); | ||
mavenAfter = new File(MavenS3EventNotificationTest.class.getResource("maven-en/after").getFile()).toPath(); | ||
target = new File(MavenS3EventNotificationTest.class.getResource("/").getFile()).toPath().getParent(); | ||
|
||
mavenActual = target.resolve("maven-en/actual"); | ||
mavenExpected = target.resolve("maven-en/expected"); | ||
|
||
deleteTempDirectories(); | ||
|
||
FileUtils.copyDirectory(mavenBefore.toFile(), mavenActual.toFile()); | ||
FileUtils.copyDirectory(mavenAfter.toFile(), mavenExpected.toFile()); | ||
|
||
replaceVersion(mavenExpected.resolve("pom.xml"), sdkVersion); | ||
replaceVersion(mavenActual.resolve("pom.xml"), sdkVersion); | ||
} | ||
|
||
@Test | ||
@EnabledIf("versionAvailable") | ||
void mavenProject_shouldConvert() throws IOException { | ||
boolean experimental = false; | ||
verifyTransformation(experimental); | ||
verifyCompilation(); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...n-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-en/after/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"). | ||
~ You may not use this file except in compliance with the License. | ||
~ A copy of the License is located at | ||
~ | ||
~ http://aws.amazon.com/apache2.0 | ||
~ | ||
~ or in the "license" file accompanying this file. This file is distributed | ||
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
~ express or implied. See the License for the specific language governing | ||
~ permissions and limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>sample-application</artifactId> | ||
<version>1.2.3</version> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>bom</artifactId> | ||
<version>V2_VERSION</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>s3</artifactId> | ||
<version>V2_VERSION</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
<version>2.12.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>s3-event-notifications</artifactId> | ||
<version>V2_VERSION</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
70 changes: 70 additions & 0 deletions
70
...awssdk/v2migrationtests/maven-en/after/src/main/java/foo/bar/S3EventNotificationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package foo.bar; | ||
|
||
import software.amazon.awssdk.eventnotifications.s3.model.S3Bucket; | ||
import software.amazon.awssdk.eventnotifications.s3.model.S3EventNotification; | ||
import software.amazon.awssdk.eventnotifications.s3.model.S3; | ||
import software.amazon.awssdk.eventnotifications.s3.model.S3EventNotificationRecord; | ||
import software.amazon.awssdk.eventnotifications.s3.model.S3Object; | ||
import software.amazon.awssdk.eventnotifications.s3.model.RequestParameters; | ||
import software.amazon.awssdk.eventnotifications.s3.model.ResponseElements; | ||
import software.amazon.awssdk.eventnotifications.s3.model.RestoreEventData; | ||
import software.amazon.awssdk.eventnotifications.s3.model.UserIdentity; | ||
import software.amazon.awssdk.eventnotifications.s3.model.GlacierEventData; | ||
import software.amazon.awssdk.eventnotifications.s3.model.LifecycleEventData; | ||
import software.amazon.awssdk.eventnotifications.s3.model.IntelligentTieringEventData; | ||
import software.amazon.awssdk.eventnotifications.s3.model.ReplicationEventData; | ||
import org.joda.time.DateTime; | ||
|
||
public class S3EventNotificationTest { | ||
public void parseEvent(String jsonInput) { | ||
S3EventNotification notification = S3EventNotification.fromJson(jsonInput); | ||
|
||
for (S3EventNotificationRecord record : notification.getRecords()) { | ||
S3 s3 = record.getS3(); | ||
|
||
S3Bucket bucket = s3.getBucket(); | ||
|
||
S3Object object = s3.getObject(); | ||
|
||
String eventName = record.getEventName(); | ||
|
||
String eventNameEnum = record.getEventName(); | ||
|
||
DateTime eventTime = /*AWS SDK for Java v2 migration: getEventTime returns Instant instead of DateTime in v2. AWS SDK v2 does not include org.joda.time as a dependency. If you want to keep using DateTime, you'll need to manually add "org.joda.time:joda-time" dependency to your project after migration.*/new DateTime(record.getEventTime().toEpochMilli()); | ||
|
||
dagnir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
RequestParameters requestParams = record.getRequestParameters(); | ||
|
||
ResponseElements responseElements = record.getResponseElements(); | ||
|
||
UserIdentity userIdentity = record.getUserIdentity(); | ||
|
||
GlacierEventData glacierEventData = record.getGlacierEventData(); | ||
|
||
RestoreEventData restoreEventData = glacierEventData.getRestoreEventData(); | ||
|
||
DateTime expireTime = /*AWS SDK for Java v2 migration: getLifecycleRestorationExpiryTime returns Instant instead of DateTime in v2. AWS SDK v2 does not include org.joda.time as a dependency. If you want to keep using DateTime, you'll need to manually add "org.joda.time:joda-time" dependency to your project after migration.*/new DateTime(restoreEventData.getLifecycleRestorationExpiryTime().toEpochMilli()); | ||
|
||
LifecycleEventData lifecycleEventData = record.getLifecycleEventData(); | ||
|
||
IntelligentTieringEventData intelligentTieringEventData = record.getIntelligentTieringEventData(); | ||
|
||
ReplicationEventData replicationEventData = record.getReplicationEventData(); | ||
} | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-en/before/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"). | ||
~ You may not use this file except in compliance with the License. | ||
~ A copy of the License is located at | ||
~ | ||
~ http://aws.amazon.com/apache2.0 | ||
~ | ||
~ or in the "license" file accompanying this file. This file is distributed | ||
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
~ express or implied. See the License for the specific language governing | ||
~ permissions and limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>sample-application</artifactId> | ||
<version>1.2.3</version> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-bom</artifactId> | ||
<version>1.12.782</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-s3</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
<version>2.12.5</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
73 changes: 73 additions & 0 deletions
73
...wssdk/v2migrationtests/maven-en/before/src/main/java/foo/bar/S3EventNotificationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package foo.bar; | ||
|
||
import com.amazonaws.services.s3.AmazonS3; | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder; | ||
import com.amazonaws.services.s3.event.S3EventNotification; | ||
import com.amazonaws.services.s3.event.S3EventNotification.S3BucketEntity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.S3Entity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord; | ||
import com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.RequestParametersEntity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.ResponseElementsEntity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.RestoreEventDataEntity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.UserIdentityEntity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.GlacierEventDataEntity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.LifecycleEventDataEntity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.IntelligentTieringEventDataEntity; | ||
import com.amazonaws.services.s3.event.S3EventNotification.ReplicationEventDataEntity; | ||
import com.amazonaws.services.s3.model.S3Event; | ||
import org.joda.time.DateTime; | ||
|
||
public class S3EventNotificationTest { | ||
public void parseEvent(String jsonInput) { | ||
S3EventNotification notification = S3EventNotification.parseJson(jsonInput); | ||
|
||
for (S3EventNotificationRecord record : notification.getRecords()) { | ||
S3Entity s3 = record.getS3(); | ||
|
||
S3BucketEntity bucket = s3.getBucket(); | ||
|
||
S3ObjectEntity object = s3.getObject(); | ||
|
||
String eventName = record.getEventName(); | ||
|
||
S3Event eventNameEnum = record.getEventNameAsEnum(); | ||
|
||
DateTime eventTime = record.getEventTime(); | ||
|
||
RequestParametersEntity requestParams = record.getRequestParameters(); | ||
|
||
ResponseElementsEntity responseElements = record.getResponseElements(); | ||
|
||
UserIdentityEntity userIdentity = record.getUserIdentity(); | ||
|
||
GlacierEventDataEntity glacierEventData = record.getGlacierEventData(); | ||
|
||
RestoreEventDataEntity restoreEventData = glacierEventData.getRestoreEventData(); | ||
|
||
DateTime expireTime = restoreEventData.getLifecycleRestorationExpiryTime(); | ||
|
||
LifecycleEventDataEntity lifecycleEventData = record.getLifecycleEventData(); | ||
|
||
IntelligentTieringEventDataEntity intelligentTieringEventData = record.getIntelligentTieringEventData(); | ||
|
||
ReplicationEventDataEntity replicationEventData = record.getReplicationEventDataEntity(); | ||
} | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.