### Question:
KmlFeatureParser { static KmlPlacemark createPlacemark(XmlPullParser parser) throws IOException, XmlPullParserException { String styleId = null; KmlStyle inlineStyle = null; HashMap<String, String> properties = new HashMap<String, String>(); Geometry geometry = null; int eventType = parser.getEventType(); while (!(eventType == END_TAG && parser.getName().equals("Placemark"))) { if (eventType == START_TAG) { if (parser.getName().equals(STYLE_URL_TAG)) { styleId = parser.nextText(); } else if (parser.getName().matches(GEOMETRY_REGEX)) { geometry = createGeometry(parser, parser.getName()); } else if (parser.getName().matches(PROPERTY_REGEX)) { properties.put(parser.getName(), parser.nextText()); } else if (parser.getName().equals(EXTENDED_DATA)) { properties.putAll(setExtendedDataProperties(parser)); } else if (parser.getName().equals(STYLE_TAG)) { inlineStyle = KmlStyleParser.createStyle(parser); } } eventType = parser.next(); } return new KmlPlacemark(geometry, styleId, inlineStyle, properties); }    }### Answer:
@Test public void testPolygon() throws Exception { XmlPullParser xmlPullParser = createParser("amu_basic_placemark.kml"); KmlPlacemark placemark = KmlFeatureParser.createPlacemark(xmlPullParser); assertNotNull(placemark); assertEquals(placemark.getGeometry().getGeometryType(), "Polygon"); KmlPolygon polygon = ((KmlPolygon) placemark.getGeometry()); assertEquals(polygon.getInnerBoundaryCoordinates().size(), 2); assertEquals(polygon.getOuterBoundaryCoordinates().size(), 5); }
@Test public void testMultiGeometry() throws Exception { XmlPullParser xmlPullParser = createParser("amu_multigeometry_placemarks.kml"); KmlPlacemark placemark = KmlFeatureParser.createPlacemark(xmlPullParser); assertNotNull(placemark); assertEquals(placemark.getGeometry().getGeometryType(), "MultiGeometry"); KmlMultiGeometry multiGeometry = ((KmlMultiGeometry) placemark.getGeometry()); assertEquals(multiGeometry.getGeometryObject().size(), 3); }
@Test public void testProperties() throws Exception { XmlPullParser xmlPullParser = createParser("amu_multigeometry_placemarks.kml"); KmlPlacemark placemark = KmlFeatureParser.createPlacemark(xmlPullParser); assertTrue(placemark.hasProperties()); assertEquals(placemark.getProperty("name"), "Placemark Test"); assertNull(placemark.getProperty("description")); }
@Test public void testExtendedData() throws Exception { XmlPullParser xmlPullParser = createParser("amu_multiple_placemarks.kml"); KmlPlacemark placemark = KmlFeatureParser.createPlacemark(xmlPullParser); assertNotNull(placemark.getProperty("holeNumber")); }
@Test public void testMultiGeometries() throws Exception { XmlPullParser xmlPullParser = createParser("amu_nested_multigeometry.kml"); KmlPlacemark feature = KmlFeatureParser.createPlacemark(xmlPullParser); assertEquals(feature.getProperty("name"), "multiPointLine"); assertEquals(feature.getProperty("description"), "Nested MultiGeometry structure"); assertEquals(feature.getGeometry().getGeometryType(), "MultiGeometry"); List<Geometry> objects = (ArrayList<Geometry>) feature.getGeometry().getGeometryObject(); assertEquals(objects.get(0).getGeometryType(), "Point"); assertEquals(objects.get(1).getGeometryType(), "LineString"); assertEquals(objects.get(2).getGeometryType(), "MultiGeometry"); List<Geometry> subObjects = (ArrayList<Geometry>) objects.get(2).getGeometryObject(); assertEquals(subObjects.get(0).getGeometryType(), "Point"); assertEquals(subObjects.get(1).getGeometryType(), "LineString"); }