DEV Community

Charlie Fubon
Charlie Fubon

Posted on

Hsja

Of course. This is a very common and important task in API development. Your team lead wants you to perform an end-to-end test to prove that your running application can accept a request, process it correctly, and return a response.

Based on the code you've provided, here is a step-by-step guide to doing exactly that using Postman.

The Goal

The objective is to send a valid JSON request to your running "Merchant-Intake" application. We want to see the application's logs show the request being processed by the filters (especially the DateFilter and RequestMdcFilter) and then receive a successful 200 OK response in Postman.


Step 1: Start Your Application

First, make sure your Spring Boot application is running. You can typically do this from your IDE (like IntelliJ or VS Code) or by running the mvn spring-boot:run command in your terminal.

You should see log messages in your console indicating that the application has started successfully on port 8385.

...
o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8385 (http) with context path ''
...
c.t.f.f.m.i.MerchantIntakeApplication   : Started MerchantIntakeApplication in X.XXX seconds (JVM running for Y.YYY)
Enter fullscreen mode Exit fullscreen mode

Step 2: Create and Configure the Request in Postman

Now, let's build the HTTP request in Postman.

A. Set the Method and URL

  1. Open Postman and click the + button to create a new request.
  2. Change the HTTP method from the default GET to POST.
  3. In the URL bar, enter the address for your local endpoint. Based on your FinNonmonController, you can use either /fraudcheck or /fraudeventcapturenonfin. Let's use /fraudcheck.

    URL: http://localhost:8385/fraudcheck

B. Set the Headers

APIs need headers to understand the incoming request. The most important one here is Content-Type. Let's also add the TraceabilityID that your RequestMdcFilter looks for.

  1. Go to the Headers tab.
  2. Add the following two key-value pairs:
Key Value Description
Content-Type application/json Tells the server you are sending a JSON payload.
TraceabilityID postman-test-12345 This will be picked up by RequestMdcFilter and added to your logs.

C. Create the Request Body

This is the most critical part. You need to provide a JSON payload that matches the structure your application expects. Based on a detailed analysis of your filters and utility classes (DateFilter, RequestMdcFilter, ValidatorUtils), a valid request needs several key pieces of information.

  1. Go to the Body tab.
  2. Select the raw radio button.
  3. From the dropdown on the right that says Text, select JSON.
  4. Copy and paste the following JSON payload into the text area.
{
  "fraudEvent": {
    "initiationChannelInstance": [
      {
        "accessChannel": "WEB",
        "processingChannel": "MERCHANT_PORTAL"
      }
    ],
    "authenticationInfo": {
      "authenticationIdentity": [
        {
          "authenticationMethodTypeCd": "AccessCard",
          "authenticateId": "1234567890123456"
        }
      ]
    }
  },
  "event": {
    "financialEvent": [
      {
        "activityTypeCd": "PURCHASE",
        "eventDttm": "2025-10-09T18:30:00",
        "terminal": {
          "localDttm": "2025-10-09T14:30:00"
        }
      }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

Why this specific JSON?

  • "event" and "financialEvent": This structure is required to reach the data processed by DateFilter and CommonEventUtils.
  • "eventDttm" and "localDttm": These fields will be targeted and reformatted by your DateFilter. Notice they don't have a Z at the end, which will test the logic in your convertToOffsetDateFormat method.
  • "fraudEvent" and "initiationChannelInstance": RequestMdcFilter uses this to get the accessChannel for logging.
  • "authenticationInfo": Your CommonValidator (via ValidatorUtils.isMandatoryAuthIdentityProvided) checks that at least one form of identification like AccessCard is present. Without this, the request would likely be invalid.
  • "activityTypeCd": This is extracted by RequestMdcFilter and put into the logs.

Step 3: Send the Request and Analyze the Results

Now you are ready to test.

A. Send the Request

Click the blue Send button in Postman.

B. Check the Postman Response

If everything is configured correctly, you should see the following in the bottom pane of Postman:

  1. Status Code: 200 OK. This is the most important indicator of success. It means your application received the request, processed it without any major errors, and sent back a normal response.
  2. Response Body: The body will likely be an empty JSON object {}. This is because your controller method fraudCheck currently just does var fraudCheckEventResponse = new FraudCheckEventResponse(); and returns it. This is perfectly fine for this test!

C. Check Your Application Logs

This is the "log it" part of your team lead's request. Look at the console where your Spring Boot application is running. You should see new log output that was generated by your request. Look for key indicators:

  • Filter Initialization Logs: When the app starts, you see logs from FilterConfig like tdDateFilter: ****Filter @Order(2) =*******tdDateFilter***********.
  • MDC Logs: This is the key. Thanks to RequestMdcFilter, your logs for this specific request should be automatically enriched with the context you provided. You will see the TraceabilityID, eventCode, and channelID in the log lines.

    A log line might look something like this (the format depends on your logging configuration):

    2025-10-09 18:30:01.123 INFO [http-nio-8385-exec-1] [TraceabilityID=postman-test-12345] [eventCode=PURCHASE] [channelID=WEB] c.t.f.f.m.i.c.f.FinNonmonController : Starting fraud check process...
    

    Seeing these values from your Postman request appear in the server logs is proof that your filters and data extraction logic are working correctly.


What to Tell Your Team Lead

You can now confidently go to your team lead and say:

"I've tested the /fraudcheck endpoint using Postman. I sent a valid request, and the application processed it successfully, returning a 200 OK response. I've also confirmed in the logs that the RequestMdcFilter is correctly extracting the TraceabilityID and other details, and the DateFilter is processing the date fields as expected. The end-to-end flow is working."

Top comments (0)