@Test public void testGetClauseFromParamsFilteredValuesEmpty() throws Exception { final CustomFieldParams customFieldParams = mockController.getMock(CustomFieldParams.class); customFieldParams.getAllValues(); mockController.setReturnValue(CollectionBuilder.newBuilder("").asMutableSet()); final VersionCustomFieldSearchInputTransformer inputTransformer = createTransformer("cf[12345]"); assertNull(inputTransformer.getClauseFromParams(theUser, customFieldParams, null)); mockController.verify(); }
@Override public void validateFromParams( CustomFieldParams cfParams, ErrorCollection errorCollection, FieldConfig fieldConfig) { @SuppressWarnings("unchecked") final Collection<String> params = cfParams.getAllValues(); CustomField cf = fieldConfig.getCustomField(); JiraAuthenticationContext authCtx = ComponentManager.getInstance().getJiraAuthenticationContext(); I18nHelper i18n = authCtx.getI18nHelper(); UserProjectHistoryManager userProjectHistoryManager = ComponentManager.getComponentInstanceOfType(UserProjectHistoryManager.class); Project currentProject = userProjectHistoryManager.getCurrentProject(Permissions.BROWSE, authCtx.getLoggedInUser()); boolean isAutocompleteView; if (cf.isAllProjects()) { isAutocompleteView = qfMgr.isAutocompleteView(cf.getIdAsLong(), Consts.PROJECT_ID_FOR_GLOBAL_CF); } else { isAutocompleteView = qfMgr.isAutocompleteView(cf.getIdAsLong(), currentProject.getId()); } if (isAutocompleteView) { if ((params == null) || params.isEmpty()) { boolean addNull; if (cf.isAllProjects()) { addNull = qfMgr.getAddNull(cf.getIdAsLong(), Consts.PROJECT_ID_FOR_GLOBAL_CF); } else { addNull = qfMgr.getAddNull(cf.getIdAsLong(), currentProject.getId()); } if (!addNull) { errorCollection.addError( fieldConfig.getFieldId(), i18n.getText("queryfields.error.isnotnull")); } } else { if (params.size() > 1) { errorCollection.addError( fieldConfig.getFieldId(), i18n.getText("queryfields.error.invalid.params")); } else { for (String param : params) { Issue issue = issueMgr.getIssueObject(param); if (issue == null) { errorCollection.addError( fieldConfig.getFieldId(), i18n.getText("queryfields.error.notissue", param)); } } } } } }