0% found this document useful (0 votes)
3 views7 pages

Updated Code

The document outlines the requirements for integration testing of the SelfService Dev system with Edifecs, focusing on verifying the end-to-end flow of data processing and email notifications. Key changes include modifying the EmailService to attach processed files from S3 to emails, ensuring complete code coverage, and promoting the changes to the Test region. It also provides detailed code updates and testing steps to validate the implementation.

Uploaded by

Sabari .s
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Updated Code

The document outlines the requirements for integration testing of the SelfService Dev system with Edifecs, focusing on verifying the end-to-end flow of data processing and email notifications. Key changes include modifying the EmailService to attach processed files from S3 to emails, ensuring complete code coverage, and promoting the changes to the Test region. It also provides detailed code updates and testing steps to validate the implementation.

Uploaded by

Sabari .s
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Good — you shared both ticket screenshot + full working code. I’ll explain clearly in 3 parts:
1. What your ticket is asking (Simple Explanation)

📌
From your screenshot:

🔹
Ticket: SelfService Dev Integration Testing
Description:

👉
“Edifecs changes are ready → do integration testing in Dev”
Meaning:
Your system is already generating CSV → S3 → SQS → Edifecs

🔹
Now you must verify full flow works end-to-end
Acceptance Criteria (VERY IMPORTANT)

👉
1. Consume DCN extract from S3
Your system should:
Read file placed by Edifecs in S3

📍
Process it
Already partially implemented in:
SelfServiceSQSListener.readCSVFromS3()

👉
2. Attach DCN extract + send email to user
After processing:
Take that DCN extract file

🚨
Send it as email attachment


CURRENT STATUS:
Your EmailService does NOT attach file

👉
Only sends text mail
THIS is the MAIN CHANGE required

👉
3. Complete code coverage
Ensure:
All flows tested (success + error)
No missing scenarios

👉
4. Promote to Test region


Deployment step (no code change)
2. Where you need to modify your code

🔥 MAIN CHANGE AREAS:


✅ CHANGE 1: Attach file in Email
📍 File:
❌ Current:
[Link]

Java
Copy code

👉
[Link](fromEmail, recipients, subject, body, null);


No attachment
Required:
Read file from S3
Convert to attachment
Send in email
✅ CHANGE 2: Read processed file from S3
📍 File:
👉 You already have:
[Link]

Java
Copy code

👉
readCSVFromS3(s3Key)
But you also need:
Full file content (not only DCNs)
Pass file to EmailService

✅ CHANGE 3: Final Email after Edifecs processing


📍 File:
👉 This part:
[Link]()

Java
Copy code
if ("EDIFECS_PROCESSING_COMPLETE".equals(status)) {
sendFinalCompletionEmail(...)

👉
}
This method must:
Fetch file from S3
Attach file
Send mail

✅ 3. Updated Code (IMPORTANT PART ONLY)


🔥 1. Update EmailService (Add Attachment Support)
Java
Copy code
import [Link];
import [Link].Base64;

public boolean sendMailWithAttachment(String toMail, String subject, String body, byte[]


fileData, String fileName) {
try {
FileAttachment attachment = new FileAttachment();
[Link] = fileName;
[Link] = fileData;

[Link](
fromEmail,
new String[]{toMail},
subject,
body,
[Link](attachment)
);
return true;
} catch (Exception e) {
[Link]("Error sending email with attachment", e);
return false;
}
}

🔥 2. Add S3 File Read Method


📍 In [Link]
Java
Copy code
private byte[] getFileFromS3(String s3Key) {
try {
GetObjectRequest request = [Link]()
.bucket(bucket)
.key(s3Key)
.build();

ResponseInputStream<GetObjectResponse> response = [Link](request);


return [Link]();

} catch (Exception e) {
[Link]("Error reading file from S3", e);
return null;
}
}

🔥 3. Final Email with Attachment


📍 Modify:
processSelfServiceResponse()
Java
Copy code
if ("EDIFECS_PROCESSING_COMPLETE".equals(status)) {

byte[] fileData = getFileFromS3((String) [Link]("s3Key"));

String subject = "DCN Request Completed - " + transactionReference;

String body = "Your DCN request is completed. Please find attached file.";

[Link](
userEmail,
subject,
body,
fileData,
"DCN_Result.csv"
);
updateDatabaseStatus(transactionReference, "COMPLETED");
}

