Merged DEV/ENFORCE to HEAD:

105194: First pass at classification interceptor
   105294: Fixed compilation issue
   105323: Updated Aikau version to 1.0.20
   105565: RM-2129 (Check classification before method execution)
   105923: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106103: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106104: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106169: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106187: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106283: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106356: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106552: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106639: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106657: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106658: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106772: RM-2130 (Check classification after method execution, filtering results where appropriate)
   106774: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107009: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107163: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107164: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107246: RM-2130 Post method invocation processor for QueryEngineResults.
   107252: RM-2130 (Post method invocation processor for QueryEngineResults)
   107253: RM-2130 Make CollectionPostMethodInvocationProcessor concrete.
   107257: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107270: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107272: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107273: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107274: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107275: RM-2130 (Check classification after method execution, filtering results where appropriate)
   107282: RM-2130 Add support for other collections than Lists.
   107344: RM-2367 (Automate AC: Access to saved search)
   107355: RM-2130 Support for specific instantiable collections.
   107363: RM-2130 (Check classification after method execution, filtering results where appropriate)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@107367 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2015-06-29 21:24:16 +00:00
43 changed files with 4521 additions and 160 deletions

View File

@@ -0,0 +1,76 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
/**
* Array Post Method Invocation Processor Unit Test
*
* @author Tuna Aksoy
* @since 3.0
*/
public class ArrayPostMethodInvocationProcessorUnitTest extends BaseUnitTest
{
@InjectMocks ArrayPostMethodInvocationProcessor arrayPostMethodInvocationProcessor;
@Mock private ContentClassificationService mockedContentClassificationService;
@Mock private PostMethodInvocationProcessor mockedPostMethodInvocationProcessor;
@Test
public void testArrayPostMethodInvocationProcessor()
{
NodeRefPostMethodInvocationProcessor processor = new NodeRefPostMethodInvocationProcessor();
processor.setNodeService(mockedNodeService);
processor.setDictionaryService(mockedDictionaryService);
processor.setContentClassificationService(mockedContentClassificationService);
NodeRef nodeRef1 = generateNodeRef();
NodeRef nodeRef2 = generateNodeRef();
NodeRef nodeRef3 = generateNodeRef();
NodeRef nodeRef4 = generateNodeRef();
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef1), TYPE_CONTENT)).thenReturn(true);
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef2), TYPE_CONTENT)).thenReturn(true);
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef3), TYPE_CONTENT)).thenReturn(true);
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef4), TYPE_CONTENT)).thenReturn(true);
when(mockedContentClassificationService.hasClearance(nodeRef1)).thenReturn(true);
when(mockedContentClassificationService.hasClearance(nodeRef2)).thenReturn(false);
when(mockedContentClassificationService.hasClearance(nodeRef3)).thenReturn(true);
when(mockedContentClassificationService.hasClearance(nodeRef4)).thenReturn(false);
when(mockedPostMethodInvocationProcessor.getProcessor(Mockito.any())).thenReturn(processor);
NodeRef[] nodes = new NodeRef[] { nodeRef1, nodeRef2, nodeRef3, nodeRef4 };
NodeRef[] processedNodes = arrayPostMethodInvocationProcessor.process(nodes);
assertEquals(2, processedNodes.length);
assertTrue(ArrayUtils.contains(processedNodes, nodeRef1));
assertTrue(ArrayUtils.contains(processedNodes, nodeRef3));
}
}

View File

