@Test(expected = UpdateConflictException.class) public void throw_exception_when_create_attachment_in_conflict() { td.setId("some_id"); td.setRevision("123D123"); when(httpClient.put(anyString(), any(InputStream.class), anyString(), anyInt())) .thenReturn(ResponseOnFileStub.newInstance(409, "update_conflict.json")); dbCon.createAttachment( "id", "rev", new AttachmentInputStream("attach_id", IOUtils.toInputStream("data"), "whatever")); }
@Test public void should_stream_attachmed_content() { when(httpClient.put(anyString(), any(InputStream.class), anyString(), anyInt())) .thenReturn(ResponseOnFileStub.newInstance(200, "create_attachment_rsp.json")); dbCon.createAttachment( "docid", new AttachmentInputStream( "attachment_id", IOUtils.toInputStream("content"), "text/html", 12l)); verify(httpClient) .put(eq("/test_db/docid/attachment_id"), any(InputStream.class), eq("text/html"), eq(12l)); }