@Test public void testModifierFirstElementArray() throws IOException { Map<String, Object> input = new HashMap<String, Object>() {{ put("input", new Integer[]{5, 4}); }}; Map<String, Object> spec = new HashMap<String, Object>() {{ put("first", "=firstElement(@(1,input))"); }}; Map<String, Object> expected = new HashMap<String, Object>() {{ put("input", new Integer[]{5, 4}); put("first", 5); }}; Modifier modifier = new Modifier.Overwritr( spec ); Object actual = modifier.transform( input, null ); JoltTestUtil.runArrayOrderObliviousDiffy( "failed modifierFirstElementArray", expected, actual ); }
@Override public Object transform( final Object input, final Map<String, Object> context ) { Map<String, Object> contextWrapper = new HashMap<>( ); contextWrapper.put( ROOT_KEY, context ); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input), walkedPath, null, contextWrapper ); return input; }
Modifier implements SpecDriven, ContextualTransform { @Override public Object transform( final Object input, final Map<String, Object> context ) { Map<String, Object> contextWrapper = new HashMap<>( ); contextWrapper.put( ROOT_KEY, context ); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input), walkedPath, null, contextWrapper ); return input; } }
Modifier implements SpecDriven, ContextualTransform { @Override public Object transform( final Object input, final Map<String, Object> context ) { Map<String, Object> contextWrapper = new HashMap<>( ); contextWrapper.put( ROOT_KEY, context ); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input), walkedPath, null, contextWrapper ); return input; } @SuppressWarnings( "unchecked" ) private  Modifier( Object spec, OpMode opMode, Map<String, Function> functionsMap ); }
Modifier implements SpecDriven, ContextualTransform { @Override public Object transform( final Object input, final Map<String, Object> context ) { Map<String, Object> contextWrapper = new HashMap<>( ); contextWrapper.put( ROOT_KEY, context ); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input), walkedPath, null, contextWrapper ); return input; } @SuppressWarnings( "unchecked" ) private  Modifier( Object spec, OpMode opMode, Map<String, Function> functionsMap ); @Override Object transform( final Object input, final Map<String, Object> context ); }
Modifier implements SpecDriven, ContextualTransform { @Override public Object transform( final Object input, final Map<String, Object> context ) { Map<String, Object> contextWrapper = new HashMap<>( ); contextWrapper.put( ROOT_KEY, context ); MatchedElement rootLpe = new MatchedElement( ROOT_KEY ); WalkedPath walkedPath = new WalkedPath(); walkedPath.add( input, rootLpe ); rootSpec.apply( ROOT_KEY, Optional.of( input), walkedPath, null, contextWrapper ); return input; } @SuppressWarnings( "unchecked" ) private  Modifier( Object spec, OpMode opMode, Map<String, Function> functionsMap ); @Override Object transform( final Object input, final Map<String, Object> context );  }