GeneralSchema extends AbstractSchema { @Override public IJsonNode recordToJson(final PactRecord record, final IJsonNode target) { final IJsonNode source = SopremoUtil.unwrap(record.getField(this.mappings.size(), JsonNodeWrapper.class)); if (target == null) return source; return this.reuseTargetNode(target, source); } 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 shouldReturnTheCorrectNode() { final PactRecord record = new PactRecord(3); record.setField(2, this.array); Assert.assertEquals(this.array, this.schema.recordToJson(record, null)); }
@Test public void shouldUseTargetNodeIfProvided() { final PactRecord record = new PactRecord(3); record.setField(2, this.array); final ArrayNode target = new ArrayNode(); final IJsonNode result = this.schema.recordToJson(record, target); Assert.assertSame(target, result); Assert.assertEquals(this.array, result); }