@Test(dataProvider = "getTestCaseUnits") public void runTestUnits(String testCaseName) throws IOException { String testPath = "/json/shiftr/" + testCaseName; Map<String, Object> testUnit = JsonUtils.classpathToMap( testPath + ".json" ); Object input = testUnit.get( "input" ); Object spec = testUnit.get( "spec" ); Object expected = testUnit.get( "expected" ); Shiftr shiftr = new Shiftr( spec ); Object actual = shiftr.transform( input ); JoltTestUtil.runDiffy( "failed case " + testPath, expected, actual ); }
@Override public Object transform( Object input ) { Map<String,Object> output = new HashMap<>(); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input ), walkedPath, output, null ); return output.get( ROOT_KEY ); }
Shiftr implements SpecDriven, Transform { @Override public Object transform( Object input ) { Map<String,Object> output = new HashMap<>(); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input ), walkedPath, output, null ); return output.get( ROOT_KEY ); } }
Shiftr implements SpecDriven, Transform { @Override public Object transform( Object input ) { Map<String,Object> output = new HashMap<>(); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input ), walkedPath, output, null ); return output.get( ROOT_KEY ); } @Inject  Shiftr( Object spec ); }
Shiftr implements SpecDriven, Transform { @Override public Object transform( Object input ) { Map<String,Object> output = new HashMap<>(); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input ), walkedPath, output, null ); return output.get( ROOT_KEY ); } @Inject  Shiftr( Object spec ); @Override Object transform( Object input ); }
Shiftr implements SpecDriven, Transform { @Override public Object transform( Object input ) { Map<String,Object> output = new HashMap<>(); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input ), walkedPath, output, null ); return output.get( ROOT_KEY ); } @Inject  Shiftr( Object spec ); @Override Object transform( Object input );  }