예제 #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));
  }