Search in sources :

Example 1 with LiveStatus

use of com.day.cq.wcm.msm.api.LiveStatus in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ContainerServletTest method setUp.

@BeforeEach
public void setUp() throws WCMException, NoSuchFieldException {
    context.load().json(TEST_BASE + CoreComponentTestContext.TEST_CONTENT_JSON, CONTENT_ROOT);
    // make the carousel component the current resource
    context.currentResource(CAROUSEL_PATH);
    // set http method
    context.request().setMethod("POST");
    // live relationship manager
    LiveRelationshipManager liveRelationshipManager = mock(LiveRelationshipManager.class);
    when(liveRelationshipManager.getLiveRelationship(any(Resource.class), anyBoolean())).then(invocation -> {
        Object[] arguments = invocation.getArguments();
        Resource resource = (Resource) arguments[0];
        if (LIVE_COPY_PATH.equals(resource.getPath())) {
            LiveRelationship liveRelationship = mock(LiveRelationship.class);
            LiveStatus liveStatus = mock(LiveStatus.class);
            when(liveStatus.isSourceExisting()).thenReturn(true);
            when(liveRelationship.getStatus()).thenReturn(liveStatus);
            return liveRelationship;
        }
        return null;
    });
    FieldSetter.setField(servlet, servlet.getClass().getDeclaredField("liveRelationshipManager"), liveRelationshipManager);
}
Also used : LiveRelationshipManager(com.day.cq.wcm.msm.api.LiveRelationshipManager) Resource(org.apache.sling.api.resource.Resource) LiveRelationship(com.day.cq.wcm.msm.api.LiveRelationship) LiveStatus(com.day.cq.wcm.msm.api.LiveStatus) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

LiveRelationship (com.day.cq.wcm.msm.api.LiveRelationship)1 LiveRelationshipManager (com.day.cq.wcm.msm.api.LiveRelationshipManager)1 LiveStatus (com.day.cq.wcm.msm.api.LiveStatus)1 Resource (org.apache.sling.api.resource.Resource)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1