List of usage examples for org.apache.commons.collections CollectionUtils exists
public static boolean exists(Collection collection, Predicate predicate)
From source file:org.openmrs.web.dwr.DWRProviderServiceTest.java
/** * @see DWRProviderService#findProvider(String,boolean,Integer,Integer) * @verifies return the list of providers including retired providers for the matching search * name/*from www . jav a 2 s .c om*/ */ @Test public void findProvider_shouldReturnTheListOfProvidersIncludingRetiredProvidersForTheMatchingSearchName() throws Exception { Vector<Object> providers = service.findProvider("provider", true, 0, 10); Assert.assertEquals(4, providers.size()); Assert.assertTrue(CollectionUtils.exists(providers, new Predicate() { @Override public boolean evaluate(Object object) { return ((ProviderListItem) object).getDisplayName().equals("Jimmy Manana Chemalit"); } })); }
From source file:org.pentaho.test.platform.plugin.pluginmgr.SystemPathPluginProviderIT.java
@SuppressWarnings("deprecation") @Test/*from w w w . j av a 2 s . co m*/ public void testLoad_Good() throws PlatformPluginRegistrationException { microPlatform.init(); PluginMessageLogger.clear(); List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession()); // should successfully load good-plugin1 and good-plugin2 and not load bad-plugin. The fact // that bad-plugin does not load should not prevent the good ones from being loaded assertTrue("plugin1 was not found", CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 1"))); assertTrue("plugin2 was not found", CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 2"))); // make sure that the bad plugin caused an error message to be logged assertEquals("bad plugin did not log an error message", 1, PluginMessageLogger.count("SystemPathXmlPluginProvider.ERROR_0001")); for (String msg : PluginMessageLogger.getAll()) { System.err.println(msg); } }
From source file:org.pentaho.test.platform.plugin.pluginmgr.SystemPathPluginProviderIT.java
@SuppressWarnings("deprecation") @Test/* w ww . j a v a 2s.c o m*/ public void tesLoadtLifecycleListener() throws PlatformPluginRegistrationException { microPlatform.init(); PluginMessageLogger.clear(); List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession()); // first make sure Plugin 1 was loaded, otherwise our check for lifcycle class will never happen assertTrue("plugin1 was not found", CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 1"))); for (IPlatformPlugin plugin : plugins) { if (plugin.getId().equals("Plugin 1")) { assertEquals("org.pentaho.test.platform.plugin.pluginmgr.FooInitializer", plugin.getLifecycleListenerClassname()); } if (plugin.getId().equals("Plugin 2")) { // no listener defined to for Plugin 2 assertNull(plugin.getLifecycleListenerClassname()); } } }
From source file:org.squashtest.tm.service.internal.execution.ExecutionStepModificationHelper.java
private boolean sameAttach(ExecutionStep eStep, ActionTestStep aStep) { Set<Attachment> eStepAttach = eStep.getAttachmentList().getAllAttachments(); Set<Attachment> aStepAttach = aStep.getAllAttachments(); if (eStepAttach.size() != aStepAttach.size()) { return false; }/* www.j a v a 2s .c o m*/ for (final Attachment aAttach : aStepAttach) { boolean exist = CollectionUtils.exists(eStepAttach, new Predicate() { @Override public boolean evaluate(Object eAttach) { Attachment toCompare = (Attachment) eAttach; boolean sameName = toCompare.getName().equals(aAttach.getName()); boolean sameSize = toCompare.getSize().equals(aAttach.getSize()); return sameName && sameSize; } }); if (!exist) { return false; } } return true; }
From source file:org.tonguetied.datatransfer.exporting.ResourcePostProcessor.java
/** * Process the list of {@link Translation}s to include translations in * global bundles into each selected bundle. If two translations exist with * different global bundles, then only one of the translations will be * added. This will be process on first occurrence. * /*w w w . ja va2s .c o m*/ * @param translations the {@link Translation}s to process * @return a processed list of {@link Translation}s */ public List<Translation> transformData(List<Translation> translations) { List<Translation> results; if (parameters.isGlobalsMerged()) { if (logger.isDebugEnabled()) logger.debug("merging global bundle values"); results = new ArrayList<Translation>(); final List<Bundle> bundles = getNonGlobalBundle(parameters.getBundles()); Translation clone; TranslationKeywordPredicate predicate; for (Translation translation : translations) { if (translation.getBundle().isGlobal()) { for (final Bundle bundle : bundles) { predicate = new TranslationKeywordPredicate(translation.getKeyword().getKeyword(), bundle, translation.getCountry(), translation.getLanguage()); // If the translation for that keyword does not yet // exist then add if (!CollectionUtils.exists(results, predicate)) { clone = translation.deepClone(); clone.setBundle(bundle); results.add(clone); } } } else { results.add(translation); } } } else { if (translations == null) results = new ArrayList<Translation>(); else results = translations; } return results; }
From source file:org.xlcloud.console.virtualClusterDefinitions.validators.TemplateParameterNameValidator.java
/** {@inheritDoc} */ @Override//from ww w. ja v a 2 s. co m public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { String validatedName = (String) value; Predicate predicate = new ParameterByNamePredicate(validatedName); if (CollectionUtils.exists(existingElements, predicate)) { throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, messages.getValue("error"), messages.getValue("vcDefinitions.editor.parameters.nameUnique"))); } }
From source file:org.xlcloud.console.virtualClusterDefinitions.validators.TemplateResourceNameValidator.java
/** {@inheritDoc} */ @Override// w w w . j a v a2 s. c o m public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { String validatedName = (String) value; Predicate predicate = new ResourceByNamePredicate(validatedName); if (CollectionUtils.exists(existingElements, predicate)) { throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, messages.getValue("error"), messages.getValue("vcDefinitions.editor.resources.nameUnique"))); } }
From source file:qtiscoringengine.ExprNot.java
@Override protected DataElement exprEvaluate(VariableBindings vb, QTIRubric rubric, List<DataElement> paramValues) { if (CollectionUtils.exists(paramValues, new Predicate() { @Override/*from w w w. ja v a 2 s .c om*/ public boolean evaluate(Object arg0) { if (arg0 == null) return true; return false; } })) return null; double val = ((_DEFloat) paramValues.get(0)).getValue().doubleValue(); for (int i = 1; i < paramValues.size(); i++) { val *= ((_DEFloat) paramValues.get(i)).getValue().doubleValue(); } return new DEFloat(val); }
From source file:qtiscoringengine.ExprNot.java
@Override protected DataElement exprEvaluate(VariableBindings vb, QTIRubric rubric, List<DataElement> paramValues) { if (CollectionUtils.exists(paramValues, new Predicate() { @Override/*w ww . java2 s .c o m*/ public boolean evaluate(Object arg0) { if (arg0 == null) return true; return false; } })) return null; return new DEFloat(((_DEFloat) paramValues.get(0)).getValue().doubleValue() - ((_DEFloat) paramValues.get(1)).getValue().doubleValue()); }
From source file:qtiscoringengine.ExprNot.java
@Override protected DataElement exprEvaluate(VariableBindings vb, QTIRubric rubric, List<DataElement> paramValues) { if (CollectionUtils.exists(paramValues, new Predicate() { @Override/*ww w . j a va2s . c o m*/ public boolean evaluate(Object arg0) { if (arg0 == null) return true; return false; } })) return null; return new DEFloat(((_DEFloat) paramValues.get(0)).getValue().doubleValue() / ((_DEFloat) paramValues.get(1)).getValue().doubleValue()); }