We have a business requirement where we query set of assets through a particular path and moving the expired assets from one folder to archive folder, how can we write JUnit test case for below code,
@Reference
CommonConfigService commonConfigService ;
ResourceResolver resourceResolver ;
@Reference
QueryBuilder querybuilder;
private void queryForAssets()
{
Session session = resourceResolver .adaptTo(Session .class);
Map<String, String> map = new HashMap<String,String>();
map.put("path", "myPath");
map.put("type" ,"dam:Asset");
map.put("property" ,"prism:ExpirationDate");
final Query query = queryBuilder.createQuery(PredicateGroup.create(map),session);
final SearchResults resultSet = query.getResult();
for(Hit hit: resultSet.getHits())
{
//business logic,...iterating through each node path and reading the expiry date properties//
moveAssetToDestination();
}
}
In the above code , the last function moveAssetToDestination() will move all the expired assets from one folder to archive folder.
So basically there are no methods which are exactly returning any value.
Is it possible to write any JUnit for above code?