Search in sources :

Example 1 with Command

use of org.apache.sling.ide.transport.Command in project sling by apache.

the class DefaultBatcherTest method identicalAddOrUpdatesAreCompacted.

@Test
public void identicalAddOrUpdatesAreCompacted() {
    AddOrUpdateNodeCommand first = new AddOrUpdateNodeCommand(mockRepo, credentials, null, null, new ResourceProxy("/content"), null);
    AddOrUpdateNodeCommand second = new AddOrUpdateNodeCommand(mockRepo, credentials, null, null, new ResourceProxy("/content"), null);
    batcher.add(first);
    batcher.add(second);
    List<Command<?>> batched = batcher.get();
    assertThat(batched, hasSize(1));
    Command<?> command = batched.get(0);
    assertThat(command, instanceOf(AddOrUpdateNodeCommand.class));
    assertThat(command.getPath(), equalTo("/content"));
}
Also used : AddOrUpdateNodeCommand(org.apache.sling.ide.impl.vlt.AddOrUpdateNodeCommand) ReorderChildNodesCommand(org.apache.sling.ide.impl.vlt.ReorderChildNodesCommand) DeleteNodeCommand(org.apache.sling.ide.impl.vlt.DeleteNodeCommand) GetNodeContentCommand(org.apache.sling.ide.impl.vlt.GetNodeContentCommand) Command(org.apache.sling.ide.transport.Command) AddOrUpdateNodeCommand(org.apache.sling.ide.impl.vlt.AddOrUpdateNodeCommand) ResourceProxy(org.apache.sling.ide.transport.ResourceProxy) Test(org.junit.Test)

Example 2 with Command

use of org.apache.sling.ide.transport.Command in project sling by apache.

the class DefaultBatcherTest method testMoreComprehensiveDeletesAreCompacted.

private void testMoreComprehensiveDeletesAreCompacted(String expected, String firstPath, String... otherPaths) {
    batcher.add(new DeleteNodeCommand(mockRepo, credentials, firstPath, null));
    for (String otherPath : otherPaths) {
        batcher.add(new DeleteNodeCommand(mockRepo, credentials, otherPath, null));
    }
    List<Command<?>> batched = batcher.get();
    assertThat(batched, hasSize(1));
    Command<?> command = batched.get(0);
    assertThat(command, instanceOf(DeleteNodeCommand.class));
    assertThat(command.getPath(), equalTo(expected));
}
Also used : ReorderChildNodesCommand(org.apache.sling.ide.impl.vlt.ReorderChildNodesCommand) DeleteNodeCommand(org.apache.sling.ide.impl.vlt.DeleteNodeCommand) GetNodeContentCommand(org.apache.sling.ide.impl.vlt.GetNodeContentCommand) Command(org.apache.sling.ide.transport.Command) AddOrUpdateNodeCommand(org.apache.sling.ide.impl.vlt.AddOrUpdateNodeCommand) DeleteNodeCommand(org.apache.sling.ide.impl.vlt.DeleteNodeCommand)

Example 3 with Command

use of org.apache.sling.ide.transport.Command in project sling by apache.

the class DefaultBatcherTest method identicalsReorderingsAreCompacted.

@Test
public void identicalsReorderingsAreCompacted() {
    ReorderChildNodesCommand first = new ReorderChildNodesCommand(mockRepo, credentials, new ResourceProxy("/content"), null);
    ReorderChildNodesCommand second = new ReorderChildNodesCommand(mockRepo, credentials, new ResourceProxy("/content"), null);
    batcher.add(first);
    batcher.add(second);
    List<Command<?>> batched = batcher.get();
    assertThat(batched, hasSize(1));
    Command<?> command = batched.get(0);
    assertThat(command, instanceOf(ReorderChildNodesCommand.class));
    assertThat(command.getPath(), equalTo("/content"));
}
Also used : ReorderChildNodesCommand(org.apache.sling.ide.impl.vlt.ReorderChildNodesCommand) DeleteNodeCommand(org.apache.sling.ide.impl.vlt.DeleteNodeCommand) GetNodeContentCommand(org.apache.sling.ide.impl.vlt.GetNodeContentCommand) Command(org.apache.sling.ide.transport.Command) AddOrUpdateNodeCommand(org.apache.sling.ide.impl.vlt.AddOrUpdateNodeCommand) ReorderChildNodesCommand(org.apache.sling.ide.impl.vlt.ReorderChildNodesCommand) ResourceProxy(org.apache.sling.ide.transport.ResourceProxy) Test(org.junit.Test)

Aggregations

AddOrUpdateNodeCommand (org.apache.sling.ide.impl.vlt.AddOrUpdateNodeCommand)3 DeleteNodeCommand (org.apache.sling.ide.impl.vlt.DeleteNodeCommand)3 GetNodeContentCommand (org.apache.sling.ide.impl.vlt.GetNodeContentCommand)3 ReorderChildNodesCommand (org.apache.sling.ide.impl.vlt.ReorderChildNodesCommand)3 Command (org.apache.sling.ide.transport.Command)3 ResourceProxy (org.apache.sling.ide.transport.ResourceProxy)2 Test (org.junit.Test)2