### Question:
PropertyInfo { public Map<String, String> getAttributesMap() { Map<String, String> attributes = new HashMap<>(); for (Element propertyAttribute : propertyAttributes) { attributes.put(propertyAttribute.getTagName(), propertyAttribute.getFirstChild().getNodeValue()); } return attributes; } PropertyInfo(); String getName(); void setName(String name); Set<PropertyDependencyInfo> getUsedByProperties(); String getValue(); void setValue(String value); String getDescription(); void setDescription(String description); String getDisplayName(); void setDisplayName(String displayName); String getFilename(); void setFilename(String filename); Set<PropertyType> getPropertyTypes(); void setPropertyTypes(Set<PropertyType> propertyTypes); PropertyUpgradeBehavior getPropertyAmbariUpgradeBehavior(); void setPropertyAmbariUpgradeBehavior(PropertyUpgradeBehavior propertyAmbariUpgradeBehavior); StackConfigurationResponse convertToResponse(); boolean isDeleted(); void setDeleted(boolean deleted); Map<String, String> getAttributesMap(); ValueAttributesInfo getPropertyValueAttributes(); Set<PropertyDependencyInfo> getDependsOnProperties(); void setPropertyValueAttributes(ValueAttributesInfo propertyValueAttributes); Set<PropertyDependencyInfo> getDependedByProperties(); boolean isRequireInput(); void setRequireInput(boolean requireInput); List<Element> getPropertyAttributes(); void setPropertyAttributes(List<Element> propertyAttributes); Set<RefreshCommand> getSupportedRefreshCommands(); void setSupportedRefreshCommands(Set<RefreshCommand> supportedRefreshCommands); boolean shouldBeConfigured(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); PropertyStackUpgradeBehavior getPropertyStackUpgradeBehavior(); void setPropertyStackUpgradeBehavior(PropertyStackUpgradeBehavior propertyStackUpgradeBehavior);  }### Answer:
@Test public void testAttributes() throws Exception { PropertyInfo property = new PropertyInfo(); List<Element> elements = new ArrayList<>(); Element e1 = createNiceMock(Element.class); Element e2 = createNiceMock(Element.class); Node n1 = createNiceMock(Node.class); Node n2 = createNiceMock(Node.class); elements.add(e1); elements.add(e2); expect(e1.getTagName()).andReturn("foo").anyTimes(); expect(e1.getFirstChild()).andReturn(n1).anyTimes(); expect(n1.getNodeValue()).andReturn("value1").anyTimes(); expect(e2.getTagName()).andReturn("bar").anyTimes(); expect(e2.getFirstChild()).andReturn(n2).anyTimes(); expect(n2.getNodeValue()).andReturn("value2").anyTimes(); replay(e1, e2, n1, n2); Field f = property.getClass().getDeclaredField("propertyAttributes"); f.setAccessible(true); f.set(property, elements); Map<String, String> attributes = property.getAttributesMap(); assertEquals(2, attributes.size()); assertEquals("value1", attributes.get("foo")); assertEquals("value2", attributes.get("bar")); }