public static void trimRecordTemplate(RecordTemplate recordTemplate, MaskTree override, final boolean failOnMismatch)
  {
    trimRecordTemplate(recordTemplate.data(), recordTemplate.schema(), override, failOnMismatch);
  }
@Test
  public void testArrayTrim() throws CloneNotSupportedException
  {
    TyperefTest test = new TyperefTest();
    RecordBarArray array = new RecordBarArray();

    RecordBar recordBar = new RecordBar();
    recordBar.setLocation("mountain view");
    array.add(recordBar);

    RecordBar recordBar2 = new RecordBar();
    recordBar2.setLocation("palo alto");
    array.add(recordBar2);

    test.setRecordArray(array);

    // Generate expected copy.
    TyperefTest expected = test.copy();

    // Introduce bad elements.
    test.getRecordArray().get(0).data().put("troublemaker", "foo");
    test.getRecordArray().get(0).data().put("troublemaker2", "foo");
    test.getRecordArray().get(1).data().put("troublemaker", "foo");
    test.getRecordArray().get(1).data().put("troublemaker2", "foo");

    Assert.assertEquals(test.getRecordArray().get(0).data().size(), 3);
    Assert.assertEquals(test.getRecordArray().get(1).data().size(), 3);
    RestUtils.trimRecordTemplate(test, false);
    Assert.assertEquals(test, expected);
  }