@@ -0,0 +1,137 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
/**
* Unit tests for the {@link CollectionPostMethodInvocationProcessor}.
*
* @author Tom Page
* @since 3.0
*/
public class CollectionPostMethodInvocationProcessorUnitTest
{
private static final String NON_FILTERED = "NON_FILTERED";
private static final String FILTERED = "FILTERED";
private static final String CHANGED_INPUT = "CHANGED_INPUT";
private static final String CHANGED_OUTPUT = "CHANGED_OUTPUT";
@InjectMocks CollectionPostMethodInvocationProcessor collectionPostMethodInvocationProcessor;
@Mock PostMethodInvocationProcessor mockPostMethodInvocationProcessor;
@Mock BasePostMethodInvocationProcessor mockStringProcessor;
@Before
public void setUp()
{
initMocks(this);
when(mockPostMethodInvocationProcessor.getProcessor(isA(String.class))).thenReturn(mockStringProcessor);
when(mockStringProcessor.process(NON_FILTERED)).thenReturn(NON_FILTERED);
when(mockStringProcessor.process(FILTERED)).thenReturn(null);
when(mockStringProcessor.process(CHANGED_INPUT)).thenReturn(CHANGED_OUTPUT);
}
@Test
public void testProcess_copesWithNull()
{
Object result = collectionPostMethodInvocationProcessor.process(null);
assertNull("Expected null collection to be passed through.", result);
}
@Test
public void testProcess_nullMember()
{
List<String> collection = new ArrayList<>();
collection.add(null);
Object result = collectionPostMethodInvocationProcessor.process(collection);
assertEquals("Expected collection containing null to be passed through.", collection, result);
}
@Test
public void testProcess_nonFilteredMember()
{
Object collection = Arrays.asList(NON_FILTERED);
Object result = collectionPostMethodInvocationProcessor.process(collection);
assertEquals("Expected element to still be present in result.", collection, result);
}
@Test
public void testProcess_filteredMemberInModifiableList()
{
List<String> collection = new ArrayList<>(Arrays.asList(FILTERED));
Collection<String> result = collectionPostMethodInvocationProcessor.process(collection);
assertTrue("Expected an empty list.", result.isEmpty());
}
@Test
public void testProcess_filteredMemberInUnmodifiableList()
{
List<String> collection = Arrays.asList(FILTERED, NON_FILTERED);
Collection<String> result = collectionPostMethodInvocationProcessor.process(collection);
assertNull("Since the collection could not be modified the whole thing should be filtered.", result);
}
@Test
public void testProcess_modifiedMember()
{
List<String> collection = Arrays.asList(NON_FILTERED, CHANGED_INPUT);
Collection<String> result = collectionPostMethodInvocationProcessor.process(collection);
assertNull("Since the Collection interface does not support replacement, the whole collection should be filtered.",
result);
}
@Test
public void testProcess_noProcessorDefined()
{
List<Integer> collection = Arrays.asList(1, 4, 91);
Collection<Integer> result = collectionPostMethodInvocationProcessor.process(collection);
assertEquals("If no processor is defined for the members then the whole list should be returned.", collection,
result);
}
}

View File

