List of usage examples for java.util Collection contains
boolean contains(Object o);
From source file:com.yahoo.sshd.authentication.file.TestPKUpdating.java
private void checkDoesntExist(TestContext testContext, User[] users) { Collection<String> authenticatedUsers = testContext.publickeyAuthenticator.getUsers(); for (User user : users) { Assert.assertFalse(authenticatedUsers.contains(user.name), "expected " + user + " not to be authenticated"); }// w w w.j a v a 2 s . c om }
From source file:guru.qas.martini.DefaultMixologistTest.java
@Test public void testGetByClassificationHierarchy() { String id = "Functionality_of_the_Reporting_Subsystem:A_Corner_Case:25"; Martini expected = this.getMartini(id); String filter = "isCategory('Core')"; Collection<Martini> martinis = mixologist.getMartinis(filter); assertTrue(martinis.contains(expected), "expected Martini not returned"); }
From source file:edu.hm.cs.fs.scriptinat0r7.model.ScriptDocument.java
public boolean isOnePasswordMatching(final Collection<String> passwords) { return StringUtils.isEmpty(getPassword()) || passwords.contains(getPassword()); }
From source file:MultiMap.java
/** * /*from w w w . ja va2 s.c o m*/ * @param value * * @return True if one or more of the keys in this map points to the * given value. * */ public final boolean containsValue(Object value) { Iterator i = values().iterator(); // // look through each map entry's set of values to see if // the given value is present // while (i.hasNext()) { Collection values = (Collection) i.next(); if (values.contains(value)) return true; } return false; }
From source file:guru.qas.martini.DefaultMixologistTest.java
@Test public void testGetCustomSPeL() { String id = "Functionality_of_the_Reporting_Subsystem:A_Corner_Case:25"; Martini expected = getMartini(id);/*w w w . j a v a2s .co m*/ checkNotNull(expected, "no Martini found matching ID [%s]", id); String filter = "isMeta('Selenium')"; Collection<Martini> martinis = mixologist.getMartinis(filter); assertTrue(martinis.contains(expected), "expected Martini not returned"); }
From source file:guru.qas.martini.DefaultMixologistTest.java
@Test public void testGetByClassification() { String id = "Functionality_of_the_Reporting_Subsystem:A_Corner_Case:25"; Martini expected = this.getMartini(id); checkNotNull(expected, "no Martini found matching ID [%s]", id); String filter = "isCategory('AdHoc')"; Collection<Martini> martinis = mixologist.getMartinis(filter); assertTrue(martinis.contains(expected), "expected Martini not returned"); }
From source file:MultiMap.java
/** * Check if the map contains the passed value. * * @param value the value to search for * @return true if the list contains the value *///www . jav a2 s . c o m public boolean containsValue(Object value) { Set pairs = super.entrySet(); if (pairs == null) { return false; } Iterator pairsIterator = pairs.iterator(); while (pairsIterator.hasNext()) { Map.Entry keyValuePair = (Map.Entry) pairsIterator.next(); Collection coll = (Collection) keyValuePair.getValue(); if (coll.contains(value)) { return true; } } return false; }
From source file:eu.trentorise.smartcampus.resourceprovider.filter.ResourceAuthenticationManager.java
/** * Check whether the access to the specific resource is granted. The The * resource is identified from the {@link ResourceCallAuthenticationToken} * fields {@link ResourceCallAuthenticationToken#getRequestPath()} and * {@link ResourceCallAuthenticationToken#getHttpMethod()}. * /*from www . ja va 2 s . c o m*/ * @param authentication * the authentication token object as instance of * {@link ResourceCallAuthenticationToken}. */ @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { assert authentication instanceof ResourceCallAuthenticationToken; ResourceCallAuthenticationToken rcAuth = (ResourceCallAuthenticationToken) authentication; String token = (String) rcAuth.getPrincipal(); OAuth2Authentication auth = loadAuthentication(token); if (auth == null) { throw new InvalidTokenException("Invalid token: " + token); } String resourceUri; try { resourceUri = getUriManager().getUriFromRequest(rcAuth.getRequestPath(), rcAuth.getHttpMethod(), auth.getAuthorities()); } catch (IOException e) { throw new OAuth2Exception("Problem accessing resource descriptor"); } String resourceID = resourceUri;// resourceStore.loadResourceByResourceUri(resourceUri); // test senza lettura db Collection<String> resourceIds = auth.getAuthorizationRequest().getScope(); if (resourceID == null || resourceIds.isEmpty() || !resourceIds.contains(resourceID)) { throw new OAuth2AccessDeniedException( "Invalid token does not contain resource id (" + resourceUri + ")"); } String authority = authServices.loadResourceAuthorityByResourceUri(resourceUri); if (ROLE_USER.equals(authority) && auth.isClientOnly()) { throw new OAuth2AccessDeniedException("Incorrect access method"); } if (ROLE_CLIENT.equals(authority) && !auth.isClientOnly()) { throw new OAuth2AccessDeniedException("Incorrect access method"); } auth.setDetails(authentication.getDetails()); return auth; }
From source file:com.mtgi.analytics.aop.config.v11.DefaultConfigurationTest.java
@Test public void testDefaultConfiguration() throws Exception { assertNotNull("default tracking manager configured", defaultTrackingManager); assertEquals("application name set", "testApp", defaultTrackingManager.getApplication()); assertEquals("default persister type provided", XmlBehaviorEventPersisterImpl.class, defaultTrackingManager.getPersister().getClass()); //verify that the default xml persister configuration has been applied. XmlBehaviorEventPersisterImpl persister = (XmlBehaviorEventPersisterImpl) defaultTrackingManager .getPersister();/* w w w. j av a2 s. c o m*/ assertTrue(persister.isBinary()); assertTrue(persister.isCompress()); assertTrue("default file name [" + persister.getFile() + "]", new File(persister.getFile()).getName().startsWith("beet")); //verify proper configuration of log flush and rotation using private task executor and scheduler instances TaskExecutor executor = defaultTrackingManager.getExecutor(); assertEquals("default executor type provided", ThreadPoolTaskExecutor.class, executor.getClass()); assertNotSame("private executor created", testExecutor, executor); String[] groups = testScheduler.getTriggerGroupNames(); for (String g : groups) { String[] names = testScheduler.getTriggerNames(g); assertEquals("no triggers scheduled in application scheduler for " + g + ": " + Arrays.asList(names), 0, names.length); } //test the state of the global scheduler configuration. SchedulerFactory factory = new StdSchedulerFactory(); Scheduler sched = factory.getScheduler("BeetScheduler"); assertNotSame("private scheduler instance initialized", testScheduler, sched); List<String> triggers = Arrays.asList(sched.getTriggerNames("beet")); assertEquals("flush and rotate jobs scheduled", 2, triggers.size()); assertTrue("flush job scheduled", triggers.contains("defaultTrackingManager_flush_trigger")); assertTrue("rotate job scheduled", triggers.contains("org.springframework.scheduling.quartz.CronTriggerBean_rotate_trigger")); Collection<?> schedulers = factory.getAllSchedulers(); assertEquals("private scheduler and application scheduler created", 2, schedulers.size()); assertTrue(schedulers.contains(sched)); assertTrue(schedulers.contains(testScheduler)); //verify the default session context implementation has been selected. SessionContext context = defaultTrackingManager.getSessionContext(); assertNotNull(context); assertTrue("JAAS context used by default", context instanceof JAASSessionContext); }
From source file:com.mtgi.analytics.aop.config.v11.WebContextConfigurationTest.java
@Test public void testDefaultConfiguration() throws Exception { assertNotNull("default tracking manager configured", defaultTrackingManager); assertEquals("application name set", "testApp", defaultTrackingManager.getApplication()); assertEquals("default persister type provided", XmlBehaviorEventPersisterImpl.class, defaultTrackingManager.getPersister().getClass()); //verify that the default xml persister configuration has been applied. XmlBehaviorEventPersisterImpl persister = (XmlBehaviorEventPersisterImpl) defaultTrackingManager .getPersister();//w w w. java 2 s . com assertTrue(persister.isBinary()); assertTrue(persister.isCompress()); assertTrue("default file name [" + persister.getFile() + "]", new File(persister.getFile()).getName().startsWith("beet")); //verify proper configuration of log flush and rotation using private task executor and scheduler instances TaskExecutor executor = defaultTrackingManager.getExecutor(); assertEquals("default executor type provided", ThreadPoolTaskExecutor.class, executor.getClass()); assertNotSame("private executor created", testExecutor, executor); String[] groups = testScheduler.getTriggerGroupNames(); for (String g : groups) { String[] names = testScheduler.getTriggerNames(g); assertEquals("no triggers scheduled in application scheduler for " + g + ": " + Arrays.asList(names), 0, names.length); } //test the state of the global scheduler configuration. SchedulerFactory factory = new StdSchedulerFactory(); Scheduler sched = factory.getScheduler("BeetScheduler"); assertNotSame("private scheduler instance initialized", testScheduler, sched); List<String> triggers = Arrays.asList(sched.getTriggerNames("beet")); assertEquals("flush and rotate jobs scheduled", 2, triggers.size()); assertTrue("flush job scheduled", triggers.contains("defaultTrackingManager_flush_trigger")); assertTrue("rotate job scheduled", triggers.contains("org.springframework.scheduling.quartz.CronTriggerBean_rotate_trigger")); Collection<?> schedulers = factory.getAllSchedulers(); assertEquals("private scheduler and application scheduler created", 2, schedulers.size()); assertTrue(schedulers.contains(sched)); assertTrue(schedulers.contains(testScheduler)); //verify the appropriate default session context implementation has been selected. SessionContext context = defaultTrackingManager.getSessionContext(); assertNotNull(context); assertTrue("web-sensitive context used by default", context instanceof SpringSessionContext); }