### Question:
BasePersister extends AbstractCollectionSetVisitor implements Persister { public void persistStringAttribute(CollectionAttribute attribute) { log().debug("Persisting "+attribute); CollectionResource resource = attribute.getResource(); String value = attribute.getStringValue(); if (value == null) { log().info("No data collected for attribute "+attribute+". Skipping."); return; } String attrName = attribute.getName(); try { File resourceDir = resource.getResourceDir(getRepository()); ResourceTypeUtils.updateStringProperty(resourceDir, value, attrName); } catch(FileNotFoundException e) { log().error("Unable to save string attribute " + attribute + ": " + e, e); } catch(IOException e) { log().error("Unable to save string attribute " + attribute + ": " + e, e); } } BasePersister();  BasePersister(ServiceParameters params, RrdRepository repository); void completeAttribute(CollectionAttribute attribute); void completeGroup(AttributeGroup group); void completeResource(CollectionResource resource); RrdRepository getRepository(); void setRepository(RrdRepository repository); void persistNumericAttribute(CollectionAttribute attribute); void persistStringAttribute(CollectionAttribute attribute); void visitAttribute(CollectionAttribute attribute); void visitGroup(AttributeGroup group); void visitResource(CollectionResource resource); boolean isIgnorePersist(); void setIgnorePersist(boolean ignore); PersistOperationBuilder getBuilder();  }### Answer:
@Test public void testPersistStringAttributeWithExistingPropertiesFile() throws Exception { initPersister(); File nodeDir = m_fileAnticipator.tempDir(getSnmpRrdDirectory(), m_node.getId().toString()); m_fileAnticipator.tempFile(nodeDir, "strings.properties", "#just a test"); CollectionAttribute attribute = buildStringAttribute(); m_persister.persistStringAttribute(attribute); }
@Test public void testPersistStringAttributeWithParentDirectory() throws Exception { initPersister(); File nodeDir = m_fileAnticipator.tempDir(getSnmpRrdDirectory(), m_node.getId().toString()); m_fileAnticipator.expecting(nodeDir, "strings.properties"); CollectionAttribute attribute = buildStringAttribute(); m_persister.persistStringAttribute(attribute); }
@Test public void testPersistStringAttributeWithNoParentDirectory() throws Exception { initPersister(); File nodeDir = m_fileAnticipator.expecting(getSnmpRrdDirectory(), m_node.getId().toString()); m_fileAnticipator.expecting(nodeDir, "strings.properties"); CollectionAttribute attribute = buildStringAttribute(); m_persister.persistStringAttribute(attribute); }