Hi All,
I was creating AEM package programattically for a usecase. while writing the test case for create package method im getting NPE, though all param was not null. Kinldy help on mocking below method for Junit.
method needs to be mocked below :
packageHelper.createPackage(packageResource, session,PageConstants.DEFAULT_GROUP_NAME, "testPackage", PageConstants.DEFAULT_VERSION,
PackageHelper.ConflictResolution.Replace, packageDefinitionProperties);
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Assuming `PackageHelper` is from the ACSCommons package, you just need to mock the whole service and then mock the method with exactly the parameters you will be passing in runtime.
Something like this:
@Mock
private PackageHelper packageHelperMock;
//Then you can mock the method createPackage
when(packageHelperMock.createPackage(.....your expected parameter)).thenReturn(yourExpectedValue);
Hi,
Assuming `PackageHelper` is from the ACSCommons package, you just need to mock the whole service and then mock the method with exactly the parameters you will be passing in runtime.
Something like this:
@Mock
private PackageHelper packageHelperMock;
//Then you can mock the method createPackage
when(packageHelperMock.createPackage(.....your expected parameter)).thenReturn(yourExpectedValue);
Hi @EstebanBustamante , thanks much for your reply. you're rite... `PackageHelper` was from the ACSCommons package.as shown in the earlier screenshot attached, all param was not null. In the servlet test case file, while debug, im getting mock Jcrpackage as out come. when it reach to actual servlet packagehelper.create(your expected parameter) showing jcrpackage as Null, though all param's were not null.
Views
Likes
Replies