this my IDVController class where I have added a new parameter in the initialize endpoint to input the header and added the logic to check the header to enable stubbing accordingly.
package com.sc.we.idv.controller;
@RestController
@RequestMapping("${context.path}")
public class IDVController {
code
Assistant
User
I am getting the below error after the fix:
Failures: [m
[ERROR] [1;31m IDVControllerTest.testInitializeInvalidSourceCountry:454 Unexpected exception type thrown, expected: <com.sc.we.idv.exceptions.FieldValueNotInRangeException> but was: <java.lang.NullPointerException>[m
[ERROR] [1;31m IDVControllerTest.testInitializeValidateErrorMessagesforLengthMax:619 expected: <[source-country is invalid, service-type should not exceed 3 char, source-country should not exceed 2 char, system-identifier should not exceed 2 char, channel-reference should not exceed 35 char, segment-code should not exceed 2 char, product-identifier should not exceed 1 char]> but was: <Cannot invoke "com.sc.we.idv.config.SharedConfig.setShouldStubInitialize(boolean)" because "this.sharedConfig" is null>[m
[ERROR] [1;31m IDVControllerTest.testInitializeValidateErrorMessagesforMinLength:698 expected: <[source-country is invalid, service-type should be minimum 3 char, source-country should be minimum 2 char, system-identifier should be minimum 2 char]> but was: <Cannot invoke "com.sc.we.idv.config.SharedConfig.setShouldStubInitialize(boolean)" because "this.sharedConfig" is null>
public class IDVControllerTest extends IDVBaseTest {
code
@Mock
private IDVService idvService;
@InjectMocks
private IDVController controller;
@Mock
private RequestFieldValidator requestFieldValidator;
@Mock
private IdTypeConfig idTypeConfig;
@Mock
private LoggerContextService loggerContextService;
@Mock
private Environment env;
@Test
public void testGetDemographics() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setServiceType("NEW");
req.getServiceInfo().setAckReference("ABCD1234");
req.getInternalInfo().setSourceCountry("VN");
req.getCustomerDetails().setFullname("Nguyễn Trường");
req.getCustomerDetails().setAddress("Eco space");
req.getCustomerDetails().setCustomerPhoto("aaaa");
req.getCustomerDetails().setDocumentNumber("A1001");
req.getCustomerDetails().setDateOfBirth("2021-12-24");
req.getCustomerDetails().setCustomerDetail("IVA");
req.getCustomerDetails().setIdDetails("123");
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
// When
ResponseEntity<DemographicResponse> res = controller.getDemographics(req);
// Then
assertNotNull(res);
assertNotNull(res.getBody());
assertEquals(res.getBody().getIdDetails().getDocumentNumber(), "DOCNO 123");
}
@Test
public void testGetDemographics_onlyMandatoryFields() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setServiceType("NEW");
req.getInternalInfo().setSourceCountry("VN");
req.getServiceInfo().setAckReference("ABCD1234");
req.setCustomerDetails(null);
req.setCustomerAuthentication(null);
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
// When
ResponseEntity<DemographicResponse> res = controller.getDemographics(req);
// Then
assertNotNull(res);
assertNotNull(res.getBody());
assertEquals(res.getBody().getIdDetails().getDocumentNumber(), "DOCNO 123");
}
@Test
public void testEnquiry() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
// Then
assertNotNull(response);
assertNotNull(response.getBody());
assertEquals(response.getBody().getVerificationResult().getOverallStatus(), "Success");
}
@Test
public void testGetDemographicMissingMandatoryFieldForNullFields() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setServiceType(null);
req.getInternalInfo().setSourceCountry(null);
req.getInternalInfo().setSystemIdentifier(null);
req.getServiceInfo().setTransactionReference(null);
req.getServiceInfo().setAckReference(null);
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
try {
// When
ResponseEntity<DemographicResponse> res = controller.getDemographics(req);
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals(
"[service-type, source-country, system-identifier, transaction-reference, ack-reference] : Mandatory Fields are Missing",
e.getMessage());
}
}
@Test
public void testEnquiryIncorrectServicetype() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getInternalInfo().setServiceType("Enquiry");
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
try {
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals(
"[SystemIdentifier should only contain Enquiry]",
e.getMessage());
}
}
@Test
public void testEnquiryIncorrectSystemIdentifierField() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getInternalInfo().setSystemIdentifier("05");
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
try {
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals("[SystemIdentifier should only contain 01,02,03,04]", e.getMessage());
}
}
@Test
public void testEnquiryIncorrectProductIdentifierField() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getServiceInfo().setProductIdentifier("X");
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
try {
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals("[productIdentifier should be A,D,L,C]", e.getMessage());
}
}
@Test
public void testEnquiryMissingMandatoryFieldForNullFields() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getInternalInfo().setServiceType(null);
request.getInternalInfo().setSourceCountry(null);
request.getInternalInfo().setSystemIdentifier(null);
request.getServiceInfo().setAckReference(null);
request.getServiceInfo().setChannelReference(null);
request.getServiceInfo().setTransactionReference(null);
request.getServiceInfo().setVendorTransactionId(null);
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
try {
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals(
"[service-type, source-country, system-identifier, transaction-reference, ack-reference] : Mandatory Fields are Missing",
e.getMessage());
}
}
@Test
public void testInitializeMissingMandatoryFieldForNullFields() throws Exception {
// Given
InitializeRequest request = TestCommonUtils.buildInitializeRequest();
request.getInternalInfo().setServiceType(null);
request.getInternalInfo().setSourceCountry(null);
request.getInternalInfo().setSystemIdentifier(null);
request.getServiceInfo().setTransactionReference(null);
request.getServiceInfo().setSegmentCode(null);
request.getServiceInfo().setProductIdentifier(null);
when(idvService.initialize(request)).thenReturn(TestCommonUtils.buildInitializeResponse());
try {
// When
ResponseEntity<InitializeResponse> response = controller.initialize(request);
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals(
"[service-type, source-country, system-identifier, transaction-reference] : Mandatory Fields are Missing",
e.getMessage());
}
}
@Test
public void testInitialize_onlyMandatoryFields() throws Exception {
// Given
InitializeRequest request = TestCommonUtils.buildInitializeRequest();
request.setCustomerDetails(null);
request.setSystemInfo(null);
request.getServiceInfo().setChannelReference(null);
request.getServiceInfo().setDeviceInfo(null);
when(idvService.initialize(request)).thenReturn(TestCommonUtils.buildInitializeResponse());
// When
ResponseEntity<InitializeResponse> response = controller.initialize(request);
// Then
assertNotNull(response);
assertNotNull(response.getBody());
}
@Test
public void testEnquiry_onlyMandatoryFields() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getInternalInfo().setServiceType("Enquiry");
request.getServiceInfo().setAckReference("ABCD1234");
request.getInternalInfo().setSourceCountry("HK");
when(idvService.enquiryIDV(any())).thenReturn(TestCommonUtils.buildEnquiryResponse());
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
// Then
assertNotNull(response);
assertNotNull(response.getBody());
assertEquals(response.getBody().getVerificationResult().getOverallStatus(), "Success");
}
@Test
public void testGetDemographicsMissingMandatoryFieldForEmptyFields() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setServiceType(" ");
req.getInternalInfo().setSourceCountry(" ");
req.getInternalInfo().setSystemIdentifier(" ");
req.getCustomerDetails().setDocumentNumber(" ");
req.getServiceInfo().setVendorTransactionId(" ");
req.getServiceInfo().setChannelReference(" ");
req.getServiceInfo().setAckReference(" ");
req.getServiceInfo().setVendorTransactionId(" ");
req.getServiceInfo().setSegmentCode(" ");
req.getServiceInfo().setProductIdentifier(" ");
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
try {
// When
ResponseEntity<DemographicResponse> res = controller.getDemographics(req);
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals(
"[service-type, source-country, vendor-transaction-id, system-identifier, ack-reference] : Mandatory Fields are Missing",
e.getMessage());
}
}
@Test
public void testInitializeMissingMandatoryFieldForEmptyFields() throws Exception {
// Given
InitializeRequest request = TestCommonUtils.buildInitializeRequest();
request.getInternalInfo().setServiceType("");
request.getInternalInfo().setSourceCountry("");
request.getInternalInfo().setSystemIdentifier("");
request.getServiceInfo().setTransactionReference("");
request.getServiceInfo().setSegmentCode("");
request.getServiceInfo().setProductIdentifier("");
when(idvService.initialize(request)).thenReturn(TestCommonUtils.buildInitializeResponse());
try {
// When
ResponseEntity<InitializeResponse> response = controller.initialize(request);
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals(
"[service-type, source-country, system-identifier, transaction-reference] : Mandatory Fields are Missing",
e.getMessage());
}
}
@Test
public void testEnquiryMissingMandatoryFieldForEmptyFields() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getInternalInfo().setServiceType("");
request.getInternalInfo().setSourceCountry("");
request.getInternalInfo().setSystemIdentifier("");
request.getServiceInfo().setAckReference("");
request.getServiceInfo().setChannelReference("");
request.getServiceInfo().setTransactionReference("");
request.getServiceInfo().setVendorTransactionId("");
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
try {
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals(
"[service-type, source-country, system-identifier, transaction-reference, ack-reference] : Mandatory Fields are Missing",
e.getMessage());
}
}
@Test
public void testGetDemographicsInvalidSourceCountry() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setSourceCountry("VN");
req.getCustomerDetails().setFullname("Nguyễn Trường");
req.getCustomerDetails().setAddress("Eco space");
req.getCustomerDetails().setCustomerPhoto("aaaa");
req.getCustomerDetails().setDocumentNumber("A1001");
req.getCustomerDetails().setDateOfBirth("2021-12-24");
req.getCustomerDetails().setCustomerDetail("IVA");
req.getCustomerDetails().setIdDetails("123");
doThrow(new ContainsInvalidCharectersException(req.getServiceInfo().getTransactionReference(),
"[source-country is invalid]")).when(requestFieldValidator)
.validateGetDemographicsRequest(any(DemographicRequest.class));
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
// When
controller.getDemographics(req);
});
// Then
assertTrue(exception.getMessage().contains("[source-country is invalid]"));
}
@Test
public void testGetDemographicsInvalidSystemIdentifier() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setSourceCountry("HK");
req.getInternalInfo().setSystemIdentifier("09");
doThrow(new ContainsInvalidCharectersException(req.getServiceInfo().getTransactionReference(),
"[source-country is invalid]")).when(requestFieldValidator)
.validateGetDemographicsRequest(any(DemographicRequest.class));
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
// When
controller.getDemographics(req);
});
// Then
assertTrue(exception.getMessage().contains("[source-country is invalid]"));
}
@Test
public void testGetDemographicInvalidServiceType() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setSourceCountry("HK");
req.getInternalInfo().setServiceType("X");
doThrow(new ContainsInvalidCharectersException(req.getServiceInfo().getTransactionReference(),
"[source-country is invalid]")).when(requestFieldValidator)
.validateGetDemographicsRequest(any(DemographicRequest.class));
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
// When
controller.getDemographics(req);
});
// Then
assertTrue(exception.getMessage().contains("[source-country is invalid]"));
}
@Test
public void testInitializeInvalidSourceCountry() throws Exception {
// Given
InitializeRequest request = TestCommonUtils.buildInitializeRequest();
request.getInternalInfo().setSourceCountry("SG");
doThrow(new FieldValueNotInRangeException(request.getServiceInfo().getTransactionReference(),
"[source-country is invalid]")).when(requestFieldValidator)
.validateInitializeRequest(any(InitializeRequest.class));
when(idvService.initialize(request)).thenReturn(TestCommonUtils.buildInitializeResponse());
FieldValueNotInRangeException exception = assertThrows(FieldValueNotInRangeException.class, () -> {
// When
controller.initialize(request);
});
// Then
assertTrue(exception.getMessage().contains("[source-country is invalid]"));
}
@Test
public void testEnquiryInvalidSourceCountry() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getInternalInfo().setSourceCountry("SG");
doThrow(new ContainsInvalidCharectersException(request.getServiceInfo().getTransactionReference(),
"[source-country is invalid]")).when(requestFieldValidator)
.invalidAttrtibutesEnquiry(any(EnquiryRequest.class));
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
// When
controller.handleEnquiryRequest(request);
});
// Then
assertTrue(exception.getMessage().contains("[source-country is invalid]"));
}
@Test
public void testGetDemographicsInvalidAttributesForLengthCheck() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setSourceCountry("HKuetyd");
req.getInternalInfo().setSystemIdentifier("1");
req.getCustomerDetails().setDocumentNumber("mmmdnkd");
req.getServiceInfo().setVendorTransactionId("6");
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
try {
// When
ResponseEntity<DemographicResponse> res = controller.getDemographics(req);
} catch (Exception e) {
// Then
assertNotEquals(2, req.getInternalInfo().getSourceCountry().length());
assertNotEquals(2, req.getInternalInfo().getSystemIdentifier().length());
assertEquals(7, req.getCustomerDetails().getDocumentNumber().length());
assertEquals(1, req.getServiceInfo().getVendorTransactionId().length());
}
}
@Test
public void testInitializeInvalidAttributesForLengthCheck() throws Exception {
// Given
InitializeRequest request = TestCommonUtils.buildInitializeRequest();
request.getInternalInfo().setServiceType("Newyy");
request.getInternalInfo().setSourceCountry("HKiijtg");
request.getInternalInfo().setSystemIdentifier("1");
request.getServiceInfo().setChannelReference("HK20240423001");
request.getServiceInfo().setTransactionReference("TXNREF10041");
request.getServiceInfo().setSegmentCode("023");
request.getServiceInfo().setProductIdentifier("DEPOSIT");
request.getCustomerDetails().setDocumentNumber("H131685(2)");
when(idvService.initialize(request)).thenReturn(TestCommonUtils.buildInitializeResponse());
try {
// When
ResponseEntity<InitializeResponse> response = controller.initialize(request);
} catch (Exception e) {
// Then
assertNotEquals(3, request.getInternalInfo().getServiceType().length());
assertNotEquals(2, request.getInternalInfo().getSourceCountry().length());
assertNotEquals(2, request.getInternalInfo().getSystemIdentifier().length());
assertEquals(13, request.getServiceInfo().getChannelReference().length());
assertEquals(11, request.getServiceInfo().getTransactionReference().length());
assertEquals(3, request.getServiceInfo().getSegmentCode().length());
assertEquals(7, request.getServiceInfo().getProductIdentifier().length());
}
}
@Test
public void testEnquiryInvalidAttributesForLengthCheck() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getInternalInfo().setServiceType("Enquiryy");
request.getInternalInfo().setSourceCountry("HKiijtg");
request.getInternalInfo().setSystemIdentifier("1");
request.getServiceInfo().setAckReference("123123123");
request.getServiceInfo().setChannelReference("HK20240423001");
request.getServiceInfo().setTransactionReference("11111111");
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
try {
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
} catch (Exception e) {
// Then
assertNotEquals(7, request.getInternalInfo().getServiceType().length());
assertNotEquals(2, request.getInternalInfo().getSourceCountry().length());
assertNotEquals(2, request.getInternalInfo().getSystemIdentifier().length());
assertEquals(9, request.getServiceInfo().getAckReference().length());
assertEquals(13, request.getServiceInfo().getChannelReference().length());
assertEquals(8, request.getServiceInfo().getTransactionReference().length());
}
}
@Test
public void testGetDemographicsValidateErrorMessagesforLengthMax() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setServiceType("NEW");
req.getInternalInfo().setSourceCountry("VN");
req.getInternalInfo().setSystemIdentifier("01");
req.getCustomerDetails().setDocumentNumber("011");
req.getServiceInfo().setVendorTransactionId("6");
req.getServiceInfo().setAckReference("ABCD1234");
req.getServiceInfo().setChannelReference("HK2024042300100000000000000000000000fgdtfgsrdgtrrsfftrughfsrdgftrf");
req.getCustomerDetails().setFullname("Nguyễn Trường");
req.getCustomerDetails().setAddress("Eco space");
req.getCustomerDetails().setCustomerPhoto("aaaa");
req.getCustomerDetails().setDateOfBirth("2021-12-24");
req.getCustomerDetails().setCustomerDetail("IVA");
req.getCustomerDetails().setIdDetails("123");
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
try {
// When
ResponseEntity<DemographicResponse> res = controller.getDemographics(req);
} catch (Exception e) {
// Then
assertEquals(
"[source-country is invalid, source-country should not exceed 2 char, system-identifier should not exceed 2 char, document-type should not exceed 3 char, channel-reference should not exceed 35 char]",
e.getMessage());
}
}
@Test
public void testInitializeValidateErrorMessagesforLengthMax() throws Exception {
// Given
InitializeRequest request = TestCommonUtils.buildInitializeRequest();
request.getInternalInfo().setServiceType("Newtt");
request.getInternalInfo().setSourceCountry("yfgf");
request.getInternalInfo().setSystemIdentifier("jgfi2v");
request.getServiceInfo().setChannelReference("HK2024042300100000000000000000000000");
request.getServiceInfo().setSegmentCode("023");
request.getServiceInfo().setProductIdentifier("DEPOSIT");
when(idvService.initialize(request)).thenReturn(TestCommonUtils.buildInitializeResponse());
try {
// When
ResponseEntity<InitializeResponse> response = controller.initialize(request);
} catch (Exception e) {
// Then
assertEquals(
"[source-country is invalid, service-type should not exceed 3 char, source-country should not exceed 2 char, system-identifier should not exceed 2 char, channel-reference should not exceed 35 char, segment-code should not exceed 2 char, product-identifier should not exceed 1 char]",
e.getMessage());
}
}
@Test
public void testEnquiryValidateErrorMessagesforLengthMax() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getInternalInfo().setServiceType("Enquiryy");
request.getInternalInfo().setSystemIdentifier("jgfi2v");
request.getServiceInfo().setAckReference("123123123000000000000000000000000000000000000000000");
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
try {
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
} catch (Exception e) {
// Then
assertEquals(
"[service-type should not exceed 7 char, system-identifier should not exceed 2 char, ack-reference should not exceed 50 char]",
e.getMessage());
}
}
@Test
public void testGetDemographicsValidateErrorMessagesforMinLength() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setServiceType("NEW");
req.getInternalInfo().setSourceCountry("VN");
req.getInternalInfo().setSystemIdentifier("01");
req.getCustomerDetails().setDocumentNumber("mmmdnkd");
req.getServiceInfo().setVendorTransactionId("6");
req.getServiceInfo().setAckReference("ABCD1234");
req.getCustomerDetails().setFullname("Nguyễn Trường");
req.getCustomerDetails().setAddress("Eco space");
req.getCustomerDetails().setCustomerPhoto("aaaa");
req.getCustomerDetails().setDateOfBirth("2021-12-24");
req.getCustomerDetails().setCustomerDetail("IVA");
req.getCustomerDetails().setIdDetails("123");
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
try {
// When
ResponseEntity<DemographicResponse> res = controller.getDemographics(req);
} catch (Exception e) {
// Then
assertEquals(
"[source-country is invalid, source-country should be minimum 2 char, system-identifier should be minimum 2 char, document-type should not exceed 3 char]",
e.getMessage());
}
}
@Test
public void testInitializeValidateErrorMessagesforMinLength() throws Exception {
// Given
InitializeRequest request = TestCommonUtils.buildInitializeRequest();
request.getInternalInfo().setServiceType("Ne");
request.getInternalInfo().setSourceCountry("H");
request.getInternalInfo().setSystemIdentifier("1");
when(idvService.initialize(request)).thenReturn(TestCommonUtils.buildInitializeResponse());
try {
// When
ResponseEntity<InitializeResponse> response = controller.initialize(request);
} catch (Exception e) {
// Then
assertEquals(
"[source-country is invalid, service-type should be minimum 3 char, source-country should be minimum 2 char, system-identifier should be minimum 2 char]",
e.getMessage());
}
}
@Test
public void testEnquiryValidateErrorMessagesforMinLength() throws Exception {
// Given
EnquiryRequest request = TestCommonUtils.buildEnquiryRequest();
request.getInternalInfo().setServiceType("New");
request.getInternalInfo().setSourceCountry("H");
request.getInternalInfo().setSystemIdentifier("1");
when(idvService.enquiryIDV(request)).thenReturn(TestCommonUtils.buildEnquiryResponse());
try {
// When
ResponseEntity<EnquiryResponse> response = controller.handleEnquiryRequest(request);
} catch (Exception e) {
// Then
assertEquals(
"[service-type should be minimum 7 char, source-country should be minimum 2 char, system-identifier should be minimum 2 char, source-country is invalid]",
e.getMessage());
}
}
@Test
public void testInitialize() throws Exception {
// Given
InitializeRequest req = TestCommonUtils.buildInitializeRequest();
Map<String, List<String>> map = TestCommonUtils.buildIdTypeConfig();
// When
when(idvService.initialize(req)).thenReturn(TestCommonUtils.buildInitializeResponse());
when(idTypeConfig.getProperties()).thenReturn(map);
ResponseEntity<InitializeResponse> initializeRes = controller.initialize(req);
// Then
assertNotNull(initializeRes);
assertNotNull(initializeRes.getBody());
assertEquals(initializeRes.getBody().getServiceInfo().getTransactionReference(), "TXNREF1002");
}
@Test
public void testVerifyCustomer() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequest();
when(idvService.verifyCustomerData(cvRequest)).thenReturn(TestCVUtils.buildCVResponse());
// When
ResponseEntity<CvResponse> res = controller.verifyCustomer(cvRequest);
// Then
assertNotNull(res);
assertNotNull(res.getBody());
assertEquals(res.getBody().getVerificationResult().getOverallStatus(), "Success");
}
@Test
public void testVerifyCustomerMandatoryMandatoryFieldException_fullname() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("fullname");
// when
MandatoryFieldValidationException exception = assertThrows(MandatoryFieldValidationException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[fullname] : Mandatory Fields are Missing", exception.getMessage());
}
@Test
public void testVerifyCustomerMandatoryMandatoryFieldException_dob() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("dob");
// when
MandatoryFieldValidationException exception = assertThrows(MandatoryFieldValidationException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[date-of-birth] : Mandatory Fields are Missing", exception.getMessage());
}
@Test
public void testVerifyCustomerMandatoryMandatoryFieldException_id() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("id-number");
// when
MandatoryFieldValidationException exception = assertThrows(MandatoryFieldValidationException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[id-number] : Mandatory Fields are Missing", exception.getMessage());
}
@Test
public void testVerifyCustomerMandatoryMandatoryFieldException_servicetype() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("service-type");
// when
MandatoryFieldValidationException exception = assertThrows(MandatoryFieldValidationException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[service-type] : Mandatory Fields are Missing", exception.getMessage());
}
@Test
public void testVerifyCustomerMandatoryMandatoryFieldException_sourcecountry() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("source-country");
// when
MandatoryFieldValidationException exception = assertThrows(MandatoryFieldValidationException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[source-country] : Mandatory Fields are Missing", exception.getMessage());
}
@Test
public void testVerifyCustomerMandatoryMandatoryFieldException_systemIdentifier() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("system-identifier");
// when
MandatoryFieldValidationException exception = assertThrows(MandatoryFieldValidationException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[system-identifier] : Mandatory Fields are Missing", exception.getMessage());
}
@Test
public void testVerifyCustomerMandatoryMandatoryFieldException_transactionreference() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("transaction-reference");
// when
MandatoryFieldValidationException exception = assertThrows(MandatoryFieldValidationException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[transaction-reference] : Mandatory Fields are Missing", exception.getMessage());
}
@Test
public void testVerifyCustomerMandatoryMandatoryFieldException_ackreference() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("ack-reference");
// when
MandatoryFieldValidationException exception = assertThrows(MandatoryFieldValidationException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[ack-reference] : Mandatory Fields are Missing", exception.getMessage());
}
@Test
public void testVerifyCustomerMandatoryMandatoryFieldException_combinations() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("combine");
// when
MandatoryFieldValidationException exception = assertThrows(MandatoryFieldValidationException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[id-number, date-of-birth] : Mandatory Fields are Missing", exception.getMessage());
}
// ***************************InvalidAttrtibutesException************************************//
@Test
public void testVerifyCustomerInvalidAttrtibutesException_serviceType() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("InvalidAttribute");
doThrow(new ContainsInvalidCharectersException(cvRequest.getServiceInfo().getTransactionReference(),
"[service-type should not exceed 3 char]")).when(requestFieldValidator)
.invalidAttrtibutesCustomerVerification(any(CvRequest.class));
// when
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[service-type should not exceed 3 char]", exception.getMessage());
}
@Test
public void tesVerifyCustomertInvalidAttrtibutesException_sourcecountry() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("source-country_invalid");
doThrow(new ContainsInvalidCharectersException(cvRequest.getServiceInfo().getTransactionReference(),
"[source-country should not exceed 2 char, source-country is invalid]")).when(requestFieldValidator)
.invalidAttrtibutesCustomerVerification(any(CvRequest.class));
// when
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[source-country should not exceed 2 char, source-country is invalid]", exception.getMessage());
}
@Test
public void testVerifyCustomerInvalidAttrtibutesException_systemIdentifier() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("system-identifier_invalid");
doThrow(new ContainsInvalidCharectersException(cvRequest.getServiceInfo().getTransactionReference(),
"[system-identifier should not exceed 2 char]")).when(requestFieldValidator)
.invalidAttrtibutesCustomerVerification(any(CvRequest.class));
// when
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[system-identifier should not exceed 2 char]", exception.getMessage());
}
@Test
public void testVerifyCustomerInvalidAttrtibutesException_TransactionRef() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("transaction-reference_invalid");
doThrow(new ContainsInvalidCharectersException(cvRequest.getServiceInfo().getTransactionReference(),
"[transaction-reference should not exceed 80 char]")).when(requestFieldValidator)
.invalidAttrtibutesCustomerVerification(any(CvRequest.class));
// when
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[transaction-reference should not exceed 80 char]", exception.getMessage());
}
@Test
public void testVerifyCustomerInvalidAttrtibutesException_acknumber() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("ack-reference_invalid");
doThrow(new ContainsInvalidCharectersException(cvRequest.getServiceInfo().getTransactionReference(),
"[ack-reference should not exceed 50 char]")).when(requestFieldValidator)
.invalidAttrtibutesCustomerVerification(any(CvRequest.class));
// when
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[ack-reference should not exceed 50 char]", exception.getMessage());
}
@Test
public void testVerifyCustomerInvalidAttrtibutesException_idnumber() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("Id-number_invalid");
doThrow(new ContainsInvalidCharectersException(cvRequest.getServiceInfo().getTransactionReference(),
"[Id-number should not exceed 50 char]")).when(requestFieldValidator)
.invalidAttrtibutesCustomerVerification(any(CvRequest.class));
when(idvService.verifyCustomerData(any())).thenReturn(TestCVUtils.buildCVResponse());
// when
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[Id-number should not exceed 50 char]", exception.getMessage());
}
@Test
public void testVerifyCustomerInvalidAttrtibutesException_fullname() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("fullname_invalid");
doThrow(new ContainsInvalidCharectersException(cvRequest.getServiceInfo().getTransactionReference(),
"[fullname should not exceed 150 char]")).when(requestFieldValidator)
.invalidAttrtibutesCustomerVerification(any(CvRequest.class));
// when
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[fullname should not exceed 150 char]", exception.getMessage());
}
@Test
public void testVerifyCustomerInvalidAttrtibutesException_dob() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequestException("date-of-birth_invalid");
doThrow(new ContainsInvalidCharectersException(cvRequest.getServiceInfo().getTransactionReference(),
"[date-of-birth should not exceed 10 char]")).when(requestFieldValidator)
.invalidAttrtibutesCustomerVerification(any(CvRequest.class));
// when
ContainsInvalidCharectersException exception = assertThrows(ContainsInvalidCharectersException.class, () -> {
controller.verifyCustomer(cvRequest);
});
// then
assertEquals("[date-of-birth should not exceed 10 char]", exception.getMessage());
}
@Test
public void testVerifyFingerPrint() throws Exception {
// Given
BiometricVerificationRequest bioauthRequest = TestCVUtils.biometricVerificationRequest();
// When
when(idvService.verifyFingerPrint(bioauthRequest)).thenReturn(TestCVUtils.buildBioAuthResponse());
ResponseEntity<BiometricVerificationResponse> bioAuthResponse = controller.verifyFingerPrint(bioauthRequest);
// then
assertNotNull(bioAuthResponse);
assertNotNull(bioAuthResponse.getBody());
assertEquals(bioAuthResponse.getBody().getResponseInfo().getProcessDescription(), "Success");
}
@Test
public void testVerifyFaceMatch() throws Exception {
//Given
LivelinessRequest request = TestCommonUtils.buildLivelinessRequest();
// When
when(idvService.verifyFaceMatch(any())).thenReturn(TestCommonUtils.buildLivelinessResponse());
ResponseEntity<LivelinessResponse> responseEntity = controller.verifyFaceMatch(request);
//Then
assertNotNull(responseEntity);
assertNotNull(responseEntity.getBody());
assertEquals(responseEntity.getBody().getResponseInfo().getProcessStatus(), "200");
assertEquals(responseEntity.getBody().getResponseInfo().getMatchScore(), "0.98825");
assertEquals(responseEntity.getBody().getResponseInfo().getMatchResult(), "Match");
}
@Test
public void testVerifyFingerprint_exception() throws Exception {
//Given
BiometricVerificationRequest request = TestCVUtils.buildBioAuthRequest();
request.getInternalInfo().setSourceCountry("AB");
doThrow(new ContainsInvalidCharectersException(request.getServiceInfo().getTransactionReference(),
"[source-country is invalid]")).when(requestFieldValidator)
.validateBiometricVerificationRequest(any(BiometricVerificationRequest.class));
// when
Exception exception = assertThrows(Exception.class, () -> {
controller.verifyFingerPrint(request);
});
// then
assertEquals("[source-country is invalid]", exception.getMessage());
}
@Test
public void testVerifyFaceMatch_exception() throws Exception {
//Given
LivelinessRequest request = TestCommonUtils.buildLivelinessRequest();
request.getInternalInfo().setSourceCountry("AB");
doThrow(new ContainsInvalidCharectersException(request.getServiceInfo().getTransactionReference(),
"[source-country is invalid]")).when(requestFieldValidator)
.validateLivelinessVerificationRequest(request);
// when
Exception exception = assertThrows(Exception.class, () -> {
controller.verifyFaceMatch(request);
});
// then
assertEquals("[source-country is invalid]", exception.getMessage());
}
@Test
public void getDemographicsSuccessTest() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getInternalInfo().setServiceType("NEW");
req.getServiceInfo().setAckReference("ABCD1234");
req.getInternalInfo().setSourceCountry("VN");
req.getServiceInfo().setVerificationType("NFC");
req.getCustomerDetails().setIdentityType("IDCARD");
req.getCustomerDetails().setFullname("Nguyễn Trường");
req.getCustomerDetails().setDateOfBirth("2021-12-24");
req.getCustomerDetails().setGender("Male");
req.getCustomerDetails().setAddress("Eco space");
req.getCustomerDetails().setCustomerPhoto("aaaa");
req.getCustomerDetails().setCustomerDetail("IVA");
req.getCustomerDetails().setIdDetails("123");
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
// When
ResponseEntity<DemographicResponse> res = controller.getDemographics(req);
// Then
assertNotNull(res);
assertNotNull(res.getBody());
assertEquals(res.getBody().getIdDetails().getDocumentNumber(), "DOCNO 123");
}
@Test
public void testVerifyCustomer_By_CVMockResponse() throws Exception {
// Given
CvRequest cvRequest = TestCVUtils.buildCVRequest();
when(env.getProperty("cv.mockresponse.enable")).thenReturn("false");
when(idvService.verifyCustomerData(cvRequest)).thenReturn(TestCVUtils.buildCVResponse());
// When
ResponseEntity<CvResponse> res = controller.verifyCustomer(cvRequest);
// Then
assertNotNull(res);
assertNotNull(res.getBody());
assertEquals(res.getBody().getVerificationResult().getOverallStatus(), "Success");
}
@Test
public void getDemographicsThirdPartyInfoNullSuccessTest() throws Exception {
// Given
DemographicRequest req = TestCommonUtils.buildDemographicReq();
req.getServiceInfo().setAckReference("ABCD1234");
req.getInternalInfo().setSourceCountry("VN");
req.getServiceInfo().setVerificationType("NFC");
req.getCustomerDetails().setIdentityType("IDV");
req.getCustomerDetails().setFullname("Nguyễn Trường");
req.getCustomerDetails().setDateOfBirth("2021-12-24");
req.getCustomerDetails().setGender("Male");
req.getCustomerDetails().setAddress("Eco space");
req.getCustomerDetails().setCustomerPhoto("aaaa");
req.getCustomerDetails().setCustomerDetail("IDV");
req.getCustomerDetails().setIdDetails("123");
req.setThirdpartyInfo(null);
when(idvService.getDemographics(any())).thenReturn(TestCommonUtils.buildDemographicResponse());
// When
ResponseEntity<DemographicResponse> res = controller.getDemographics(req);
// Then
assertNotNull(res);
assertNotNull(res.getBody());
assertEquals(res.getBody().getIdDetails().getDocumentNumber(), "DOCNO 123");
}
@Test
public void testInitializeForCustometDetailsNonMandatory() throws Exception {
// Given
InitializeRequest req = TestCommonUtils.buildInitializeRequest();
req.getInternalInfo().setSourceCountry("SG");
req.getSystemInfo().setSuccessCallBackURL("http://localhost:3001/callback");
req.setCustomerDetails(null);
// When
when(idvService.initialize(req)).thenReturn(TestCommonUtils.buildInitializeResponse());
ResponseEntity<InitializeResponse> initializeRes = controller.initialize(req);
// Then
assertNotNull(initializeRes);
assertNotNull(initializeRes.getBody());
assertEquals(initializeRes.getBody().getServiceInfo().getTransactionReference(), "TXNREF1002");
assertEquals(req.getSystemInfo().getSuccessCallBackURL(), "http://localhost:3001/callback");
assertEquals(req.getCustomerDetails(), null);
}
}
The above jUnit class is having error because of the newly included header parameter in the initialize function call. Please help me to fix it
To address the error in your JUnit test class caused by the new @RequestHeader parameter in the initialize method of the IDVController, you will need to update the relevant test methods to include the stub header in their requests. The change primarily involves initializing the request in the test methods to now include the new parameter.
Updated Test Methods for initialize
Identify the tests that invoke controller.initialize(request)
You will need to update the tests that call controller.initialize(request) to also include the new header.
Update the tests to pass the stub header
You'll modify the test cases for your initialize method in the IDVControllerTest class as follows:
Here's how you would update an example test case:
java
@Test
public void testInitialize() throws Exception {
// Given
InitializeRequest req = TestCommonUtils.buildInitializeRequest();
Map<String, List<String>> map = TestCommonUtils.buildIdTypeConfig();
// When
when(idvService.initialize(req)).thenReturn(TestCommonUtils.buildInitializeResponse());
when(idTypeConfig.getProperties()).thenReturn(map);
// You will need to adjust the call to the initialize method to include the stub header.
ResponseEntity<InitializeResponse> initializeRes = controller.initialize("n", req); // Replace "n" with desired value
// Then
assertNotNull(initializeRes);
assertNotNull(initializeRes.getBody());
assertEquals(initializeRes.getBody().getServiceInfo().getTransactionReference(), "TXNREF1002");
}
Other Test Cases
You should similarly update other test methods that involve the initialize method. Here’s an example for another test case you may have:
java
@Test
public void testInitializeMissingMandatoryFieldForNullFields() throws Exception {
// Given
InitializeRequest request = TestCommonUtils.buildInitializeRequest();
request.getInternalInfo().setServiceType(null);
request.getInternalInfo().setSourceCountry(null);
request.getInternalInfo().setSystemIdentifier(null);
// Setting mock response for idvService
when(idvService.initialize(request)).thenReturn(TestCommonUtils.buildInitializeResponse());
try {
// When
ResponseEntity<InitializeResponse> response = controller.initialize("n", request); // Adjusted for header
} catch (MandatoryFieldValidationException e) {
// Then
assertEquals(
"[service-type, source-country, system-identifier] : Mandatory Fields are Missing",
e.getMessage());
}
}
Summary of Adjustments
Add the stub header parameter: Make sure every invocation of the controller.initialize method includes the @RequestHeader parameter for stub (in the examples, I've set it to "n").
Adjust expectations in tests as needed: Make sure that any behavior dependent on the stub setting is appropriately covered in your tests by including conditional assertions if necessary.
Make similar updates for the other test cases relative to their content. This change will ensure that your tests run successfully without encountering issues due to the newly added method signature in the actual code.
This is the SharedConfig class which is autowired in IDVController class.
package com.sc.we.idv.config;
import org.springframework.stereotype.Component;
@Component
public class SharedConfig {
private boolean shouldStubInitialize;
code
public boolean isShouldStubInitialize() {
return shouldStubInitialize;
}
public void setShouldStubInitialize(boolean shouldStubInitialize) {
this.shouldStubInitialize = shouldStubInitialize;
}
}
Please help me to fix the error
The errors you're encountering in your unit tests indicate that the SharedConfig dependency in your IDVController is not being initialized correctly. This is typically due to the fact that the @InjectMocks annotation is used without properly mocking or initializing all the required dependencies.
Here's how you can address the issues step by step:
Step 1: Mock the SharedConfig
First, ensure that SharedConfig is mocked in your test class. Since it is used as a dependency in the IDVController, you'll modify your test class to mock this component.
In the IDVControllerTest class, update the following:
java
import org.mockito.Mock;
public class IDVControllerTest extends IDVBaseTest {
@Mock
private IDVService idvService;
@Mock
private SharedConfig sharedConfig; // Add this line to mock SharedConfig
@InjectMocks
private IDVController controller;
// ... rest of the existing code ...
}
Step 2: Initialize the SharedConfig Mock
Next, make sure to initialize the sharedConfig mock in the relevant tests. You can also modify the tests to return proper behavior for the SharedConfig mock when called.
For instance, if you're using the sharedConfig.setShouldStubInitialize() method in your controller, you might want to set up some behavior in the test case itself. Here is how you can do that when testing the initialize method:
java
@Test
public void testInitialize() throws Exception {
// Given
InitializeRequest req = TestCommonUtils.buildInitializeRequest();
Map<String, List<String>> map = TestCommonUtils.buildIdTypeConfig();
// Mock the behavior of IDVService
when(idvService.initialize(req)).thenReturn(TestCommonUtils.buildInitializeResponse());
when(idTypeConfig.getProperties()).thenReturn(map);
// Mock the behavior of SharedConfig
sharedConfig.setShouldStubInitialize(false);
// When
ResponseEntity<InitializeResponse> initializeRes = controller.initialize("n", req); // Pass your "stub" header value
// Then
assertNotNull(initializeRes);
assertNotNull(initializeRes.getBody());
assertEquals(initializeRes.getBody().getServiceInfo().getTransactionReference(), "TXNREF1002");
}
Step 3: Update Other Tests
If other tests are failing due to the null references to sharedConfig, you may need to mock that behavior as well. Wherever your controller relies on sharedConfig, make sure to include it in your setup, like in the testInitializeInvalidSourceCountry, testInitializeValidateErrorMessagesforLengthMax, and testInitializeValidateErrorMessagesforMinLength.
Example:
java
@Test
public void testInitializeInvalidSourceCountry() throws Exception {
// Given
InitializeRequest request = TestCommonUtils.buildInitializeRequest();
request.getInternalInfo().setSourceCountry("InvalidCountry"); // Set to an invalid value
sharedConfig.setShouldStubInitialize(false); // Mock sharedConfig behavior
when(idvService.initialize(request)).thenThrow(new FieldValueNotInRangeException(request.getServiceInfo().getTransactionReference(), "[source-country is invalid]"));
// Expecting an exception when calling initialize
FieldValueNotInRangeException exception = assertThrows(FieldValueNotInRangeException.class, () -> {
controller.initialize("n", request);
});
assertEquals("[source-country is invalid]", exception.getMessage());
}
Summary
MockSharedConfig in your test class.
Set up the behavior of the mocked SharedConfig in each test as needed.
Ensure that the initialization and mock behaviors reflect the logic you're testing for in each specific test case.
This should fix the issue of NullPointerExceptions related to the SharedConfig not being initialized in your unit tests.