mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2217 Allow null as a filter value.
Also add a few unit tests for the file. +review RM-96 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@106034 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -147,11 +147,12 @@ public class UserSecurityClearanceGet extends AbstractRmWebScript
|
|||||||
* Gets the name filter from the webscript request
|
* Gets the name filter from the webscript request
|
||||||
*
|
*
|
||||||
* @param req {@link WebScriptRequest} The webscript request
|
* @param req {@link WebScriptRequest} The webscript request
|
||||||
* @return {@link String} The name filter (can be null)
|
* @return {@link String} The name filter from the request (or the empty string if the request doesn't contain one).
|
||||||
*/
|
*/
|
||||||
private String getNameFilter(WebScriptRequest req)
|
private String getNameFilter(WebScriptRequest req)
|
||||||
{
|
{
|
||||||
return req.getParameter(NAME_FILTER);
|
String nameFilter = req.getParameter(NAME_FILTER);
|
||||||
|
return (nameFilter != null ? nameFilter : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests for the {@link UserQueryParams}.
|
||||||
|
*
|
||||||
|
* @author tpage
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public class UserQueryParamsUnitTest
|
||||||
|
{
|
||||||
|
private static final QName QNAME1 = QName.createQName("1");
|
||||||
|
private static final QName QNAME2 = QName.createQName("2");
|
||||||
|
|
||||||
|
/** Check that the constructor escapes backslashes correctly. */
|
||||||
|
@Test
|
||||||
|
public void testConstructor_backSlashes()
|
||||||
|
{
|
||||||
|
UserQueryParams userQueryParams = new UserQueryParams("\\Hello\\\\World!");
|
||||||
|
assertEquals("\\\\Hello\\\\\\\\World!", userQueryParams.getSearchTerm());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check that the constructor rejects null. */
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testConstructor_null()
|
||||||
|
{
|
||||||
|
new UserQueryParams(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check that providing two properties results in a list being returned. */
|
||||||
|
@Test
|
||||||
|
public void testWithFilterProps_twoProperties()
|
||||||
|
{
|
||||||
|
UserQueryParams userQueryParams = new UserQueryParams("Search term");
|
||||||
|
userQueryParams.withFilterProps(QNAME1, QNAME2);
|
||||||
|
assertEquals(Arrays.asList(QNAME1, QNAME2), userQueryParams.getFilterProps());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check that the first parameter can't be null. */
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testWithFilterProps_firstPropertyNull()
|
||||||
|
{
|
||||||
|
UserQueryParams userQueryParams = new UserQueryParams("Search term");
|
||||||
|
userQueryParams.withFilterProps(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check that providing a null after the first argument fails. */
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testWithFilterProps_containsNull()
|
||||||
|
{
|
||||||
|
UserQueryParams userQueryParams = new UserQueryParams("Search term");
|
||||||
|
userQueryParams.withFilterProps(QNAME1, (QName) null);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user