### Question:
JsonUtils { public static List<String> getMatchingListFromJsonArrayNode(JsonNode rootNode, String fieldName) { List<String> retList = new ArrayList<>(); Iterator<JsonNode> ite = rootNode.elements(); if (ite == null || !ite.hasNext()) { return retList; } ite.forEachRemaining(field -> { JsonNode stringNode = field.get(fieldName); if (stringNode != null && !stringNode.textValue().isEmpty()) { retList.add(stringNode.textValue()); } }); return retList; }  static JsonNode getNodeFromJsonFile(String filePath, String fieldName); static List<String> getMatchingListFromJsonArrayNode(JsonNode rootNode, String fieldName);  }### Answer:
@Test void testGetLogGroup() throws IOException { JsonNode node = mapper.readTree(SINGLE_LOG_CONFIG); List<String> groupList = JsonUtils.getMatchingListFromJsonArrayNode(node, LOG_GROUP_NAME); Assertions.assertEquals(1, groupList.size()); Assertions.assertEquals("test_group", groupList.get(0)); }
@Test void testGetMultipleLogGroups() throws IOException { JsonNode node = mapper.readTree(MULTI_LOG_CONFIG); List<String> groupList = JsonUtils.getMatchingListFromJsonArrayNode(node, LOG_GROUP_NAME); Assertions.assertEquals(3, groupList.size()); Assertions.assertTrue(groupList.contains("test_group1")); Assertions.assertTrue(groupList.contains("test_group2")); }
@Test void testGetLogGroupWithStreamPresent() throws IOException { JsonNode node = mapper.readTree(SINGLE_LOG_CONFIG_WITH_STREAM); List<String> groupList = JsonUtils.getMatchingListFromJsonArrayNode(node, LOG_GROUP_NAME); Assertions.assertEquals(1, groupList.size()); Assertions.assertEquals("test_group", groupList.get(0)); }