package com.worth.ifs.sil.experian.controller;

import com.worth.ifs.BaseControllerMockMVCTest;
import org.junit.Test;
import org.springframework.test.web.servlet.MvcResult;

import static com.worth.ifs.sil.experian.controller.ExperianEndpointController.validationErrors;
import static com.worth.ifs.util.JsonMappingUtil.toJson;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

/**
 * Tests around the SIL email stub
 */
public class ExperianEndpointControllerMockMvcTest extends BaseControllerMockMVCTest<ExperianEndpointController> {

    @Override
    protected ExperianEndpointController supplyControllerUnderTest() {
        return new ExperianEndpointController();
    }

    @Test
    public void testExperianValidate() throws Exception {
        validationErrors.keySet().forEach(bankDetails -> {
            String requestBody = toJson(bankDetails);
            try {
                MvcResult result = mockMvc.
                        perform(
                                post("/silstub/experianValidate").
                                        header("Content-Type", "application/json").
                                        header("IFS_AUTH_TOKEN", "123abc").
                                        content(requestBody)
                        ).
                        andExpect(status().isOk()).
                        andReturn();
                result.getResponse();
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
}
@@ -265,16 +265,116 @@
 Errors;%0A
+import static com.worth.ifs.sil.experian.controller.ExperianEndpointController.verificationResults;%0A
 import s
@@ -1595,30 +1595,667 @@
     
-    result.getResponse
+%7D catch (Exception e) %7B%0A                e.printStackTrace();%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @Test%0A    public void testExperianVerify() throws Exception %7B%0A        verificationResults.keySet().forEach(accountDetails -%3E %7B%0A            String requestBody = toJson(accountDetails);%0A            try%7B%0A                MvcResult result = mockMvc.perform(%0A                        post(%22/silstub/experianVerify%22).%0A                                header(%22Content-Type%22, %22application/json%22).%0A                                header(%22IFS_AUTH_TOKEN%22, %22123abc%22).%0A                                content(requestBody)%0A                ).andExpect(status().isOk()).andReturn
 ();%0A
@@ -2279,33 +2279,32 @@
 ch (Exception e)
- 
 %7B%0A              

Add mock mvc test for experian verify