Example usage for java.util Collection contains

List of usage examples for java.util Collection contains

Introduction

In this page you can find the example usage for java.util Collection contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this collection contains the specified element.

Usage

From source file:edu.umn.msi.tropix.common.test.Foo.java

public void testTempDirectoryCreator(final TempDirectoryCreator creator) throws Exception {
    final Collection<File> tempDirectories = new LinkedList<File>();
    for (int i = 0; i < 10; i++) {
        final File tempDirectory = creator.getNewTempDirectory();
        assert !tempDirectories.contains(tempDirectory) : "Non unique temp directory created";
        tempDirectories.add(tempDirectory);
        assert tempDirectory.isDirectory() : "Temp directory is not a directory.";
        assert tempDirectory.canWrite() : "Cant write to temp directory.";
        assert tempDirectory.list().length == 0 : "New directory not empty";
    }/*from   w  w w  . j  av  a2 s  .  com*/
}

From source file:com.mtgi.analytics.aop.config.v11.SessionContextConfigurationTest.java

@Test
public void testConfiguration() 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();//from   w  ww . j a  va 2 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());

    //test the state of the global scheduler configuration.
    SchedulerFactory factory = new StdSchedulerFactory();
    Scheduler sched = factory.getScheduler("BeetScheduler");

    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 created", 1, schedulers.size());
    assertTrue(schedulers.contains(sched));

    //verify the default session context implementation has been selected.
    SessionContext context = defaultTrackingManager.getSessionContext();
    assertNotNull(context);

    assertTrue("application context class used", context instanceof TestContext);
    assertSame("application dependency injected into context", testBean, ((TestContext) context).innerBean);
    assertEquals("literal property injected into context", "Hello from testland", ((TestContext) context).prop);
}

From source file:de.dhke.projects.cutil.collections.aspect.AspectMapEntrySet.java

private boolean batchRemove(final Collection<?> c, final boolean retain) {
    for (Map.Entry<K, V> entry : this) {
        if (c.contains(entry) != retain) {
            CollectionItemEvent<Map.Entry<K, V>, Map<K, V>> ev = new CollectionItemEvent<Entry<K, V>, Map<K, V>>(
                    this, _aspectMap, new DefaultMapEntry<>(entry));
            _aspectMap.notifyBeforeElementRemoved(ev);
        }//w w  w  .java2s  .  com
    }
    boolean wasRemoved = false;
    Iterator<Map.Entry<K, V>> iter = _entrySet.iterator();
    while (iter.hasNext()) {
        Map.Entry<K, V> entry = iter.next();
        if (c.contains(entry) != retain) {
            CollectionItemEvent<Map.Entry<K, V>, Map<K, V>> ev = new CollectionItemEvent<Entry<K, V>, Map<K, V>>(
                    this, _aspectMap, new DefaultMapEntry<>(entry));
            iter.remove();
            _aspectMap.notifyAfterElementRemoved(ev);
            wasRemoved = true;
        }
    }
    return wasRemoved;
}

From source file:de.dhke.projects.cutil.collections.aspect.AspectMultiMapEntrySet.java

private boolean batchRemove(Collection<?> c, boolean retain) {
    for (Map.Entry<K, Collection<V>> entry : _entrySet) {
        if (c.contains(entry) != retain) {
            for (V value : entry.getValue()) {
                final Map.Entry<K, V> evEntry = new DefaultMapEntry<>(entry.getKey(), value);
                _aspectMap.notifyBeforeElementRemoved(_aspectMap, evEntry);
            }//from w  w  w  .ja  v  a 2  s. c  om
        }
    }

    final Iterator<Map.Entry<K, Collection<V>>> iter = _entrySet.iterator();
    boolean wasRemoved = false;
    while (iter.hasNext()) {
        Map.Entry<K, Collection<V>> entry = iter.next();
        if (c.contains(entry) != retain) {
            iter.remove();
            wasRemoved = true;
            for (V value : entry.getValue()) {
                Map.Entry<K, V> evEntry = new DefaultMapEntry<>(entry.getKey(), value);
                _aspectMap.notifyAfterElementRemoved(_aspectMap, evEntry);
            }
        }
    }
    return wasRemoved;
}

From source file:de.codecentric.boot.admin.AdminApplicationHazelcastTest.java

