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

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