### Question:
MultiFieldPanelFunctions { public static List<Map<String, String>> getMultiFieldPanelValues(Resource resource, String name) { Gson gson = new Gson(); ValueMap map = resource.adaptTo(ValueMap.class); List<Map<String, String>> results = new ArrayList<>(); if (map != null && map.containsKey(name)) { String[] values = map.get(name, new String[0]); for (String value : values) { try { results.add(gson.fromJson(value, Map.class)); } catch (JsonParseException e) { log.error( String.format("Unable to parse JSON in %s property of %s", name, resource.getPath()), e); } } } return results; } private  MultiFieldPanelFunctions(); static List<Map<String, String>> getMultiFieldPanelValues(Resource resource, String name);  }### Answer:
@Test public void testSingleObject() { List<Map<String, String>> actual = MultiFieldPanelFunctions.getMultiFieldPanelValues(resource, "single"); assertEquals(1, actual.size()); assertEquals(true, actual.get(0).containsKey("a")); assertEquals("b", actual.get(0).get("a")); }
@Test public void testMultipleObject() { List<Map<String, String>> actual = MultiFieldPanelFunctions.getMultiFieldPanelValues(resource, "multiple"); assertEquals(2, actual.size()); assertEquals(true, actual.get(0).containsKey("a")); assertEquals("b", actual.get(0).get("a")); assertEquals(true, actual.get(1).containsKey("c")); assertEquals("d", actual.get(1).get("c")); }
@Test public void testKeyWhichDoesntExist() { List<Map<String, String>> actual = MultiFieldPanelFunctions.getMultiFieldPanelValues(resource, "non-existing"); assertEquals(0, actual.size()); }
@Test public void testResourceAdaptToValueMapNull() { when(resource.adaptTo(ValueMap.class)).thenReturn(null); List<Map<String, String>> actual = MultiFieldPanelFunctions.getMultiFieldPanelValues(resource, "single"); assertEquals(0, actual.size()); }