// simulate Shiftr LHS specs
MatchablePathElement pe1 = (MatchablePathElement) ShiftrSpec.parseSingleKeyLHS( "tuna-*-marlin-*" );
MatchablePathElement pe2 = (MatchablePathElement) ShiftrSpec.parseSingleKeyLHS( "rating-*" );
// match them against some data to get LiteralPathElements with captured values
LiteralPathElement lpe = pe1.match( "tuna-2-marlin-3", new WalkedPath() );
AssertJUnit.assertEquals( "2" , lpe.getSubKeyRef( 1 ) );
AssertJUnit.assertEquals( "3" , lpe.getSubKeyRef( 2 ) );
LiteralPathElement lpe2 = pe2.match( "rating-BBB", new WalkedPath( null, lpe ) );
AssertJUnit.assertEquals( 2, lpe2.getSubKeyCount() );
AssertJUnit.assertEquals( "BBB" , lpe2.getSubKeyRef( 1 ) );
// Build an write path path
ShiftrWriter shiftrWriter = new ShiftrWriter( "tuna[&(1,1)].marlin[&(1,2)].&(0,1)" );
AssertJUnit.assertEquals( 5, shiftrWriter.size() );
AssertJUnit.assertEquals( "tuna.[&(1,1)].marlin.[&(1,2)].&(0,1)", shiftrWriter.getCanonicalForm() );
// Evaluate the write path against the LiteralPath elements we build above ( like Shiftr does )
WalkedPath twoSteps = new WalkedPath( null, lpe );
twoSteps.add( null, lpe2 );
List<String> stringPath = shiftrWriter.evaluate( twoSteps );
AssertJUnit.assertEquals( "tuna", stringPath.get( 0 ) );
AssertJUnit.assertEquals( "2", stringPath.get( 1 ) );
AssertJUnit.assertEquals( "marlin", stringPath.get( 2 ) );