### Question:
UpdateTreeSetAction extends UpdateTreeAction { @Override public void performAction(SolrUpdateRequest updateRequest) throws IndexingException { if (!(updateRequest instanceof ChildSetRequest)) { throw new IndexingException("ChildSetRequest required to perform TreeSet update, received " + updateRequest.getClass().getName()); } ChildSetRequest childSetRequest = (ChildSetRequest) updateRequest; if (childSetRequest.getChildren() == null || childSetRequest.getChildren().size() == 0) { throw new IllegalArgumentException("Update request must specify one or more children for indexing"); } for (PID pid : childSetRequest.getChildren()) { RepositoryObject obj = repositoryObjectLoader.getRepositoryObject(pid); treeIndexer.index(obj, actionType, updateRequest.getUserID()); } if (log.isDebugEnabled()) { log.debug("Finished updating tree of {}. {} objects updated in {} ms.", new Object[] { updateRequest.getPid().toString(), updateRequest.getChildrenPending(), (System.currentTimeMillis() - updateRequest.getTimeStarted()) }); } }  @Override void performAction(SolrUpdateRequest updateRequest);  }### Answer:
@Test public void testSingleEmptyChild() throws Exception { ContentContainerObject containerObj = makeContainer(repositoryObjectLoader); PID containerPid = containerObj.getPid(); indexTriples(containerObj); request = new ChildSetRequest(containerPid.getRepositoryPath(), asList(containerPid.getRepositoryPath()), IndexingActionType.ADD, USER); action.performAction(request); verify(messageSender).sendIndexingOperation(eq(USER), pidCaptor.capture(), eq(IndexingActionType.ADD)); List<PID> pids = pidCaptor.getAllValues(); assertTrue(pids.contains(containerPid)); }
@Test public void testMultipleChildren() throws Exception { ContentContainerObject container1Obj = makeContainer(repositoryObjectLoader); PID container1Pid = container1Obj.getPid(); ContentContainerObject container2Obj = makeContainer(repositoryObjectLoader); PID container2Pid = container2Obj.getPid(); indexTriples(container1Obj, container2Obj); request = new ChildSetRequest(container1Pid.getRepositoryPath(), asList(container1Pid.getRepositoryPath(), container2Pid.getRepositoryPath()), IndexingActionType.ADD, USER); action.performAction(request); verify(messageSender, times(2)).sendIndexingOperation(eq(USER), pidCaptor.capture(), eq(IndexingActionType.ADD)); List<PID> pids = pidCaptor.getAllValues(); assertTrue(pids.contains(container1Pid)); assertTrue(pids.contains(container2Pid)); }
@Test public void testNestedChildren() throws Exception { ContentContainerObject containerObj = makeContainer(repositoryObjectLoader); PID containerPid = containerObj.getPid(); ContentContainerObject childObj = addContainerToParent(containerObj, repositoryObjectLoader); indexTriples(containerObj, childObj); request = new ChildSetRequest(containerPid.getRepositoryPath(), asList(containerPid.getRepositoryPath()), IndexingActionType.ADD, USER); action.performAction(request); verify(messageSender, times(2)).sendIndexingOperation(eq(USER), pidCaptor.capture(), eq(IndexingActionType.ADD)); List<PID> pids = pidCaptor.getAllValues(); assertTrue(pids.contains(containerPid)); assertTrue(pids.contains(childObj.getPid())); }
@Test(expected = IndexingException.class) public void testNotChildSetRequest() throws Exception { SolrUpdateRequest request = mock(SolrUpdateRequest.class); action.performAction(request); }
@Test(expected = IllegalArgumentException.class) public void testNoChildrenRequest() throws Exception { request = new ChildSetRequest(null, asList(), IndexingActionType.ADD, USER); action.performAction(request); }