Example usage for java.util Set containsAll

List of usage examples for java.util Set containsAll

Introduction

In this page you can find the example usage for java.util Set containsAll.

Prototype

boolean containsAll(Collection<?> c);

Source Link

Document

Returns true if this set contains all of the elements of the specified collection.

Usage

From source file:org.jtalks.jcommune.service.nontransactional.MentionedUsersTest.java

@Test
public void extractMentionedUserShouldRecognizeMultipleUsersInBbCodes() {
    String textWithUsersMentioning = "In this text we have 3 user mentioning: first [user]Shogun[/user],"
            + "second [user notified=true]masyan[/user]," + "third [user]jk1[/user]";

    MentionedUsers mentionedUsers = MentionedUsers.parse(textWithUsersMentioning);
    Set<String> extractedUserNames = mentionedUsers.extractAllMentionedUsers(textWithUsersMentioning);

    assertTrue(extractedUserNames.containsAll(asList("Shogun", "masyan", "jk1")));
}

From source file:gov.nih.nci.firebird.data.AbstractRegistrationTest.java

@Test
public void testGetPersons() {
    Set<Person> persons = registration.getPersons();
    for (FormTypeEnum formType : FormTypeEnum.PROTOCOL_REGISTATION_FORM_TYPES) {
        assertTrue(persons.containsAll(registration.getForm(formType).getPersons()));
    }//from  w  ww.j  a va  2 s .c  o m
}

From source file:com.dianping.wed.cache.redis.WeddingRedisServiceImplTest.java

private void testHash() {
    //************************** Hash ********************************//

    //key ?/*from  ww  w. j  a v  a  2 s.c o m*/
    weddingRedisService.del(key);

    long hSet = weddingRedisService.hSet(key, "a", "0");
    Assert.assertTrue(hSet == 1);

    hSet = weddingRedisService.hSet(key, "a", "1");
    Assert.assertTrue(hSet == 0);

    String hGet = weddingRedisService.hGet(key, "a");
    Assert.assertTrue(hGet.equals("1"));

    boolean hExists = weddingRedisService.hExists(key, "a");
    Assert.assertTrue(hExists);

    long hDel = weddingRedisService.hDel(key, "a");
    Assert.assertTrue(hDel == 1);

    hExists = weddingRedisService.hExists(key, "a");
    Assert.assertTrue(!hExists);

    weddingRedisService.hSet(key, "a", "1");
    weddingRedisService.hSet(key, "b", "2");
    weddingRedisService.hSet(key, "c", "3");

    Map<String, String> hGetAll = weddingRedisService.hGetAll(key);
    Assert.assertTrue(hGetAll.size() == 3);

    long hLen = weddingRedisService.hLen(key);
    Assert.assertTrue(hLen == 3);

    long hIncrBy = weddingRedisService.hIncrBy(key, "c", 1);
    Assert.assertTrue(hIncrBy == 4);

    Set<String> hKeys = weddingRedisService.hKeys(key);
    Assert.assertTrue(hKeys.size() == 3);
    List<String> keys = new ArrayList<String>();
    keys.add("a");
    keys.add("b");
    keys.add("c");
    Assert.assertTrue(hKeys.containsAll(keys));

    List<String> hVals = weddingRedisService.hVals(key);
    List<String> vals = new ArrayList<String>();
    keys.add("1");
    keys.add("2");
    keys.add("4");
    Assert.assertTrue(hVals.containsAll(vals));

    Map<String, String> kvs = new HashMap<String, String>();
    kvs.put("1231", "1231");
    kvs.put("1232", "1232");
    kvs.put("1233", "1233");
    kvs.put("1234", "1234");
    String result = weddingRedisService.hMSet(key, kvs);
    Assert.assertTrue(result.equalsIgnoreCase("ok"));
    List<String> resultList = weddingRedisService.hMGet(key, "1231", "1232", "1233", "1234");
    Assert.assertTrue(resultList.size() == 4);
    Assert.assertTrue(resultList.get(0).equalsIgnoreCase("1231"));
}

From source file:com.replaymod.replaystudio.launcher.Launcher.java

private void assertPossible() {
    List<Instruction> instructions = new ArrayList<>(this.instructions);
    Set<String> replays = new HashSet<>(inputs.keySet());
    OUTER: while (!replays.containsAll(outputs.keySet())) {
        for (Instruction instruction : instructions) {
            if (replays.containsAll(instruction.getInputs())) {
                replays.addAll(instruction.getOutputs());
                instructions.remove(instruction);
                continue OUTER;
            }/*from w w w .j av  a 2 s.c  o m*/
        }
        System.out.println("Cannot run all instructions with active config!");
        System.out.println("Instructions missing: " + StringUtils.join(instructions, ','));
        throw new CriticalException(5);
    }
}

From source file:org.apache.stanbol.enhancer.nlp.model.AnalysedTextTest.java

