PostEngineSessionBeanTest > testProcessPostAccountCreationAction FAILED
2025-01-06T11:41:30.5074393Z mockit.internal.MissingInvocation: Missing 1 invocation to:
2025-01-06T11:41:30.5075430Z scb.util.SystemProperties#localLookup(String)
2025-01-06T11:41:30.5076422Z with arguments: "eBBS/SubsidiaryAccountSession"
2025-01-06T11:41:30.5077425Z on mock instance: scb.util.SystemProperties@2c5e72ec
2025-01-06T11:41:30.5078760Z at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessorCollectAllTestClassesExecutor.accessDispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
2025-01-06T11:41:30.5091272Z at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:133)
2025-01-06T11:41:30.5092366Z at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2025-01-06T11:41:30.5093350Z at java.lang.reflect.Method.invoke(Method.java:498)
2025-01-06T11:41:30.5094772Z at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
2025-01-06T11:41:30.5095886Z at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
2025-01-06T11:41:30.5097123Z at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnectionDispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
2025-01-06T11:41:30.5099722Z at org.gradle.internal.remote.internal.hub.MessageHubCatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
2025-01-06T11:41:30.5101943Z at org.gradle.internal.concurrent.ManagedExecutorImplWorker.run(ThreadPoolExecutor.java:624)
2025-01-06T11:41:30.5105165Z at org.gradle.internal.concurrent.ThreadFactoryImpl41.(PostEngineSessionBeanTest.java:2826)
2025-01-06T11:41:30.5112172Z at scb.business.etransaction.ejb.PostEngineSessionBeanTest.testProcessPostAccountCreationAction(PostEngineSessionBeanTest.java:2816)
2025-01-06T11:41:30.6959118Z
The error message you are seeing indicates that a test case (testProcessPostAccountCreationAction) within the class PostEngineSessionBeanTest has failed due to a missing invocation on a mock object. Specifically, the method localLookup(String) on the SystemProperties mock was expected to be called with the argument "eBBS/SubsidiaryAccountSession" but it was not invoked during the test execution.
Here's a breakdown of the issue and potential ways to resolve it:
Understanding the Error
Mocking Framework: The error is generated by a mocking framework (likely JMockit in your case) that tracks subsequent calls to mocked methods.
Missing Invocation: The test expected a certain method (localLookup) to be called with a specific parameter during its execution but it did not happen.
Potential Causes
The part of the code under test that is supposed to call localLookup never executed, possibly due to skipped logic, incorrect test setup, or the test being improperly configured.
There might be conditions (such as flags or state) in the code that prevent the invocation from happening when the test runs.
Steps to Resolve
Verify Test Logic: Check the logic in the testProcessPostAccountCreationAction method to ensure that it triggers the code path which calls localLookup. Make sure the conditions are set correctly.
Review Mocks Setup: Ensure that the mocking of the SystemProperties class is done correctly and that the mocking behavior matches your expectations. You might need to set expectations for the method:
java
// Example of setting up expectations
new Expectations(SystemProperties.class) {{
SystemProperties.localLookup("eBBS/SubsidiaryAccountSession"); result = "someExpectedResult"; // or return a mock object
}};
Check for Initialization Issues: Sometimes the issue may lie in how the test initializes objects. Make sure that all necessary dependencies and configurations are correctly set up before the test executes.
Enhance Logging: Add logging statements in both the test and the code under test to ensure that the flow is as expected, and where it might diverge.
Run Isolated Tests: If applicable, try to run this test in isolation to see if it passes outside of the larger suite, which can sometimes help identify issues with interdependencies in tests.
Dependency Changes: If there were any recent changes to the codebase that might affect this behavior, consider reviewing those changes. It might help to look at the recent history of the PostEngineSessionBeanTest class.
Conclusion
Investigate the reasons why localLookup was not called within the context of the test. By validating your test setup, logic, and the mocking framework's expectations, you should be able to find the root cause of the failure and correct it. If necessary, consult the documentation for the mocking framework you are using for further details on expectations and configurations.
final Object[] nextElemObj = { "12345", "INR", "C" };
try {
reqInfo = new RequestInfo();
SubsidiaryAccountWrapper subsidiaryAccountWrapper = new SubsidiaryAccountWrapper();
subsidiaryAccountWrapper.productCode = "308";
subsidiaryAccountWrapper.setRequestInfo(reqInfo);
productWrapper = new ProductWrapper();
productWrapper.passbookReqFlag = 'Y';
MasterRelationshipWrapper masterRelationshipWrapper[] = new MasterRelationshipWrapper[1];
MasterRelationshipWrapper masterRelationshipWrapp = new MasterRelationshipWrapper();
masterRelationshipWrapp.relationshipNumber = "01506947501";
masterRelationshipWrapp.primaryAccount = 'Y';
masterRelationshipWrapp.disableRelOperatingInstuctionFlag = false;
masterRelationshipWrapper[0] = masterRelationshipWrapp;
accountMasterWrapper.masterRelationshipWrapper = masterRelationshipWrapper;
final AbstractWrapper[] abstractWrappers = new AbstractWrapper[1];
relStatusParamWrapper = new RelationshipStatusUpdateParamWrapper();
relStatusParamWrapper.setIsEventEnabled("N");
AccountBusinessParamWrapper accountBusinessParamWrapper = new AccountBusinessParamWrapper();
accountBusinessParamWrapper.setadviceRequired("N");
abstractWrappers[0] = relStatusParamWrapper;
abstractWrappers[0] = accountBusinessParamWrapper;
gbaAbstractWrapper = new AbstractWrapper[1];
gbaBppWarpper = new GBABusinessParamWrapper();
gbaAbstractWrapper[0] = gbaBppWarpper;
mcaAbstractWrapper = new AbstractWrapper[1];
mcaBusinessParamWrapper = new MCABusinessParamWrapper();
mcaAbstractWrapper[0] = mcaBusinessParamWrapper;
systemWrapper = new SystemWrapper();
systemWrapper.systemDate = Date.valueOf("2023-02-03");
icmUtil.isICMEnabled = false;
Deencapsulation.setField(postenginesessionbean, "productEntityHome", productEntityHome);
Deencapsulation.setField(postenginesessionbean, "accountMasterEntityHome", accountMasterEntityHome);
Deencapsulation.setField(postenginesessionbean, "mySessionCtx", mySessionCtx);
Deencapsulation.setField(postenginesessionbean, "sysProperties", sysProperties);
Deencapsulation.setField(postenginesessionbean, "currentTransactionStatisticsEntityHome", currentTransactionStatisticsEntityHome);
Deencapsulation.setField(postenginesessionbean, "previousTransactionStatisticsEntityHome", previousTransactionStatisticsEntityHome);
new Expectations() {
{
eodWrapper.getNextElement();
returns(nextElemObj, null);
{SubsidiaryAccountDAOFactory.getDAOInstance(anyString); result = subsidiaryAccountEntityHome;};
{subsidiaryAccountEntityHome.fetchMasterForLeanAct((SubsidiaryAccountEntityKey) any); result = subsidiaryAccountEntity;};
{subsidiaryAccountEntity.getWrapper(); result = subsidiaryAccountWrapper;};
{subsidiaryAccountWrapper.clone(); result = subsidiaryAccountWrapper;};
{sysProperties.localLookup("eBBS/SubsidiaryAccountSession"); result = subsidiaryAccountSessionHome;};
{subsidiaryAccountSessionHome.create(); result = subsidiaryAccountSession;};
{subsidiaryAccountSession.updateMasterRelStatus(anyString, anyString, anyString, new Date(18012000), accountMasterWrapper);
//result = new SCBApplicationException();
};
{productEntityHome.findByPrimaryKey((scb.ebbs.ecodes.ejb.ProductEntityKey) any); result = productEntity;}
{productEntity.getWrapper(); result = productWrapper;};
{accountMasterEntityHome.findByPrimaryKey((AccountMasterEntityKey) any); result = masterEntity;};
{masterEntity.getWrapper(); result = accountMasterWrapper;};
{PassbookDAOFactory.getDAOInstance(anyString); result = passbookEntityHome;};
{
Deencapsulation.invoke(businessProcessParamCache, "getInstance");
result = businessProcessParamCache;
businessProcessParamCache.getProcessParameters("RELSTATUSUPDATE_PARAM");
result = abstractWrappers;
};
{querySessionHome.create(); result = querySession;};
{querySession.getRelStatus(anyString); result = anyString;};
{RelationshipDAOFactory.getDAOInstance(anyString); result = relationshipEntityHome;};
{relationshipEntityHome.findByPrimaryKeyForUpdate((scb.ebbs.ecustomer.ejb.RelationshipEntityKey) any);
result = relationshipEntity;};
{relationshipEntity.getWrapper(); result = relationshipWrapper;};
{businessProcessParamCache.getProcessParameters(EBBSBusinessProcessConstants.ACCOUNT_PARAM);
result = abstractWrappers;};
{scb.ebbs.util.StaticDataCache.getInstance(); result = staticDataCache;};
{staticDataCache.getSystemWrapper(); result = systemWrapper;};
{subsidiaryAccountSession.updateFeBeBalance(subsidiaryAccountWrapper, systemWrapper.systemDate,
new Date(18012000));};
{InterestAccrualDAOFactory.getDAOInstance(anyString); result = interestAccrualEntityHome;};
{TPSDAOFactory.getDAOInstance(anyString); result = frontEndBalanceEntityHome;};
{PostEngineDAOFactory.getDAOInstance(anyString); result = backendBalanceEntityHome;};
{sysProperties.localLookup("eBBS/InterestSession"); result = interestSessionHome;};
{interestSessionHome.create(); result = interestSession;};
{interestSession.getInterestWrapper(anyString,anyString,(Date) any);
result=interestWrapper;};
{businessProcessParamCache.getProcessParameters(EBBSBusinessProcessConstants.GBA_ACCOUNT_PARAM);
result = gbaAbstractWrapper;};
{businessProcessParamCache.getProcessParameters(EBBSBusinessProcessConstants.MCA_ACCOUNT_PARAM);
result = mcaBusinessParamWrapper;};
{subsidiaryAccountSession.consolidatedStatementForIdaGbaAcc(subsidiaryAccountWrapper, productWrapper, gbaBppWarpper, 'N');};
{EventProcessor.getInstance(); result = eventProcessor;};
{subsidiaryAccountEntityHome.findByPrimaryKey((SubsidiaryAccountEntityKey)any); result = subsidiaryAccountEntity;};
{subsidiaryAccountEntity.getWrapper(); result = subsidiaryAccountWrapper;};
{subsidiaryAccountSession.getEvents(subsidiaryAccountWrapper, subsidiaryAccountWrapper); result = argBusinessEvent;};
{StatisticalFieldsDAOFactory.getDAOInstance("CurrentBalanceStatisticsEntity"); result = currentBalanceStatisticsEntityHome;};
{currentBalanceStatisticsEntity.getWrapper(); result = balanceStatisticsWrapper;};
{StatisticalFieldsDAOFactory.getDAOInstance("CurrentInterestBearingBalanceStatisticsEntity"); result = currentInterestBearingBalanceStatisticsEntityHome;};
{currentInterestBearingBalanceStatisticsEntity.getWrapper(); result = balanceStatisticsWrapper;};
}
};
postenginesessionbean.processPostAccountCreationAction(eodWrapper);
//Assert.assertTrue(true);
} catch (Exception exObj) {
//fail("Exception not Expected");
}
}
this is the method
The method you've provided, testProcessPostAccountCreationAction, sets up a unit test using JMockit for testing a specific action within the PostEngineSessionBean. The test uses mocking to simulate various dependencies and interactions.
Considering that you've encountered a MissingInvocation error indicating that the localLookup method of SystemProperties was expected to be called but wasn't, let's analyze the code to uncover potential reasons for this issue and solutions that you can adopt.
Key Points to Review
Expectations Setup:
Make sure that the expectations for sysProperties.localLookup("eBBS/SubsidiaryAccountSession") are set correctly in the new Expectations() { ... } block, which you've already done. Ensure that you lift the # from localLookup as a reference if the tool requires it.
Method Invocation:
Ensure that the processPostAccountCreationAction method of your postenginesessionbean actually calls sysProperties.localLookup("eBBS/SubsidiaryAccountSession"). If it sometimes does not execute that call based on certain conditions, you may need to adjust those conditions for your test.
Input Data:
The success of your test might depend strongly on the specific inputs being fed into processPostAccountCreationAction. Review the logic inside that method to see if:
Certain objects need to be in a specific state (or correctly initialized).
Any branch in the method logic bypasses the localLookup call based on the test data you're providing.
Faulty Mocking:
The mock of SystemProperties may not be set up as intended. Double-check:
The version of JMockit that you are using, as certain versions may behave differently or require additional configuration.
Confirm that SystemProperties does not implicitly call static constructors or other side effects that could interfere with the mocking.
Additional Assertions:
If you're debugging this, consider adding extra assertions or logging within the processPostAccountCreationAction method (if feasible) to trace whether certain parts of the method are indeed being executed.
Testing Mock Configurations:
Modify the expectations on the sysProperties mock:
java
new Expectations() {
{
// Existing expectations...
sysProperties.localLookup("eBBS/SubsidiaryAccountSession");
result = subsidiaryAccountSessionHome; // return a mock value as needed
// Ensure other methods do not interfere
}
};
Suggestions for Debugging
Log Inside the Method: If you have access to modify processPostAccountCreationAction, consider adding logging statements or using a debugging session to monitor execution flow.
Isolate Test Cases: If necessary, isolate the specific functionality that calls localLookup in a smaller test case and run it independently to confirm behavior.
Check for Conditional Logic: Closely inspect the method implementation for any conditions that may prevent reaching the invocation of localLookup, such as flags or failures that bypass that path.
Conclusion
Focus on ensuring that the processPostAccountCreationAction method has the right conditions met within your test case so that it will execute the localLookup call as expected, thereby fulfilling the expectations you set in your mock configuration. If the method’s logic is the reason why the call isn’t made during the test, adjusting your test inputs or conditions may resolve the issue.