Skip to content

Commit

Permalink
Remove static analysis warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelaferreira committed Sep 3, 2023
1 parent 1b39722 commit a4baed6
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import io.micronaut.serde.annotation.Serdeable;
import lombok.Data;
import lombok.ToString;
import ses.notification.lambda.SesEvent;
import ses.notification.lambda.SesMessageMail;
import ses.notification.lambda.SesNotification;

import java.time.LocalDateTime;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import io.micronaut.serde.annotation.Serdeable;
import lombok.Data;
import lombok.ToString;
import ses.notification.lambda.SesEvent;
import ses.notification.lambda.SesMessageMail;
import ses.notification.lambda.SesNotification;

import java.time.LocalDateTime;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public class BounceEmailReport extends EmailReport {
public static final String BOUNCED_ADDRESS_ERROR_MESSAGE = ", Error message: ";
public static final String NA = "NA";

private String bounceType;
private String bounceReason;

public BounceEmailReport(ReportingConfiguration configuration, SesBounceMessage message) {
super(BOUNCE_REPORT_SUBJECT, configuration.getFrom(), configuration.getTo(), getBounceBody(message));
}
Expand Down
195 changes: 101 additions & 94 deletions src/test/java/ses/notification/lambda/DeserializationServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ class DeserializationServiceTest {

@Test
void readDeliveryNotification() throws IOException {
String notification = ""
+ "{"
+ "\"notificationType\": \"Delivery\""
+ "}";
String notification = """
{
"notificationType": "Delivery"
}
""";

final SesMessage sesMessage = deserializationService.readSesMessage(notification);

Expand All @@ -29,10 +30,12 @@ void readDeliveryNotification() throws IOException {

@Test
void readDeliveryEvent() throws IOException {
String notification = ""
+ "{"
+ "\"eventType\": \"Delivery\""
+ "}";
String notification = """
{
"eventType": "Delivery"
}
""";


final SesMessage sesMessage = deserializationService.readSesMessage(notification);

Expand All @@ -41,10 +44,11 @@ void readDeliveryEvent() throws IOException {

@Test
void readBounceNotification() throws IOException {
String notification = ""
+ "{"
+ "\"notificationType\": \"Bounce\""
+ "}";
String notification = """
{
"notificationType": "Bounce"
}
""";

final SesMessage sesMessage = deserializationService.readSesMessage(notification);

Expand All @@ -53,84 +57,86 @@ void readBounceNotification() throws IOException {

@Test
void readBounceEvent() throws IOException {
String notification = "{\n" +
" \"eventType\": \"Bounce\",\n" +
" \"bounce\": {\n" +
" \"feedbackId\": \"0100017f5acb69b0-6c754b6c-3cfd-423f-8d91-2cc01b3d7f75-000000\",\n" +
" \"bounceType\": \"Permanent\",\n" +
" \"bounceSubType\": \"General\",\n" +
" \"bouncedRecipients\": [\n" +
" {\n" +
" \"emailAddress\": \"[email protected]\",\n" +
" \"action\": \"failed\",\n" +
" \"status\": \"5.1.1\",\n" +
" \"diagnosticCode\": \"smtp; 550 5.1.1 user unknown\"\n" +
" }\n" +
" ],\n" +
" \"timestamp\": \"2022-03-05T15:55:54.762Z\",\n" +
" \"reportingMTA\": \"dns; a8-62.smtp-out.amazonses.com\"\n" +
" },\n" +
" \"mail\": {\n" +
" \"timestamp\": \"2022-03-05T15:55:53.969Z\",\n" +
" \"source\": \"[email protected]\",\n" +
" \"sourceArn\": \"arn:aws:ses:us-east-1:844875565510:identity/gresb.com\",\n" +
" \"sendingAccountId\": \"844875565510\",\n" +
" \"messageId\": \"0100017f5acb66f1-e509f90c-9c19-4dd6-ae93-bb7a0f7ea93c-000000\",\n" +
" \"destination\": [\n" +
" \"[email protected]\"\n" +
" ],\n" +
" \"headersTruncated\": false,\n" +
" \"headers\": [\n" +
" {\n" +
" \"name\": \"From\",\n" +
" \"value\": \"[email protected]\"\n" +
" },\n" +
" {\n" +
" \"name\": \"To\",\n" +
" \"value\": \"[email protected]\"\n" +
" },\n" +
" {\n" +
" \"name\": \"Subject\",\n" +
" \"value\": \"dafasdf\"\n" +
" },\n" +
" {\n" +
" \"name\": \"MIME-Version\",\n" +
" \"value\": \"1.0\"\n" +
" },\n" +
" {\n" +
" \"name\": \"Content-Type\",\n" +
" \"value\": \"multipart/alternative; boundary=\\\"----=_Part_1237092_28065239.1646495753972\\\"\"\n" +
" }\n" +
" ],\n" +
" \"commonHeaders\": {\n" +
" \"from\": [\n" +
" \"[email protected]\"\n" +
" ],\n" +
" \"to\": [\n" +
" \"[email protected]\"\n" +
" ],\n" +
" \"messageId\": \"0100017f5acb66f1-e509f90c-9c19-4dd6-ae93-bb7a0f7ea93c-000000\",\n" +
" \"subject\": \"dafasdf\"\n" +
" },\n" +
" \"tags\": {\n" +
" \"ses:operation\": [\n" +
" \"SendEmail\"\n" +
" ],\n" +
" \"ses:configuration-set\": [\n" +
" \"gresb-ses-config\"\n" +
" ],\n" +
" \"ses:source-ip\": [\n" +
" \"45.95.65.150\"\n" +
" ],\n" +
" \"ses:from-domain\": [\n" +
" \"gresb.com\"\n" +
" ],\n" +
" \"ses:caller-identity\": [\n" +
" \"gresb-root-developer-break-glass\"\n" +
" ]\n" +
" }\n" +
" }\n" +
"}";
String notification = """
{
"eventType": "Bounce",
"bounce": {
"feedbackId": "0100017f5acb69b0-6c754b6c-3cfd-423f-8d91-2cc01b3d7f75-000000",
"bounceType": "Permanent",
"bounceSubType": "General",
"bouncedRecipients": [
{
"emailAddress": "[email protected]",
"action": "failed",
"status": "5.1.1",
"diagnosticCode": "smtp; 550 5.1.1 user unknown"
}
],
"timestamp": "2022-03-05T15:55:54.762Z",
"reportingMTA": "dns; a8-62.smtp-out.amazonses.com"
},
"mail": {
"timestamp": "2022-03-05T15:55:53.969Z",
"source": "[email protected]",
"sourceArn": "arn:aws:ses:us-east-1:844875565510:identity/gresb.com",
"sendingAccountId": "844875565510",
"messageId": "0100017f5acb66f1-e509f90c-9c19-4dd6-ae93-bb7a0f7ea93c-000000",
"destination": [
"[email protected]"
],
"headersTruncated": false,
"headers": [
{
"name": "From",
"value": "[email protected]"
},
{
"name": "To",
"value": "[email protected]"
},
{
"name": "Subject",
"value": "dafasdf"
},
{
"name": "MIME-Version",
"value": "1.0"
},
{
"name": "Content-Type",
"value": "multipart/alternative; boundary=\\"----=_Part_1237092_28065239.1646495753972\\""
}
],
"commonHeaders": {
"from": [
"[email protected]"
],
"to": [
"[email protected]"
],
"messageId": "0100017f5acb66f1-e509f90c-9c19-4dd6-ae93-bb7a0f7ea93c-000000",
"subject": "dafasdf"
},
"tags": {
"ses:operation": [
"SendEmail"
],
"ses:configuration-set": [
"gresb-ses-config"
],
"ses:source-ip": [
"45.95.65.150"
],
"ses:from-domain": [
"gresb.com"
],
"ses:caller-identity": [
"gresb-root-developer-break-glass"
]
}
}
}
""";

final SesMessage sesMessage = deserializationService.readSesMessage(notification);

Expand All @@ -139,10 +145,11 @@ void readBounceEvent() throws IOException {

@Test
void readComplaintNotification() throws IOException {
String notification = ""
+ "{"
+ "\"notificationType\": \"Complaint\""
+ "}";
String notification = """
{
"notificationType": "Complaint"
}
""";

final SesMessage sesMessage = deserializationService.readSesMessage(notification);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ses.notification.lambda;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -14,8 +13,6 @@ public class FunctionRequestHandlerTest {

private static FunctionRequestHandler requestHandler;

private static final ObjectMapper MAPPER = new ObjectMapper();

@BeforeAll
public static void setupServer() {
final ReportingConfiguration configuration = new ReportingConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MicronautSerializationTest {
@Inject
private ObjectMapper mapper;

private String event = """
private final String event = """
{
"Records": [
{
Expand Down
1 change: 0 additions & 1 deletion src/test/java/ses/notification/lambda/TestDataFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class TestDataFactory {
public static final String TEST_1_EMAIL_COM = "[email protected]";
public static final String TEST_1_EMAIL_COM_WITH_NAME = String.format("Test 1 <%s>", TEST_1_EMAIL_COM);
public static final String TEST_2_EMAIL_COM = "[email protected]";
public static final String TEST_2_EMAIL_COM_WITH_NAME = String.format("Test 2 <%s>", TEST_2_EMAIL_COM);
public static final String TEST_SUBJECT = "Test subject";
public static final String FROM_1_EMAIL_COM = "[email protected]";
public static final String FROM_2_EMAIL_COM = "[email protected]";
Expand Down

0 comments on commit a4baed6

Please sign in to comment.