Example #1
0
 @Test
 public void testConcatVararg() throws Exception {
   Map<String, String> map = ImmutableMap.of("foo", "bar", "dee", "dum");
   TagList t1 = BasicTagList.of("foo", "bar");
   TagList tags = BasicTagList.concat(t1, new BasicTag("dee", "dum"));
   assertEquals(tags.asMap(), map);
 }
Example #2
0
 @Test
 public void testConcatOverride() throws Exception {
   Map<String, String> map = ImmutableMap.of("foo", "bar2");
   TagList t1 = BasicTagList.of("foo", "bar");
   TagList t2 = BasicTagList.of("foo", "bar2");
   TagList tags = BasicTagList.concat(t1, t2);
   assertEquals(tags.asMap(), map);
 }
Example #3
0
 @Test
 public void testCopy() throws Exception {
   Map<String, String> map = ImmutableMap.of("foo", "bar", "dee", "dum");
   BasicTagList t1 = BasicTagList.of("foo", "bar");
   BasicTagList t2 = BasicTagList.of("foo", "bar2");
   assertEquals(t1.copy("foo", "bar2"), t2);
   assertEquals(t1.copy("dee", "dum").asMap(), map);
 }
Example #4
0
  @Test
  public void testEquals() throws Exception {
    BasicTagList t1 = BasicTagList.of("foo", "bar");
    BasicTagList t2 = BasicTagList.of("foo", "bar2");
    BasicTagList t3 = BasicTagList.of("foo", "bar");

    assertNotNull(t1);
    assertFalse(t1.toString().equals(t2.toString()));
    assertTrue(t1.equals(t1));
    assertFalse(t1.equals(t2));
    assertTrue(t1.equals(t3));
  }
Example #5
0
 @Test
 public void testIterator() throws Exception {
   TagList t1 = BasicTagList.of("foo", "bar");
   for (Tag t : t1) {
     assertEquals(t, new BasicTag("foo", "bar"));
   }
 }
Example #6
0
 @Test
 public void testCopyOfIterableString() throws Exception {
   Map<String, String> map = ImmutableMap.of("foo", "bar", "dee", "dum");
   List<String> input = ImmutableList.of("foo=bar", "dee=dum");
   TagList tags = BasicTagList.copyOf(input);
   assertEquals(tags.asMap(), map);
 }
Example #7
0
 @Test
 public void testAccessors() throws Exception {
   TagList t1 = BasicTagList.of("foo", "bar");
   assertTrue(!t1.isEmpty());
   assertEquals(t1.size(), 1);
   assertEquals(t1.getTag("foo"), new BasicTag("foo", "bar"));
   assertTrue(t1.getTag("dee") == null, "dee is not a tag");
   assertTrue(t1.containsKey("foo"));
   assertTrue(!t1.containsKey("dee"));
 }
Example #8
0
 @Test(expectedExceptions = IllegalArgumentException.class)
 public void testOfOddNumber() {
   BasicTagList.of("foo");
 }
Example #9
0
 @Test
 public void testOf() throws Exception {
   BasicTagList expected = BasicTagList.copyOf(ImmutableMap.of("foo", "bar", "id", "1"));
   BasicTagList of = BasicTagList.of("foo", "bar", "id", "1");
   assertEquals(of, expected);
 }
Example #10
0
  @Test
  public void testHashCode() throws Exception {
    BasicTagList t1 = BasicTagList.of("foo", "bar");
    BasicTagList t2 = BasicTagList.of("foo", "bar2");
    BasicTagList t3 = BasicTagList.of("foo", "bar");

    assertTrue(t1.hashCode() == t1.hashCode());
    assertTrue(t1.hashCode() != t2.hashCode());
    assertTrue(t1.hashCode() == t3.hashCode());
  }