FixtureMap extends LinkedHashMap<String, FixtureTemplate> implements FixtureTemplate { public FixtureMap reproduce() { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(1024 * 2); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(this); oos.flush(); oos.close(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())); Object obj = ois.readObject(); FixtureMap dup = (FixtureMap) obj; dup.setParent(getParent()); dup.setRoot(isRoot()); dup.setFixtureName(getFixtureName()); return dup; } catch (Exception e) { throw new FixtureFormatException(getFixtureName(), e); } } FixtureMap(); FixtureMap reproduce(); FixtureMetadata getMetadata(); @Override boolean isRoot(); @Override void setRoot(boolean root); @Override String getFixtureName(); @Override void setFixtureName(String fixtureName); @Override FixtureTemplate getParent(); @Override void setParent(FixtureTemplate parent); @Override boolean hasParent();  }
@Test public void testReproduce() { FixtureMap origin = new FixtureMap(); FixtureMap subMap = new FixtureMap(); FixtureList list = new FixtureList(); FixtureMap mapInList = new FixtureMap(); FixtureValue integer = new FixtureValue(1); FixtureValue date = new FixtureValue(new Date()); list.add(mapInList); origin.put("subMap", subMap); origin.put("list", list); origin.put("integer", integer); origin.put("date", date); origin.setFixtureName("origin-fixture-name"); origin.setRoot(true); FixtureMap dup = origin.reproduce(); assertEquals(origin, dup); assertEquals(origin.get("subMap"), dup.get("subMap")); assertEquals(origin.get("list"), dup.get("list")); assertEquals(dup.get("integer"), integer); assertEquals(origin.get("date"), dup.get("date")); assertFalse(dup == origin); assertFalse(dup.get("subMap") == subMap); assertFalse(dup.get("list") == list); assertFalse(((FixtureList)dup.get("list")).get(0) == mapInList); assertFalse(dup.get("integer") == integer); assertFalse(dup.get("date") == date); }