Search in sources :

Example 1 with DispatcherFlushFilter

use of com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter in project acs-aem-commons by Adobe-Consulting-Services.

the class DispatcherFlushRulesImplTest method testPreprocess_success_translation1.

@Test
public void testPreprocess_success_translation1() throws Exception {
    hierarchicalFlushRules.put(Pattern.compile("/content/acs-aem-commons/(.*)"), new String[] { "/content/target/$1" });
    final ReplicationAction replicationAction = mock(ReplicationAction.class);
    when(replicationAction.getPath()).thenReturn("/content/acs-aem-commons/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/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 2 with DispatcherFlushFilter

use of com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter in project acs-aem-commons by Adobe-Consulting-Services.

the class DispatcherFlushRulesImplTest method testPreprocess_success_resourceonly_translation2.

@Test
public void testPreprocess_success_resourceonly_translation2() throws Exception {
    resourceOnlyFlushRules.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.ResourceOnly, 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 3 with DispatcherFlushFilter

use of com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter in project acs-aem-commons by Adobe-Consulting-Services.

the class DispatcherFlushRulesImplTest method testPreprocess_success_resourceOnly.

@Test
public void testPreprocess_success_resourceOnly() throws Exception {
    resourceOnlyFlushRules.put(Pattern.compile("/content/acs-aem-commons/.*"), new String[] { "/content/target" });
    final ReplicationAction replicationAction = mock(ReplicationAction.class);
    when(replicationAction.getPath()).thenReturn("/content/acs-aem-commons/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"));
    assertEquals(DispatcherFlushFilter.FlushType.ResourceOnly, 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 4 with DispatcherFlushFilter

use of com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter in project acs-aem-commons by Adobe-Consulting-Services.

the class DispatcherFlushRulesImplTest method testPreprocess_success_hierarchicalAndResourceOnly.

@Test
public void testPreprocess_success_hierarchicalAndResourceOnly() throws Exception {
    hierarchicalFlushRules.put(Pattern.compile("/content/.*"), new String[] { "/content/hierarchical" });
    resourceOnlyFlushRules.put(Pattern.compile("/content/.*"), new String[] { "/content/resource-only" });
    final ReplicationAction replicationAction = mock(ReplicationAction.class);
    when(replicationAction.getPath()).thenReturn("/content/acs-aem-commons/page");
    when(replicationAction.getType()).thenReturn(ReplicationActionType.ACTIVATE);
    final ReplicationOptions replicationOptions = new ReplicationOptions();
    replicationOptions.setSynchronous(false);
    replicationOptions.setFilter(new DispatcherFlushFilter());
    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/hierarchical"));
    assertEquals(DispatcherFlushFilter.FlushType.Hierarchical, agentFilterCaptor.getValue().getFlushType());
    // Private impl class; no access to test for instanceof
    assertEquals("DispatcherFlushRulesFilter", agentFilterCaptor.getValue().getClass().getSimpleName());
    verify(dispatcherFlusher, times(1)).flush(any(ResourceResolver.class), eq(ReplicationActionType.ACTIVATE), eq(false), agentFilterCaptor.capture(), eq("/content/resource-only"));
    assertEquals(DispatcherFlushFilter.FlushType.ResourceOnly, 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 5 with DispatcherFlushFilter

use of com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter 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)

Aggregations

DispatcherFlushFilter (com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter)6 ReplicationAction (com.day.cq.replication.ReplicationAction)6 ReplicationOptions (com.day.cq.replication.ReplicationOptions)6 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)6 Test (org.junit.Test)6