Search in sources :

Example 11 with ReplicationOptions

use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.

the class DispatcherFlushRulesImplTest method testPreprocess_notAccepts_ReplicationActionTypeInternalPoll.

@Test
public void testPreprocess_notAccepts_ReplicationActionTypeInternalPoll() throws Exception {
    when(this.hierarchicalFlushRules.size()).thenReturn(9);
    when(this.resourceOnlyFlushRules.size()).thenReturn(9);
    final ReplicationAction replicationAction = mock(ReplicationAction.class);
    when(replicationAction.getPath()).thenReturn("/content/acs-aem-commons");
    when(replicationAction.getType()).thenReturn(ReplicationActionType.INTERNAL_POLL);
    dispatcherFlushRules.preprocess(replicationAction, new ReplicationOptions());
    verifyZeroInteractions(dispatcherFlusher);
}
Also used : ReplicationOptions(com.day.cq.replication.ReplicationOptions) ReplicationAction(com.day.cq.replication.ReplicationAction) Test(org.junit.Test)

Example 12 with ReplicationOptions

use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.

the class DispatcherFlushRulesImplTest method testPreprocess_success_translation2.

@Test
public void testPreprocess_success_translation2() throws Exception {
    hierarchicalFlushRules.put(Pattern.compile("/content/acs-aem-commons/(.*)/(.*)"), new String[] { "/content/target/$1/acs-aem-commons/$2" });
    final ReplicationAction replicationAction = mock(ReplicationAction.class);
    when(replicationAction.getPath()).thenReturn("/content/acs-aem-commons/en/page");
    when(replicationAction.getType()).thenReturn(ReplicationActionType.ACTIVATE);
    final ReplicationOptions replicationOptions = new ReplicationOptions();
    replicationOptions.setSynchronous(false);
    final ArgumentCaptor<DispatcherFlushFilter> agentFilterCaptor = ArgumentCaptor.forClass(DispatcherFlushFilter.class);
    dispatcherFlushRules.preprocess(replicationAction, replicationOptions);
    verify(dispatcherFlusher, times(1)).flush(any(ResourceResolver.class), eq(ReplicationActionType.ACTIVATE), eq(false), agentFilterCaptor.capture(), eq("/content/target/en/acs-aem-commons/page"));
    assertEquals(DispatcherFlushFilter.FlushType.Hierarchical, agentFilterCaptor.getValue().getFlushType());
    // Private impl class; no access to test for instanceof
    assertEquals("DispatcherFlushRulesFilter", agentFilterCaptor.getValue().getClass().getSimpleName());
    verifyNoMoreInteractions(dispatcherFlusher);
}
Also used : ReplicationOptions(com.day.cq.replication.ReplicationOptions) ReplicationAction(com.day.cq.replication.ReplicationAction) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) DispatcherFlushFilter(com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter) Test(org.junit.Test)

Example 13 with ReplicationOptions

use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.

the class DispatcherFlushRulesImplTest method testPreprocess_notAccepts_ReplicationActionPathEmpty.

@Test
public void testPreprocess_notAccepts_ReplicationActionPathEmpty() throws Exception {
    when(this.hierarchicalFlushRules.size()).thenReturn(9);
    when(this.resourceOnlyFlushRules.size()).thenReturn(9);
    final ReplicationAction replicationAction = mock(ReplicationAction.class);
    when(replicationAction.getPath()).thenReturn("");
    dispatcherFlushRules.preprocess(replicationAction, new ReplicationOptions());
    verifyZeroInteractions(dispatcherFlusher);
}
Also used : ReplicationOptions(com.day.cq.replication.ReplicationOptions) ReplicationAction(com.day.cq.replication.ReplicationAction) Test(org.junit.Test)

Example 14 with ReplicationOptions

use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.

the class DispatcherFlushRulesImplTest method testPreprocess_notAccepts_ReplicationActionPathNull.

@Test
public void testPreprocess_notAccepts_ReplicationActionPathNull() throws Exception {
    when(this.hierarchicalFlushRules.size()).thenReturn(9);
    when(this.resourceOnlyFlushRules.size()).thenReturn(9);
    final ReplicationAction replicationAction = mock(ReplicationAction.class);
    when(replicationAction.getPath()).thenReturn(null);
    dispatcherFlushRules.preprocess(replicationAction, new ReplicationOptions());
    verifyZeroInteractions(dispatcherFlusher);
}
Also used : ReplicationOptions(com.day.cq.replication.ReplicationOptions) ReplicationAction(com.day.cq.replication.ReplicationAction) Test(org.junit.Test)

Example 15 with ReplicationOptions

use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.

the class DispatcherFlushRulesImplTest method testPreprocess_notAccepts_ReplicationActionTypeTest.

@Test
public void testPreprocess_notAccepts_ReplicationActionTypeTest() throws Exception {
    when(this.hierarchicalFlushRules.size()).thenReturn(9);
    when(this.resourceOnlyFlushRules.size()).thenReturn(9);
    final ReplicationAction replicationAction = mock(ReplicationAction.class);
    when(replicationAction.getPath()).thenReturn("/content/acs-aem-commons");
    when(replicationAction.getType()).thenReturn(ReplicationActionType.TEST);
    dispatcherFlushRules.preprocess(replicationAction, new ReplicationOptions());
    verifyZeroInteractions(dispatcherFlusher);
}
Also used : ReplicationOptions(com.day.cq.replication.ReplicationOptions) ReplicationAction(com.day.cq.replication.ReplicationAction) Test(org.junit.Test)

Aggregations

ReplicationOptions (com.day.cq.replication.ReplicationOptions)17 Test (org.junit.Test)13 ReplicationAction (com.day.cq.replication.ReplicationAction)12 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)7 DispatcherFlushFilter (com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter)6 Session (javax.jcr.Session)2 RoundRobin (com.adobe.acs.commons.functions.RoundRobin)1 ReplicateVersion (com.adobe.acs.commons.replication.ReplicateVersion)1 ReplicationResult (com.adobe.acs.commons.replication.ReplicationResult)1 AgentIdFilter (com.day.cq.replication.AgentIdFilter)1 ReplicationException (com.day.cq.replication.ReplicationException)1 ArrayList (java.util.ArrayList)1 RepositoryException (javax.jcr.RepositoryException)1 Version (javax.jcr.version.Version)1 Resource (org.apache.sling.api.resource.Resource)1