GeneralSchema extends AbstractSchema { @Override public PactRecord jsonToRecord(final IJsonNode value, PactRecord target, final EvaluationContext context) { if (target == null) target = new PactRecord(this.mappings.size() + 1); target.setField(this.mappings.size(), SopremoUtil.wrap(value)); for (int i = 0; i < this.mappings.size(); i++) target.setField(i, SopremoUtil.wrap(this.mappings.get(i).evaluate(value, null, context))); return target; } GeneralSchema(final EvaluationExpression... mappings);  GeneralSchema(final List<EvaluationExpression> mappings); List<EvaluationExpression> getMappings(); @Override IntSet indicesOf(final EvaluationExpression expression); @Override PactRecord jsonToRecord(final IJsonNode value, PactRecord target, final EvaluationContext context); @Override IJsonNode recordToJson(final PactRecord record, final IJsonNode target);  }
@Test public void shouldUseTargetRecordIfProvided() { final PactRecord target = new PactRecord(3); final PactRecord record = this.schema.jsonToRecord(this.array, target, this.context); Assert.assertSame(target, record); }
@Test public void shouldCreateACorrectRecord() { final PactRecord record = this.schema.jsonToRecord(this.array, null, this.context); Assert.assertEquals(IntNode.valueOf(7), record.getField(0, JsonNodeWrapper.class).getValue()); Assert.assertEquals(IntNode.valueOf(12), record.getField(1, JsonNodeWrapper.class).getValue()); Assert.assertEquals(this.array, record.getField(2, JsonNodeWrapper.class).getValue()); }