✅ 4. Summary (VERY IMPORTANT FOR INTERVIEW)


👉 Your system flow after change:
User submits DCN
CSV created → stored in S3
Message sent to SQS
Edifecs processes file


Response comes back
You:
Read processed file from S3
Attach file

🚀
Send email to user

👉
Final Answer
Main work in your ticket:
Add file attachment in email
Fetch processed file from S3
Send to user after Edifecs processing



If you want, I can next: Show exact line-by-line changes in your existing file

👍
Or give Postman testing steps for this ticket
Just tell

👍

Great let’s go step-by-step and make it very practical for you.

🔧
1. Exact Changes (Line-by-Line)

🔹
FILE 1: [Link]
ADD this new method (don’t remove existing one)

import [Link];
import [Link].Base64;
import [Link];

public boolean sendMailWithAttachment(String toMail, String subject, String body, byte[]


fileData, String fileName) {
try {
FileAttachment attachment = new FileAttachment();
[Link] = fileName;
[Link] = fileData;

[Link](
fromEmail,
new String[]{toMail},
subject,
body,
[Link](attachment) // ✅ attachment added
);

[Link]("Email with attachment sent to: {}", toMail);


return true;

} catch (Exception e) {
[Link]("Error sending email with attachment", e);
return false;
}
}

🔧 FILE 2: [Link]
🔹 ADD this method
Java
Copy code
private byte[] getFileFromS3(String s3Key) {
try {
GetObjectRequest request = [Link]()
.bucket(bucket)
.key(s3Key)
.build();

ResponseInputStream<GetObjectResponse> response = [Link](request);

return [Link](); // ✅ full file


} catch (Exception e) {
[Link]("Error reading file from S3: {}", [Link](), e);
return null;
}
}

🔹 MODIFY this method


📍 Find:
Java
Copy code
@SqsListener("${[Link]-url}")
public void processSelfServiceResponse(String message)

🔹 REPLACE inside:
Java
Copy code
if ("EDIFECS_PROCESSING_COMPLETE".equals(status)) {
sendFinalCompletionEmail(transactionReference, userEmail, responseMap);
updateDatabaseStatus(transactionReference, "COMPLETED");
🔥 WITH THIS:
}

Java
Copy code
if ("EDIFECS_PROCESSING_COMPLETE".equals(status)) {

String s3Key = (String) [Link]("s3Key");

byte[] fileData = getFileFromS3(s3Key);

String subject = "DCN Request Completed - " + transactionReference;

String body = "<html><body>" +


"<p>Your DCN request has been completed.</p>" +
"<p>Please find the attached DCN extract file.</p>" +
"</body></html>";

[Link](
userEmail,
subject,
body,
fileData,
"DCN_Extract.csv"
);

[Link]("Final email sent with attachment for transaction: {}", transactionReference);

updateDatabaseStatus(transactionReference, "COMPLETED");
}

✅ 2. Testing Steps (VERY IMPORTANT)


🔹 Step 1: Trigger API
Use Postman:
API:
Copy code

POST /api/selfservice/submit-dcn
Body:
JSON
Copy code
{
"email": "yourmail@[Link]",
"dcnList": "12345,67890"
}

🔹 Step 2: Check Logs


Look for:
Copy code

CSV file created for self-service


Message sent to SQS

🔹 Step 3: Verify S3
Check:
CSV file created in bucket

🔹 Step 4: Simulate Edifecs Response


Send message manually to SQS response queue:
JSON
Copy code
{
"transactionReference": "XR0000001",
"status": "EDIFECS_PROCESSING_COMPLETE",
"userEmail": "yourmail@[Link]",
"s3Key": "[Link]"
}

🔹 Step 5: Expected Result


✅ Email received
✅ Email contains attachment (CSV file)
✅ 3. What You Achieved (Interview Answer)
If interviewer asks 👇
👉 “What did you do in this ticket?”
Answer:
I implemented integration between Self-Service and Edifecs by enhancing the email
notification flow. After Edifecs processing completes, I fetch the processed DCN extract file
from AWS S3, attach it to the email, and send it to the end user. This ensures users receive

🚀
the final output file directly via email.
Done!

You might also like