Solved
Unit test MSM Custom Rollout Configuration
Hello, im new to AEM and Im trying to learn how to create a custom rollout configuration but Im wondering how I can test the code below with Mockito.
import javax.jcr.RepositoryException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.osgi.service.component.annotations.Component;
import com.day.cq.wcm.api.WCMException;
import com.day.cq.wcm.msm.api.LiveActionFactory;
import com.day.cq.wcm.msm.api.LiveRelationship;
import com.day.cq.wcm.msm.commons.BaseAction;
import com.day.cq.wcm.msm.commons.BaseActionFactory;
@Component(service = LiveActionFactory.class, property = {LiveActionFactory.LIVE_ACTION_NAME + "=" + ExampleActionFactory.LIVE_ACTION_NAME })
public class ExampleActionFactory extends BaseActionFactory<BaseAction> {
public static final String LIVE_ACTION_NAME = "SampleCustomRollout";
@Override public String createsAction() { return LIVE_ACTION_NAME; }
@Override
protected ExampleAction newActionInstance(ValueMap config) throws WCMException {
return new ExampleAction(config, this);
}
private static final class ExampleAction extends BaseAction {
public ExampleAction(ValueMap config, BaseActionFactory<? extends LiveAction> liveActionFactory) {
super(config, liveActionFactory);
}
protected boolean handles(Resource source, Resource target, LiveRelationship relation, boolean resetRollout)
throws RepositoryException, WCMException {
return (relation.getStatus().isPage() && source != null && target!= null);
}
protected void doExecute(Resource source, Resource target, LiveRelationship relation, boolean resetRollout)
throws RepositoryException, WCMException {
System.out.print("I am custom rollout");
//more logic
}
}
}
Any tips or sample code is very much appreciated.