@Test
  public void openReadThrowsIfModeIsNotRaw() {
    // Arrange:
    final TEntityFileDescriptor descriptor = this.createDescriptor(TEST_FILE);

    // Act + Assert:
    ExceptionAssert.assertThrows(
        v -> descriptor.openRead(StorableEntityReadMode.Decode), IllegalArgumentException.class);
  }
  @Test
  public void openReadWithReadModeDelegatesToOpenRead() throws IOException {
    // Arrange:
    final TEntityFileDescriptor descriptor = Mockito.spy(this.createDescriptor(TEST_FILE));

    // Act + Assert:
    try (final InputStream is = descriptor.openRead(StorableEntityReadMode.Raw)) {
      Mockito.verify(descriptor, Mockito.times(1)).openRead();
    }
  }
  @Test
  public void openReadCanOpenFileThatExists() throws IOException {
    // Arrange:
    final TEntityFileDescriptor descriptor = this.createDescriptor(TEST_FILE);

    // Act:
    try (final InputStream is = descriptor.openRead()) {
      // Assert:
      Assert.assertThat(is, IsNull.notNullValue());
    }
  }
  @Test
  public void openReadCannotOpenFileThatDoesNotExist() {
    // Arrange:
    final File file = new File(TEST_FILE_DIRECTORY, "imaginary-read.bar");
    final TEntityFileDescriptor descriptor = this.createDescriptor(file);

    // Act:
    ExceptionAssert.assertThrowsStorageException(
        v -> descriptor.openRead(),
        this.getExceptionClass(),
        this.getExceptionValue(
            StorableEntityStorageException.Code.STORABLE_ENTITY_DOES_NOT_EXIST.value()));
  }
  @Test
  public void openReadCannotOpenFileThatIsInvalid() {
    // Arrange:
    final File file = Mockito.mock(File.class);
    Mockito.when(file.getName()).thenReturn("fo\0o.bar");
    Mockito.when(file.getAbsolutePath()).thenReturn("fo\0o.bar");
    Mockito.when(file.exists()).thenReturn(true);
    final TEntityFileDescriptor descriptor = this.createDescriptor(file);

    // Act:
    ExceptionAssert.assertThrowsStorageException(
        v -> descriptor.openRead(),
        this.getExceptionClass(),
        this.getExceptionValue(
            StorableEntityStorageException.Code.STORABLE_ENTITY_COULD_NOT_BE_READ.value()));
  }