@@ -0,0 +1,112 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
/**
* Unit tests for {@link ListPostMethodInvocationProcessor}.
*
* @author Tom Page
* @since 3.0
*/
public class ListPostMethodInvocationProcessorUnitTest
{
private static final String NON_FILTERED = "NON_FILTERED";
private static final String FILTERED = "FILTERED";
private static final String CHANGED_INPUT = "CHANGED_INPUT";
private static final String CHANGED_OUTPUT = "CHANGED_OUTPUT";
@InjectMocks ListPostMethodInvocationProcessor listPostMethodInvocationProcessor;
@Mock PostMethodInvocationProcessor mockPostMethodInvocationProcessor;
@Mock BasePostMethodInvocationProcessor mockStringProcessor;
@Before
public void setUp()
{
initMocks(this);
when(mockPostMethodInvocationProcessor.getProcessor(isA(List.class))).thenReturn(listPostMethodInvocationProcessor);
when(mockPostMethodInvocationProcessor.getProcessor(isA(String.class))).thenReturn(mockStringProcessor);
when(mockStringProcessor.process(NON_FILTERED)).thenReturn(NON_FILTERED);
when(mockStringProcessor.process(FILTERED)).thenReturn(null);
when(mockStringProcessor.process(CHANGED_INPUT)).thenReturn(CHANGED_OUTPUT);
}
@Test
public void testProcessCollection_emptyList()
{
List<String> collection = new ArrayList<>();
Collection<String> result = listPostMethodInvocationProcessor.processCollection(collection, mockStringProcessor);
assertEquals(collection, result);
}
@Test
public void testProcessCollection_completelyFiltered()
{
List<String> collection = Arrays.asList(FILTERED, FILTERED);
Collection<String> result = listPostMethodInvocationProcessor.processCollection(collection, mockStringProcessor);
assertTrue("Expected all members of the list to be removed.", result.isEmpty());
}
@Test
public void testProcessCollection_supportsReplacement()
{
List<String> collection = Arrays.asList(NON_FILTERED, CHANGED_INPUT);
Collection<String> result = listPostMethodInvocationProcessor.processCollection(collection, mockStringProcessor);
List<String> expected = Arrays.asList(NON_FILTERED, CHANGED_OUTPUT);
assertEquals(expected, result);
}
@Test
public void testProcess_listOfLists()
{
List<String> innerListA = Arrays.asList(FILTERED, NON_FILTERED, CHANGED_INPUT);
List<String> innerListB = Arrays.asList(CHANGED_INPUT, FILTERED, NON_FILTERED);
List<List<String>> collection = Arrays.asList(innerListA, innerListB);
Collection<List<String>> result = listPostMethodInvocationProcessor.process(collection);
List<String> expectedInnerListA = Arrays.asList(NON_FILTERED, CHANGED_OUTPUT);
List<String> expectedInnerListB = Arrays.asList(CHANGED_OUTPUT, NON_FILTERED);
List<List<String>> expected = Arrays.asList(expectedInnerListA, expectedInnerListB);
assertEquals(expected, result);
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import static org.springframework.extensions.webscripts.GUID.generate;
import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.service.cmr.repository.NodeRef;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
/**
* NodeRef Post Method Invocation Processor Unit Test
*
* @author Tuna Aksoy
* @since 3.0
*/
public class NodeRefPostMethodInvocationProcessorUnitTest extends BaseUnitTest
{
@InjectMocks private NodeRefPostMethodInvocationProcessor nodeRefPostMethodInvocationProcessor;
@Mock private ContentClassificationService mockedContentClassificationService;
@Test
public void testProcessingNonExistingNode()
{
NodeRef nodeRef = new NodeRef(generate() + "://" + generate() + "/");
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(true);
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(true);
assertEquals(nodeRef, nodeRefPostMethodInvocationProcessor.process(nodeRef));
}
@Test
public void testProcessingNonContent()
{
NodeRef nodeRef = generateNodeRef();
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(false);
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(true);
assertEquals(nodeRef, nodeRefPostMethodInvocationProcessor.process(nodeRef));
}
@Test
public void testExistingNodeWithUserClearance()
{
NodeRef nodeRef = generateNodeRef();
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(true);
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(true);
assertEquals(nodeRef, nodeRefPostMethodInvocationProcessor.process(nodeRef));
}
@Test
public void testExistingNodeWithNoUserClearance()
{
NodeRef nodeRef = generateNodeRef();
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(true);
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(false);
assertEquals(null, nodeRefPostMethodInvocationProcessor.process(nodeRef));
}
@Test
public void testProcessingNull()
{
assertEquals("Expected null to be passed through without error.", null,
nodeRefPostMethodInvocationProcessor.process((NodeRef) null));
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.alfresco.repo.search.impl.querymodel.QueryEngineResults;
import org.alfresco.service.cmr.search.ResultSet;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import com.google.common.collect.Sets;
/**
* Unit tests for {@link QueryEngineResultPostMethodInvocationProcessor}.
*
* @author Tom Page
* @since 3.0
*/
public class QueryEngineResultsPostMethodInvocationProcessorUnitTest
{
private static final Set<String> KEY_1 = Sets.newHashSet("KEY_1");
private static final Set<String> KEY_2 = Sets.newHashSet("KEY_2");
private static final Set<String> KEY_3 = Sets.newHashSet("KEY_3");
private static final Set<String> KEY_4 = Sets.newHashSet("KEY_4");
private static final ResultSet UNCLASSIFIED_RESULT_SET = mock(ResultSet.class);
private static final ResultSet CLASSIFIED_RESULT_SET = mock(ResultSet.class);
@InjectMocks
private QueryEngineResultsPostMethodInvocationProcessor processor = new QueryEngineResultsPostMethodInvocationProcessor();
@Mock
private PostMethodInvocationProcessor mockPostMethodInvocationProcessor;
@Mock
private ResultSetPostMethodInvocationProcessor mockResultSetPMIP;
@Before
public void setUp()
{
initMocks(this);
when(mockPostMethodInvocationProcessor.getProcessor(Mockito.any())).thenReturn(mockResultSetPMIP);
when(mockResultSetPMIP.process(UNCLASSIFIED_RESULT_SET)).thenReturn(UNCLASSIFIED_RESULT_SET);
when(mockResultSetPMIP.process(CLASSIFIED_RESULT_SET)).thenReturn(null);
}
/** Check that {@code process} filters out the classified result sets. */
@Test
public void testProcess()
{
Map<Set<String>, ResultSet> resultsMap = new HashMap<>();
resultsMap.put(KEY_1, UNCLASSIFIED_RESULT_SET);
resultsMap.put(KEY_2, CLASSIFIED_RESULT_SET);
resultsMap.put(KEY_3, UNCLASSIFIED_RESULT_SET);
resultsMap.put(KEY_4, CLASSIFIED_RESULT_SET);
QueryEngineResults queryEngineResults = new QueryEngineResults(resultsMap);
QueryEngineResults returnedQueryEngineResults = processor.process(queryEngineResults);
Map<Set<String>, ResultSet> expectedResultSet = new HashMap<>();
expectedResultSet.put(KEY_1, UNCLASSIFIED_RESULT_SET);
expectedResultSet.put(KEY_3, UNCLASSIFIED_RESULT_SET);
assertEquals("Unexpected results from query.", expectedResultSet, returnedQueryEngineResults.getResults());
}
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
/**
* Unit tests for {@link SortedSetPostMethodInvocationProcessor}.
*
* @author Tom Page
* @since 3.0
*/
public class SortedSetPostMethodInvocationProcessorUnitTest
{
private static final String NON_FILTERED = "NON_FILTERED";
private static final String FILTERED = "FILTERED";
private static final String SHORT_INPUT = "SHORT_INPUT";
private static final String REALLY_LONG_OUTPUT_STRING = "REALLY_LONG_OUTPUT_STRING";
@InjectMocks SortedSetPostMethodInvocationProcessor sortedSetPostMethodInvocationProcessor;
@Mock BasePostMethodInvocationProcessor mockStringProcessor;
@Before
public void setUp()
{
initMocks(this);
when(mockStringProcessor.process(NON_FILTERED)).thenReturn(NON_FILTERED);
when(mockStringProcessor.process(FILTERED)).thenReturn(null);
when(mockStringProcessor.process(SHORT_INPUT)).thenReturn(REALLY_LONG_OUTPUT_STRING);
}
/**
* Given I have a sorted set of input strings
* When I pass it to the SortedSet processor
* Then I expect items above my clearance to be filtered
* And I expect items below my clearance to be passed through
* And I expect items that get changed by the filtering process to be changed
* And I expect the output set to be sorted using the same comparator as the input.
*/
@Test
public void testProcessCollection()
{
// Create a custom comparator that sorts based on the length of the strings.
Comparator<String> comparator = new Comparator<String>()
{
public int compare(String o1, String o2)
{
return o1.length() - o2.length();
}
};
SortedSet<String> collection = new TreeSet<>(comparator);
collection.add(SHORT_INPUT);
collection.add(NON_FILTERED);
collection.add(FILTERED);
Collection<String> result = sortedSetPostMethodInvocationProcessor.processCollection(collection, mockStringProcessor);
Iterator<String> iterator = result.iterator();
assertEquals("Expected the first element to be the shortest", NON_FILTERED, iterator.next());
assertEquals("Expected the second element to be the longest", REALLY_LONG_OUTPUT_STRING, iterator.next());
assertFalse("Expected two elements in output", iterator.hasNext());
}
}