@Test public void traverse_many() throws PersistenceException, AecuException { List<Resource> results = new ArrayList<>(); for (int i = 0; i < 1500; i++) { results.add(resource); } when(resolver.findResources(QUERY, TYPE)).thenReturn(results.iterator()); ForQuery traverser = new ForQuery(QUERY, TYPE); traverser.traverse(context, null, actions, output, false); verify(action, times(1500)).doAction(resource); verify(resolver, times(1)).commit(); }
@Override public void traverse(@Nonnull BindingContext context, FilterBy filter, @Nonnull List<Action> actions, @Nonnull StringBuilder output, boolean dryRun) throws PersistenceException, AecuException { ResourceResolver resourceResolver = context.getResolver(); Iterator<Resource> queryResult = resourceResolver.findResources(query, queryType); while (queryResult.hasNext()) { Resource resource = queryResult.next(); applyActionsOnResource(resource, filter, actions, output, dryRun); } }
ForQuery extends TraversData { @Override public void traverse(@Nonnull BindingContext context, FilterBy filter, @Nonnull List<Action> actions, @Nonnull StringBuilder output, boolean dryRun) throws PersistenceException, AecuException { ResourceResolver resourceResolver = context.getResolver(); Iterator<Resource> queryResult = resourceResolver.findResources(query, queryType); while (queryResult.hasNext()) { Resource resource = queryResult.next(); applyActionsOnResource(resource, filter, actions, output, dryRun); } } }
ForQuery extends TraversData { @Override public void traverse(@Nonnull BindingContext context, FilterBy filter, @Nonnull List<Action> actions, @Nonnull StringBuilder output, boolean dryRun) throws PersistenceException, AecuException { ResourceResolver resourceResolver = context.getResolver(); Iterator<Resource> queryResult = resourceResolver.findResources(query, queryType); while (queryResult.hasNext()) { Resource resource = queryResult.next(); applyActionsOnResource(resource, filter, actions, output, dryRun); } } ForQuery(@Nonnull String query, @Nonnull String queryType); }
ForQuery extends TraversData { @Override public void traverse(@Nonnull BindingContext context, FilterBy filter, @Nonnull List<Action> actions, @Nonnull StringBuilder output, boolean dryRun) throws PersistenceException, AecuException { ResourceResolver resourceResolver = context.getResolver(); Iterator<Resource> queryResult = resourceResolver.findResources(query, queryType); while (queryResult.hasNext()) { Resource resource = queryResult.next(); applyActionsOnResource(resource, filter, actions, output, dryRun); } } ForQuery(@Nonnull String query, @Nonnull String queryType); @Override void traverse(@Nonnull BindingContext context, FilterBy filter, @Nonnull List<Action> actions,
            @Nonnull StringBuilder output, boolean dryRun); }
ForQuery extends TraversData { @Override public void traverse(@Nonnull BindingContext context, FilterBy filter, @Nonnull List<Action> actions, @Nonnull StringBuilder output, boolean dryRun) throws PersistenceException, AecuException { ResourceResolver resourceResolver = context.getResolver(); Iterator<Resource> queryResult = resourceResolver.findResources(query, queryType); while (queryResult.hasNext()) { Resource resource = queryResult.next(); applyActionsOnResource(resource, filter, actions, output, dryRun); } } ForQuery(@Nonnull String query, @Nonnull String queryType); @Override void traverse(@Nonnull BindingContext context, FilterBy filter, @Nonnull List<Action> actions,
            @Nonnull StringBuilder output, boolean dryRun);  }