/**
   * Tests that the factory method works correctly with normal input.
   *
   * @throws Exception if bad happens.
   */
  @Test
  public void createFromFormFileBasic() throws Exception {

    final String fileName = "fileName";
    final String fileType = "fileType";
    final byte[] data =
        new byte[] {
          1,
        };

    FormFile formFile = createMockFormFileWithExpectations(fileName, fileType, data);
    AttachmentFile file = AttachmentFile.createFromFormFile(formFile);

    this.context.assertIsSatisfied();

    Assert.assertThat(file.getName(), is(fileName));
    Assert.assertThat(file.getType(), is(fileType));
    Assert.assertThat(file.getData(), is(data));
  }
  /**
   * Test that confirms proper handling of long file names.
   *
   * @throws Exception if bad happens.
   */
  @Test
  public void createFromFormFileLongName() throws Exception {
    final String fileName =
        "fileNamethrows Exceptionthrows Exceptionthrows Exceptionthrows Exceptionthrows Exceptionthrows Exceptionthrows Exceptionthrows Exceptionthrows Exceptionthrows Exception";
    final String fileType = "fileType";
    final byte[] data =
        new byte[] {
          1,
        };

    FormFile formFile = createMockFormFileWithExpectations(fileName, fileType, data);
    AttachmentFile file = AttachmentFile.createFromFormFile(formFile);

    this.context.assertIsSatisfied();

    Assert.assertThat(
        file.getName(),
        is(fileName.substring(fileName.length() - AttachmentFile.MAX_FILE_NAME_LENGTH)));
    Assert.assertThat(file.getType(), is(fileType));
    Assert.assertThat(file.getData(), is(data));
  }