Package org.kitesdk.data.spi.CharSequences

Examples of org.kitesdk.data.spi.CharSequences.ImmutableCharSequenceSet


  @Test
  public void testStringCharSequenceSetContains() {
    List<String> colors = Lists.newArrayList(
        "orange", "green", "blue", "red", "purple", "red");
    ImmutableCharSequenceSet set = new ImmutableCharSequenceSet(colors);

    for (String color : colors) {
      Assert.assertTrue("Should contain Utf8(value)",
          set.contains(new Utf8(color)));
    }
    Assert.assertTrue("Should contain all values",
        set.containsAll(colors));
  }
View Full Code Here


  @Test
  public void testUtf8CharSequenceSetContains() {
    List<Utf8> colors = Lists.newArrayList(
        new Utf8("orange"), new Utf8("green"), new Utf8("blue"),
        new Utf8("red"), new Utf8("purple"), new Utf8("red"));
    ImmutableCharSequenceSet set = new ImmutableCharSequenceSet(colors);

    for (Utf8 color : colors) {
      Assert.assertTrue("Should contain Utf8(value)",
          set.contains(color.toString()));
    }
    Assert.assertTrue("Should contain all values",
        set.containsAll(colors));
  }
View Full Code Here

  @Test
  public void testStringCharSequenceSetSize() {
    List<String> colors = Lists.newArrayList(
        "orange", "green", "blue", "red", "purple", "red");
    ImmutableCharSequenceSet set = new ImmutableCharSequenceSet(colors);

    Assert.assertEquals("Should remove duplicate color", 5, set.size());
  }
View Full Code Here

  @Test
  public void testUtf8CharSequenceSetSize() {
    List<Utf8> colors = Lists.newArrayList(
        new Utf8("orange"), new Utf8("green"), new Utf8("blue"),
        new Utf8("red"), new Utf8("purple"), new Utf8("red"));
    ImmutableCharSequenceSet set = new ImmutableCharSequenceSet(colors);

    Assert.assertEquals("Should remove duplicate color", 5, set.size());
  }
View Full Code Here

  @Test
  public void testStringCharSequenceSetIterator() {
    List<String> colors = Lists.newArrayList(
        "orange", "green", "blue", "red", "purple", "red");
    Set<String> normalSet = Sets.newHashSet(colors);
    ImmutableCharSequenceSet set = new ImmutableCharSequenceSet(colors);
    for (CharSequence color : set) {
      Assert.assertTrue("Should return original types", color instanceof String);
      normalSet.remove(color);
    }
    Assert.assertTrue("Should iterate through all values", normalSet.isEmpty());
View Full Code Here

  public void testUtf8CharSequenceSetIterator() {
    List<Utf8> colors = Lists.newArrayList(
        new Utf8("orange"), new Utf8("green"), new Utf8("blue"),
        new Utf8("red"), new Utf8("purple"), new Utf8("red"));
    Set<Utf8> normalSet = Sets.newHashSet(colors);
    ImmutableCharSequenceSet set = new ImmutableCharSequenceSet(colors);
    for (CharSequence color : set) {
      Assert.assertTrue("Should return original types", color instanceof Utf8);
      normalSet.remove(color);
    }
    Assert.assertTrue("Should iterate through all values", normalSet.isEmpty());
View Full Code Here

  @Test
  public void testStringCharSequenceSetImmutable() {
    List<String> colors = Lists.newArrayList(
        "orange", "green", "blue", "red", "purple", "red");
    final ImmutableCharSequenceSet set = new ImmutableCharSequenceSet(colors);
    TestHelpers.assertThrows("Should reject additions to the set",
        UnsupportedOperationException.class, new Runnable() {
          @Override
          public void run() {
            set.add("white");
          }
        });
    TestHelpers.assertThrows("Should reject bulk additions to the set",
        UnsupportedOperationException.class, new Runnable() {
          @Override
          public void run() {
            set.addAll(Lists.newArrayList("white", "black"));
          }
        });
    TestHelpers.assertThrows("Should reject removals from the set",
        UnsupportedOperationException.class, new Runnable() {
          @Override
          public void run() {
            set.remove("purple");
          }
        });
    TestHelpers.assertThrows("Should reject bulk removals from the set",
        UnsupportedOperationException.class, new Runnable() {
          @Override
          public void run() {
            set.removeAll(Lists.newArrayList("purple", "red"));
          }
        });
  }
View Full Code Here

  @Test
  public void testUtf8CharSequenceSetImmutable() {
    List<Utf8> colors = Lists.newArrayList(
        new Utf8("orange"), new Utf8("green"), new Utf8("blue"),
        new Utf8("red"), new Utf8("purple"), new Utf8("red"));
    final ImmutableCharSequenceSet set = new ImmutableCharSequenceSet(colors);
    TestHelpers.assertThrows("Should reject additions to the set",
        UnsupportedOperationException.class, new Runnable() {
          @Override
          public void run() {
            set.add(new Utf8("white"));
          }
        });
    TestHelpers.assertThrows("Should reject bulk additions to the set",
        UnsupportedOperationException.class, new Runnable() {
          @Override
          public void run() {
            set.addAll(Lists.newArrayList(new Utf8("white"), new Utf8("black")));
          }
        });
    TestHelpers.assertThrows("Should reject removals from the set",
        UnsupportedOperationException.class, new Runnable() {
          @Override
          public void run() {
            set.remove(new Utf8("purple"));
          }
        });
    TestHelpers.assertThrows("Should reject bulk removals from the set",
        UnsupportedOperationException.class, new Runnable() {
          @Override
          public void run() {
            set.removeAll(Lists.newArrayList(new Utf8("purple"), new Utf8("red")));
          }
        });
  }
View Full Code Here

  @Test
  public void testCharSequenceSetEqualsAndHashCode() {
    List<String> stringColors = Lists.newArrayList(
        "orange", "green", "blue", "red", "purple", "red");
    ImmutableCharSequenceSet strings = new ImmutableCharSequenceSet(stringColors);

    List<Utf8> utf8Colors = Lists.newArrayList(
        new Utf8("orange"), new Utf8("green"), new Utf8("blue"),
        new Utf8("red"), new Utf8("purple"), new Utf8("red"));
    ImmutableCharSequenceSet utf8s = new ImmutableCharSequenceSet(utf8Colors);

    Assert.assertEquals("Identical String and Utf8 sets should be equal",
        strings, utf8s);
    Assert.assertEquals("Sets equal => hash codes equal",
        strings.hashCode(), utf8s.hashCode());
  }
View Full Code Here

TOP

Related Classes of org.kitesdk.data.spi.CharSequences.ImmutableCharSequenceSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.