@Test public void testConvertArray() { FixtureMap parent = new FixtureMap(); List<Object> list = new ArrayList<>(); String value1 = "string"; Date value2 = new Date(); list.add(value1); list.add(value2); FixtureList fixtureList = FixtureTemplateWrapper.wrap(list, "test", parent); assertEquals("test", fixtureList.getFixtureName()); assertEquals(parent, fixtureList.getParent()); assertTrue(fixtureList.get(0) instanceof FixtureValue); assertTrue(fixtureList.get(1) instanceof FixtureValue); FixtureValue fixtureValue1 = (FixtureValue) fixtureList.get(0); FixtureValue fixtureValue2 = (FixtureValue) fixtureList.get(1); assertEquals(value1, fixtureValue1.getValue()); assertEquals(value2, fixtureValue2.getValue()); assertEquals("test", fixtureValue1.getFixtureName()); assertEquals("test", fixtureValue2.getFixtureName()); }
@SuppressWarnings("unchecked") public static FixtureMap wrap(Map<String, ? extends Object> source, String fixtureName, FixtureTemplate parent) { FixtureMap fixtureMap = new FixtureMap(); fixtureMap.setFixtureName(fixtureName); fixtureMap.setParent(parent); for (Map.Entry<String, ? extends Object> entry : source.entrySet()) { String key = entry.getKey(); if (entry.getValue() instanceof Map) { fixtureMap.put(entry.getKey(), wrap((Map) entry.getValue(), key, fixtureMap)); } else if (entry.getValue() instanceof List) { fixtureMap.put(entry.getKey(), wrap((List) entry.getValue(), key, fixtureMap)); } else { FixtureValue wrapped = wrap(entry.getValue(), entry.getKey(), fixtureMap); fixtureMap.put(entry.getKey(), wrapped); } } return fixtureMap; }
FixtureTemplateWrapper { @SuppressWarnings("unchecked") public static FixtureMap wrap(Map<String, ? extends Object> source, String fixtureName, FixtureTemplate parent) { FixtureMap fixtureMap = new FixtureMap(); fixtureMap.setFixtureName(fixtureName); fixtureMap.setParent(parent); for (Map.Entry<String, ? extends Object> entry : source.entrySet()) { String key = entry.getKey(); if (entry.getValue() instanceof Map) { fixtureMap.put(entry.getKey(), wrap((Map) entry.getValue(), key, fixtureMap)); } else if (entry.getValue() instanceof List) { fixtureMap.put(entry.getKey(), wrap((List) entry.getValue(), key, fixtureMap)); } else { FixtureValue wrapped = wrap(entry.getValue(), entry.getKey(), fixtureMap); fixtureMap.put(entry.getKey(), wrapped); } } return fixtureMap; } }
FixtureTemplateWrapper { @SuppressWarnings("unchecked") public static FixtureMap wrap(Map<String, ? extends Object> source, String fixtureName, FixtureTemplate parent) { FixtureMap fixtureMap = new FixtureMap(); fixtureMap.setFixtureName(fixtureName); fixtureMap.setParent(parent); for (Map.Entry<String, ? extends Object> entry : source.entrySet()) { String key = entry.getKey(); if (entry.getValue() instanceof Map) { fixtureMap.put(entry.getKey(), wrap((Map) entry.getValue(), key, fixtureMap)); } else if (entry.getValue() instanceof List) { fixtureMap.put(entry.getKey(), wrap((List) entry.getValue(), key, fixtureMap)); } else { FixtureValue wrapped = wrap(entry.getValue(), entry.getKey(), fixtureMap); fixtureMap.put(entry.getKey(), wrapped); } } return fixtureMap; }  }
FixtureTemplateWrapper { @SuppressWarnings("unchecked") public static FixtureMap wrap(Map<String, ? extends Object> source, String fixtureName, FixtureTemplate parent) { FixtureMap fixtureMap = new FixtureMap(); fixtureMap.setFixtureName(fixtureName); fixtureMap.setParent(parent); for (Map.Entry<String, ? extends Object> entry : source.entrySet()) { String key = entry.getKey(); if (entry.getValue() instanceof Map) { fixtureMap.put(entry.getKey(), wrap((Map) entry.getValue(), key, fixtureMap)); } else if (entry.getValue() instanceof List) { fixtureMap.put(entry.getKey(), wrap((List) entry.getValue(), key, fixtureMap)); } else { FixtureValue wrapped = wrap(entry.getValue(), entry.getKey(), fixtureMap); fixtureMap.put(entry.getKey(), wrapped); } } return fixtureMap; }  @SuppressWarnings("unchecked") static FixtureMap wrap(Map<String, ? extends Object> source, String fixtureName, FixtureTemplate parent); @SuppressWarnings("unchecked") static FixtureList wrap(List<? extends Object> source, String fixtureName, FixtureTemplate parent); static FixtureValue wrap(Object source, String fixtureName, FixtureTemplate parent); }
FixtureTemplateWrapper { @SuppressWarnings("unchecked") public static FixtureMap wrap(Map<String, ? extends Object> source, String fixtureName, FixtureTemplate parent) { FixtureMap fixtureMap = new FixtureMap(); fixtureMap.setFixtureName(fixtureName); fixtureMap.setParent(parent); for (Map.Entry<String, ? extends Object> entry : source.entrySet()) { String key = entry.getKey(); if (entry.getValue() instanceof Map) { fixtureMap.put(entry.getKey(), wrap((Map) entry.getValue(), key, fixtureMap)); } else if (entry.getValue() instanceof List) { fixtureMap.put(entry.getKey(), wrap((List) entry.getValue(), key, fixtureMap)); } else { FixtureValue wrapped = wrap(entry.getValue(), entry.getKey(), fixtureMap); fixtureMap.put(entry.getKey(), wrapped); } } return fixtureMap; }  @SuppressWarnings("unchecked") static FixtureMap wrap(Map<String, ? extends Object> source, String fixtureName, FixtureTemplate parent); @SuppressWarnings("unchecked") static FixtureList wrap(List<? extends Object> source, String fixtureName, FixtureTemplate parent); static FixtureValue wrap(Object source, String fixtureName, FixtureTemplate parent);  }