@Test
public void testSwitchingOrderOfMainDoc() throws Exception {

    Metadata m1 = new Metadata();
    m1.add("k1", "v1");
    m1.add("k1", "v2");
    m1.add("k1", "v3");
    m1.add("k1", "v4");
    m1.add("k1", "v4");
    m1.add("k2", "v1");
    m1.add(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH, "/embedded-1");
    Metadata m2 = new Metadata();
    m2.add("k3", "v1");
    m2.add("k3", "v2");
    m2.add("k3", "v3");
    m2.add("k3", "v4");
    m2.add("k3", "v4");
    m2.add("k4", "v1");
    List<Metadata> truth = new ArrayList<>();
    truth.add(m2);
    truth.add(m1);
    StringWriter stringWriter = new StringWriter();
    try(JsonStreamingSerializer serializer = new JsonStreamingSerializer(stringWriter)) {
        serializer.add(m1);
        serializer.add(m2);
    }
    Reader reader = new StringReader(stringWriter.toString());
    List<Metadata> deserialized = JsonMetadataList.fromJson(reader);
    assertEquals(truth, deserialized);
}