@Test
  public void delete_withExistingFile_shouldDeleteFile() {
    // Given
    // we create some content
    FlatsyDatabase db = new FlatsyFlatFileDatabase(root);
    String content = "This is original content";
    String uri = "births/original.json";

    db.create(new FlatsyObject(uri, db), content);
    assertEquals(FlatsyObjectType.JSONFile, db.type(uri));

    // When
    // we delete the
    db.delete(new FlatsyObject(uri, db));

    // Then
    // when there is no file for our key
    assertEquals(FlatsyObjectType.Null, db.type(uri));
  }
  @Test
  public void create_newContentForNonExistingFolder_shouldCreateStructure() throws IOException {
    // Given
    // we create some content
    FlatsyDatabase db = new FlatsyFlatFileDatabase(root);
    String newContent = "This is new content";
    String newURI = "births/flatsyTest/foo.json";
    String newFolderURI = "births/flatsyTest";

    // When
    // we create the file
    FlatsyObject object = new FlatsyObject(newURI, db);
    db.create(object, newContent);

    // Then
    // files and folders exist and when we retrieve the file it has the content
    assertEquals(FlatsyObjectType.JSONFile, db.type(newURI));
    assertEquals(FlatsyObjectType.Folder, db.type(newFolderURI));
    assertEquals(newContent, db.retrieve(new FlatsyObject(newURI, db)));
  }
  @Test
  public void type_forExistingNonJsonURI_shouldGiveOtherFile() {
    // Given
    // setup with json file
    FlatsyDatabase db = new FlatsyFlatFileDatabase(root);
    String otherFile = "births/adoption/bulletins/englandandwales/2013-08-20/283368d3.html";

    // When
    // we get the type
    FlatsyObjectType type = db.type(otherFile);

    // Then
    // shouldGiveJSONFile
    assertEquals(FlatsyObjectType.OtherFile, type);
  }
  @Test
  public void type_forExistingJsonURI_shouldGiveJSONFile() {
    // Given
    // setup with json file
    FlatsyDatabase db = new FlatsyFlatFileDatabase(root);
    String jsonFile = "births/data.json";

    // When
    // we get the type
    FlatsyObjectType type = db.type(jsonFile);

    // Then
    // shouldGiveJSONFile
    assertEquals(FlatsyObjectType.JSONFile, type);
  }
  @Test
  public void type_forMissingFile_shouldGiveObjectTypeNull() {
    // Given
    // setup with rubbish filename
    FlatsyDatabase db = new FlatsyFlatFileDatabase(root);
    String uri = "births/foo.xml";

    // When
    // we get the type
    FlatsyObjectType type = db.type(uri);

    // Then
    // should give null
    assertEquals(FlatsyObjectType.Null, type);
  }
  @Test
  public void type_forFolder_shouldGiveFolder() {
    // Given
    // setup with json file
    FlatsyDatabase db = new FlatsyFlatFileDatabase(root);
    String folder = "births";

    // When
    // we get the type
    FlatsyObjectType type = db.type(folder);

    // Then
    // should give folder
    assertEquals(FlatsyObjectType.Folder, type);
  }