RM-5481 Handle empty string as a reason or exemption id.

If the empty string is passed as a classification reason or exemption id then the API framework
converts it to null for us. We should throw a 404 (not found) error, because there are no reasons
or exemptions with the empty string as their id (or null for that matter).  Add two new REST API
tests for these cases.

Also stopped using the helper method addParam in TopicsWithInstructionsTest, as it is only saving us
about ten characters, causes an extra import and includes an explicit mention of the topicsApi
inside it (i.e. it doesn't work at all with the guidesAPI).
This commit is contained in:
Tom Page
2017-08-03 08:56:04 +01:00
parent fbe2e3dae3
commit c58f7af109
2 changed files with 43 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.util.RMCollectionUtils.Difference;
import org.junit.Test;
@@ -122,4 +123,21 @@ public class RMCollectionUtilsUnitTest
assertEquals(s, l);
}
@Test public void toImmutableSet_nullInput()
{
Set<String> output = RMCollectionUtils.toImmutableSet(null);
assertNull("toImmutableSet should pass through with null.", output);
}
@Test public void toImmutableSet_nullElement()
{
Set<String> input = newHashSet("One", null, "Three");
// Call the method under test.
Set<String> output = RMCollectionUtils.toImmutableSet(input);
assertEquals("Unexpected handling of null input element", output, newHashSet("One", "Three"));
assertEquals("Input should not have been changed.", input, newHashSet("One", null, "Three"));
}
}