Exemple #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"));
  }
Exemple #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"));
  }
Exemple #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());
  }
Exemple #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("")));
  }
Exemple #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));
  }
Exemple #6
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetAncestorIndexGreateThanSize() throws Exception {
   Path path = Path.fromDotString("1.2.3");
   path.getAncestor(5);
 }
Exemple #7
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetAncestorNegativeIndex() throws Exception {
   Path path = Path.fromDotString("1.2.3");
   path.getAncestor(-1);
 }
Exemple #8
0
 @Test
 public void testGetParentOnEmptyPath() throws Exception {
   Path path = Path.fromDotString("");
   Assert.assertThat(path.getParent(), nullValue());
 }
Exemple #9
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetFromStringNullString() throws Exception {
   Path.fromDotString(null);
 }
Exemple #10
0
  @Test
  public void testGetFromStringEmpty() throws Exception {
    Path path = Path.fromDotString("");

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