@SuppressWarnings("deprecation") @Test public void testLoad_Good() throws PlatformPluginRegistrationException { microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).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); } }
@SuppressWarnings("deprecation") @Test public void tesLoadtLifecycleListener() throws PlatformPluginRegistrationException { microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).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()); } } }
@Atomic public static Boolean run(Person person, ExecutionCourse executionCourse) throws NotAuthorizedException { AbstractModifyProfessorshipWithPerson.run(person); Professorship professorshipToDelete = person.getProfessorshipByExecutionCourse(executionCourse); Collection shiftProfessorshipList = professorshipToDelete.getAssociatedShiftProfessorshipSet(); boolean hasCredits = false; if (!shiftProfessorshipList.isEmpty()) { hasCredits = CollectionUtils.exists( shiftProfessorshipList, new Predicate() { @Override public boolean evaluate(Object arg0) { ShiftProfessorship shiftProfessorship = (ShiftProfessorship) arg0; return shiftProfessorship.getPercentage() != null && shiftProfessorship.getPercentage() != 0; } }); } if (!hasCredits) { professorshipToDelete.delete(); } else { if (hasCredits) { throw new DomainException("error.remove.professorship"); } } return Boolean.TRUE; }
@Override protected void doValidation() { super.doValidation(); if (CollectionUtils.exists( issueTypeSchemeManager.getAllSchemes(), new FieldConfigPredicate(getSchemeId(), getName()))) { addError("name", getText("admin.errors.issuetypes.duplicate.name")); } if ((getSelectedOptions() != null) && (getSelectedOptions().length > 0)) { boolean hasNormalIssueType = false; for (int i = 0; i < getSelectedOptions().length; i++) { final String id = getSelectedOptions()[i]; final IssueType issueType = constantsManager.getIssueTypeObject(id); if (!issueType.isSubTask()) { hasNormalIssueType = true; break; } } if (!hasNormalIssueType) { addErrorMessage(getText("admin.errors.issuetypes.must.select.standard.issue.type")); } } }
protected boolean requestURIRequiresAuthentication(final HttpServletRequest request) { return !CollectionUtils.exists( getUnprotectedURIs(), new Predicate() { public boolean evaluate(Object uri) { return request.getRequestURI().startsWith(uri.toString()); } }); }
/** * @param classNode a ClassNode to search * @param annotationsToLookFor Annotations to look for * @return true if classNode is marked with any of the annotations in annotationsToLookFor */ public static boolean hasAnyAnnotations( final ClassNode classNode, final Class<? extends Annotation>... annotationsToLookFor) { return CollectionUtils.exists( Arrays.asList(annotationsToLookFor), new Predicate() { @SuppressWarnings({"unchecked", "rawtypes"}) public boolean evaluate(Object object) { return hasAnnotation(classNode, (Class) object); } }); }
@Test public void list_contains_any_apache_commons() { boolean vehiclesContainYukon = CollectionUtils.exists( vehicles, new org.apache.commons.collections.Predicate() { public boolean evaluate(Object object) { Vehicle vehicle = (Vehicle) object; return vehicle.model.contains("YUKON"); } }); assertTrue(vehiclesContainYukon); }
private boolean isServiceUsedForOrders(URI tenantId, CatalogService service) { String serviceId = service.getId().toString(); List<Order> orders = orderManager.getOrders(tenantId); return CollectionUtils.exists(orders, new ServiceIdPredicate(serviceId)); }