ShiftrWriter path = new ShiftrWriter( "ugc.photos-&1-bob[&2]" );
AssertJUnit.assertEquals( 3, path.size() );
{ // 0
PathElement pe = path.get( 0 );
AssertJUnit.assertTrue( "First pathElement should be a literal one.", pe instanceof LiteralPathElement );
}
{ // 1
PathElement pe = path.get( 1 );
AssertJUnit.assertTrue( "Second pathElement should be a literal one.", pe instanceof AmpPathElement );
AmpPathElement refElement = (AmpPathElement) pe;
AssertJUnit.assertEquals( 3, refElement.getTokens().size() );
{
AssertJUnit.assertTrue( refElement.getTokens().get(0) instanceof String );
AssertJUnit.assertEquals( "photos-", (String) refElement.getTokens().get(0) );
}
{
AssertJUnit.assertTrue( refElement.getTokens().get(1) instanceof AmpReference );
AmpReference ref = (AmpReference) refElement.getTokens().get(1);
AssertJUnit.assertEquals( "&(1,0)", ref.getCanonicalForm() );
AssertJUnit.assertEquals( 1, ref.getPathIndex() );
AssertJUnit.assertEquals( 0, ref.getKeyGroup() );
}
{
AssertJUnit.assertTrue( refElement.getTokens().get(2) instanceof String );
AssertJUnit.assertEquals( "-bob", (String) refElement.getTokens().get(2) );
}
}
{ // 2
PathElement pe = path.get( 2 );
AssertJUnit.assertTrue( "Third pathElement should be a literal one.", pe instanceof ArrayPathElement );
ArrayPathElement arrayElement = (ArrayPathElement) pe;
AssertJUnit.assertEquals( "[&(2,0)]", arrayElement.getCanonicalForm() );
}