示例#1
0
  @Test
  public void testContainsType() {
    Collection<A> collection = new HashSet<A>();
    collection.add(new B());
    collection.add(new B());

    assertTrue(Groups.containsType(A.class, collection));
    assertTrue(Groups.containsType(B.class, collection));
    assertFalse(Groups.containsType(C.class, collection));
  }
示例#2
0
  @Test
  public void testFirstOfType() {
    Collection<A> collection = new HashSet<A>();
    collection.add(new B());
    collection.add(new B());

    assertTrue(Groups.firstOfType(C.class, collection) == null);
    assertTrue(collection.contains(Groups.firstOfType(A.class, collection)));
    assertTrue(collection.contains(Groups.firstOfType(B.class, collection)));
  }
示例#3
0
  @Test
  public void testFirstEmpty() {
    Collection<String> collection = new HashSet<String>();

    assertTrue(Groups.first(collection) == null);

    collection.add("Hello World");
    assertTrue(Groups.first(collection).equals("Hello World"));

    collection.add("Goodbye World");
    assertTrue(collection.contains(Groups.first(collection)));
  }
示例#4
0
  @Test
  public void testOfType() {
    Collection<A> collection = new HashSet<A>();
    collection.add(new A());
    collection.add(new B());
    collection.add(new B());
    collection.add(new A());
    collection.add(new B());
    collection.add(new A());
    collection.add(new A());
    collection.add(new C());

    assertTrue(Groups.ofType(A.class, collection).size() == 8);
    assertTrue(Groups.ofType(B.class, collection).size() == 3);
    assertTrue(Groups.ofType(C.class, collection).size() == 1);
  }