@Test
public void test() {
    Application app = Application.create("Hazelcast Test").withHealthUrl("http://127.0.0.1/health").build();
    Application app2 = Application.create("Hazelcast Test").withHealthUrl("http://127.0.0.1:2/health").build();
    Application app3 = Application.create("Do not find").withHealthUrl("http://127.0.0.1:3/health").build();

    // publish app on instance1
    ResponseEntity<Application> postResponse = registerApp(app, instance1);
    app = postResponse.getBody();//from  w ww .  ja va2 s.  c o m
    assertEquals(HttpStatus.CREATED, postResponse.getStatusCode());
    assertNotNull(app.getId());

    // publish app2 on instance2
    ResponseEntity<Application> postResponse2 = registerApp(app2, instance2);
    app2 = postResponse2.getBody();
    assertEquals(HttpStatus.CREATED, postResponse.getStatusCode());
    assertNotNull(app2.getId());

    // retrieve app from instance2
    ResponseEntity<Application> getResponse = getApp(app.getId(), instance2);
    assertEquals(HttpStatus.OK, getResponse.getStatusCode());
    assertEquals(app, getResponse.getBody());

    // retrieve app and app2 from instance1 (but not app3)
    app3 = registerApp(app3, instance1).getBody();
    Collection<Application> apps = getAppByName("Hazelcast Test", instance1).getBody();
    assertEquals(2, apps.size());
    assertTrue(apps.contains(app));
    assertTrue(apps.contains(app2));
    assertFalse(apps.contains(app3));
}

From source file:com.smash.revolance.ui.comparator.element.ElementMatchMaker.java

@Override
public Collection<ElementMatch> findMatch(Collection<ElementBean> elements, ElementBean element,
        ElementSearchMethod... methods) throws NoMatchFound, IllegalArgumentException {
    if (elements == null) {
        throw new IllegalArgumentException("Null content cannot be parsed");
    }//w ww  . j  av a  2s.c o  m
    if (element == null) {
        throw new IllegalArgumentException("Null element cannot be matched.");
    }
    if (elements.isEmpty()) {
        throw new NoMatchFound("Unable to find a single match. Empty element collection passed in.");
    }

    Collection<ElementBean> localElements = new ArrayList<ElementBean>();
    localElements.addAll(elements);
    if (localElements.contains(element)) {
        localElements.remove(element);
    }

    List<ElementMatch> matches = getElementMatches(element, localElements, methods);

    if (matches.isEmpty()) {
        throw new NoMatchFound("Unable to find a single match.");
    } else {
        return matches;
    }
}

From source file:edu.cornell.mannlib.vivo.orcid.controller.OrcidDefaultHandler.java

private boolean isAuthorized() {
    // Only a self-editor is authorized.
    IdentifierBundle ids = RequestIdentifiers.getIdBundleForRequest(vreq);
    Collection<String> profileUris = HasProfile.getProfileUris(ids);
    log.debug("Authorized? individualUri=" + state.getIndividualUri() + ", profileUris=" + profileUris);
    return profileUris.contains(state.getIndividualUri());
}

From source file:com.smash.revolance.ui.comparator.page.PageMatchMaker.java

@Override
public Collection<PageMatch> findMatch(final Collection<PageBean> pages, final PageBean page,
        PageSearchMethod... methods) throws NoMatchFound, IllegalArgumentException {
    if (pages == null) {
        throw new IllegalArgumentException("Null collection of pages to be parsed");
    }// ww  w .j a  v  a2  s  .  c  o  m
    if (page == null) {
        throw new IllegalArgumentException("Null page cannot be matched.");
    }

    Collection<PageBean> localPages = new ArrayList<PageBean>();
    localPages.addAll(pages);
    if (localPages.contains(page)) {
        pages.remove(page);
    }

    List<PageMatch> matches = getPageMatches(page, localPages, methods);

    if (matches.isEmpty()) {
        throw new NoMatchFound("Unable to find a single match.");
    } else {
        return matches;
    }
}

From source file:at.ac.tuwien.qse.sepm.dao.repo.PhotoProviderTest.java

@Test
public void index_someExisting_returnPaths() throws DAOException {
    PhotoProvider object = getObject();/*from  w  w w  . j a  va2 s .c  o m*/
    Photo photo1 = getContext().getPhoto1();
    Photo photo2 = getContext().getPhoto2();
    add(object, photo1);
    add(object, photo2);

    Collection<Path> index = object.index();
    assertEquals(2, index.size());
    assertTrue(index.contains(photo1.getFile()));
    assertTrue(index.contains(photo2.getFile()));
}

From source file:org.simbasecurity.core.domain.repository.PolicyDatabaseRepositoryTest.java

@Test
public void find() {
    Collection<Policy> collection = policyDatabaseRepository.find(user);
    assertEquals(3, collection.size());/*from  w w  w.ja  v a  2  s .com*/
    assertTrue(collection.containsAll(Arrays.asList(policy1, policy2, policy3)));
    assertFalse(collection.contains(policy4));
    assertFalse(collection.contains(policy5));
}