@Test
public void testAnalysedTextaddSpanMethods() {
    Collection<Span> spans = new HashSet<Span>();
    //add some span of different types 
    spans.add(at.addToken(4, 11));/*w  w  w.j a va2s.c o m*/
    spans.add(at.addChunk(4, 19));
    spans.add(at.addSentence(0, 91));
    Set<Span> atSpans = AnalysedTextUtils.asSet(at.getEnclosed(EnumSet.allOf(SpanTypeEnum.class)));
    Assert.assertTrue(spans.containsAll(atSpans));
    Assert.assertTrue(atSpans.containsAll(spans));
}

From source file:com.pinterest.pinlater.backends.redis.PinLaterRedisBackendTest.java

@Test
public void testGetQueueNames() {
    Assert.assertTrue(backend.getQueueNames().get().contains(QUEUE_NAME));

    // Remove the test queue, create 3 more queues.
    backend.cleanUpAllShards().get();/*from w  w  w.j  a  v  a  2s .  com*/
    Set<String> testQueueNames = Sets.newHashSet();
    for (int i = 0; i < 3; i++) {
        String queueName = QUEUE_NAME + i;
        testQueueNames.add(queueName);
        backend.createQueue(queueName).get();
    }
    Set<String> queueNames = backend.getQueueNames().get();
    Assert.assertFalse(queueNames.contains(QUEUE_NAME));
    Assert.assertTrue(queueNames.containsAll(testQueueNames));
}

From source file:com.yahoo.squidb.data.JSONFunctionTest.java

public void testJsonGroupArray() {
    testJsonFunction(new Runnable() {
        @Override//from w w w .  ja v a2s.c o m
        public void run() {
            Thing thing = new Thing();
            for (int i = 0; i < 5; i++) {
                thing.setFoo(Integer.toString(i));
                database.createNew(thing);
            }
            Function<String> groupArray = JSONFunctions.jsonGroupArray(Thing.FOO);
            String result = database.simpleQueryForString(Query.select(groupArray).from(Thing.TABLE));
            try {
                JSONArray resultArray = new JSONArray(result);
                Set<String> resultValues = new HashSet<>();
                for (int i = 0; i < resultArray.length(); i++) {
                    resultValues.add(resultArray.getString(i));
                }
                assertEquals(5, resultValues.size());
                assertTrue(resultValues.containsAll(Arrays.asList("0", "1", "2", "3", "4")));
            } catch (JSONException e) {
                fail("JSONException: " + e.getMessage());
            }
        }
    }, JSONFunctions.JSON1_GROUP_FUNCTIONS_VERSION);
}

From source file:org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1.java

void createSuperTypeEdges(AtlasVertex vertex, Set<String> superTypes, TypeCategory typeCategory)
        throws AtlasBaseException {
    Set<String> currentSuperTypes = getSuperTypeNames(vertex);

    if (CollectionUtils.isNotEmpty(superTypes)) {
        if (!superTypes.containsAll(currentSuperTypes)) {
            throw new AtlasBaseException(AtlasErrorCode.SUPERTYPE_REMOVAL_NOT_SUPPORTED);
        }/*from   w ww.  j a  v  a 2 s . c o m*/

        for (String superType : superTypes) {
            AtlasVertex superTypeVertex = findTypeVertexByNameAndCategory(superType, typeCategory);

            getOrCreateEdge(vertex, superTypeVertex, AtlasGraphUtilsV1.SUPERTYPE_EDGE_LABEL);
        }
    } else if (CollectionUtils.isNotEmpty(currentSuperTypes)) {
        throw new AtlasBaseException(AtlasErrorCode.SUPERTYPE_REMOVAL_NOT_SUPPORTED);
    }
}

From source file:gov.nih.nci.firebird.data.AbstractRegistrationTest.java

@Test
public void testGetOrganizations() {
    Set<Organization> organizations = registration.getOrganizations();
    for (FormTypeEnum formType : FormTypeEnum.PROTOCOL_REGISTATION_FORM_TYPES) {
        assertTrue(organizations.containsAll(registration.getForm(formType).getOrganizations()));
    }/*from  w w w. j ava  2 s  .  c o m*/
}

From source file:jease.cmf.domain.Node.java

/**
 * Appens given children to node. This method automatically detaches all
 * children before each child is attached to the new parent.
 *///from  w ww  . j  a  v  a  2 s.c  o  m
public void appendChildren(final Node[] newChildren) {
    Set<Node> newChildrenSet = new HashSet<>(Arrays.asList(newChildren));
    Set<Node> currentChildrenSet = new HashSet<>(Arrays.asList(children));
    List<Node> result = new ArrayList<>();
    if (newChildrenSet.containsAll(currentChildrenSet)) {
        result.addAll(Arrays.asList(newChildren));
    } else {
        int newChildIndex = 0;
        for (Node child : children) {
            if (newChildrenSet.contains(child)) {
                result.add(newChildren[newChildIndex++]);
            } else {
                result.add(child);
            }
        }
        for (int i = newChildIndex; i < newChildren.length; i++) {
            result.add(newChildren[i]);
        }
    }
    result.forEach(this::appendChild);
}