String name = "sample-agent";
ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);
ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);
SimpleReplicationAgent agent = new SimpleReplicationAgent(name,
false, "subServiceName", packageImporter,
packageExporter, packageExporterStrategy,
queueProvider,
distributionHandler, replicationEventFactory, resolverFactory, null);
ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
ReplicationActionType.ADD, "/");
ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
ResourceResolver resourceResolver = mock(ResourceResolver.class);
when(replicationPackage.getPaths()).thenReturn(new String[]{"/"});
when(distributionHandler.add(any(String.class), any(ReplicationPackage.class), eq(queueProvider))).thenReturn(true);
when(packageExporter.exportPackages(any(ResourceResolver.class), any(ReplicationRequest.class)))
.thenReturn(Arrays.asList(replicationPackage));
when(queueProvider.getDefaultQueue(name)).thenReturn(
new SimpleReplicationQueue(name, "name"));
ReplicationResponse response = agent.execute(resourceResolver, request);