@Test(expected = FileOperationException.class)
  public void shouldThrowExceptionIfAlfrescoReturnedUnexpectedResponseCode() {

    stubFor(
        post(urlEqualTo(WEB_CONTEXT + UPLOAD_PATH))
            .willReturn(
                aResponse()
                    .withStatus(500)
                    .withBody(alfrescoResponseOf("file1234", "text/plain"))));

    fileSender.send("abc.txt", toInputStream("aa"));
  }
  @Test
  public void shouldReturnUploadedFileData() {
    final String fileId = "file1234";
    final String fileMimeType = "text/plain";

    stubFor(
        post(urlEqualTo(WEB_CONTEXT + UPLOAD_PATH))
            .willReturn(
                aResponse().withStatus(200).withBody(alfrescoResponseOf(fileId, fileMimeType))));

    final FileData fileData = fileSender.send("abc.txt", toInputStream("aa"));

    assertThat(fileData.fileId(), is(fileId));
  }
  @Test
  public void shouldSendFileToAlfresco() throws Exception {
    stubFor(
        post(urlEqualTo(WEB_CONTEXT + UPLOAD_PATH))
            .willReturn(
                aResponse().withStatus(200).withBody(alfrescoResponseOf("not_used", "not_used"))));

    fileSender.send("file.txt", toInputStream("abcd1243"));

    verify(
        postRequestedFor(urlEqualTo(WEB_CONTEXT + UPLOAD_PATH))
            .withHeader(CONTENT_TYPE, containing("multipart/form-data; boundary="))
            .withHeader("cppuid", equalTo(USER_ID))
            .withRequestBody(
                containing(
                    "Content-Disposition: form-data; name=\"filedata\"; filename=\"file.txt\"\r\nContent-Type: text/plain\r\n\r\nabcd1243\r\n")));
  }
  @Test(expected = FileOperationException.class)
  public void shouldThrowExceptionIfAlfrescoResponseContainsEmptyBody() {
    stubFor(post(urlEqualTo(WEB_CONTEXT + UPLOAD_PATH)).willReturn(aResponse().withStatus(200)));

    fileSender.send("abc.txt", toInputStream("aa"));
  }