示例#1
0
  @Test
  public void testGetFromStringSingleItem() throws Exception {
    Path path = Path.fromDotString("1");

    Assert.assertThat(path.getSize(), is(1));
    Assert.assertThat(path.get(0), is("1"));
  }
示例#2
0
  @Test
  public void testGetFromString() throws Exception {
    Path path = Path.fromDotString("1.2.3");

    Assert.assertThat(path.getSize(), is(3));

    Assert.assertThat(path.get(0), is("1"));
    Assert.assertThat(path.get(1), is("2"));
    Assert.assertThat(path.get(2), is("3"));
  }
示例#3
0
  @Test
  public void testGetParent() throws Exception {
    Path path;

    path = Path.fromDotString("1.2.3");
    Assert.assertThat(path.getParent(), is(Path.fromDotString("1.2")));

    path = Path.fromDotString("1");
    Assert.assertThat(path.getParent(), is(Path.fromDotString("")));

    path = Path.fromDotString("");
    Assert.assertThat(path.getParent(), nullValue());
  }
示例#4
0
  @Test
  public void testGetAncestor() throws Exception {

    Path path = Path.fromDotString("1.2.3");

    Assert.assertThat(path.getAncestor(3), is(Path.fromDotString("1.2.3")));
    Assert.assertThat(path.getAncestor(2), is(Path.fromDotString("1.2")));
    Assert.assertThat(path.getAncestor(1), is(Path.fromDotString("1")));
    Assert.assertThat(path.getAncestor(0), is(Path.fromDotString("")));
  }
示例#5
0
  @Test
  public void testIsComplex() throws Exception {
    Path path;

    path = Path.fromDotString("1.2.3");
    Assert.assertThat(path.isComplex(), is(true));

    path = Path.fromDotString("1");
    Assert.assertThat(path.isComplex(), is(false));

    path = Path.fromDotString("");
    Assert.assertThat(path.isComplex(), is(false));
  }
示例#6
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetAncestorIndexGreateThanSize() throws Exception {
   Path path = Path.fromDotString("1.2.3");
   path.getAncestor(5);
 }
示例#7
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetAncestorNegativeIndex() throws Exception {
   Path path = Path.fromDotString("1.2.3");
   path.getAncestor(-1);
 }
示例#8
0
 @Test
 public void testGetParentOnEmptyPath() throws Exception {
   Path path = Path.fromDotString("");
   Assert.assertThat(path.getParent(), nullValue());
 }
示例#9
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetFromStringNullString() throws Exception {
   Path.fromDotString(null);
 }
示例#10
0
  @Test
  public void testGetFromStringEmpty() throws Exception {
    Path path = Path.fromDotString("");

    Assert.assertThat(path.getSize(), is(0));
  }