Merge branch '19954-permission-dedup-doc'
[arvados.git] / sdk / java-v2 / src / test / java / org / arvados / client / api / client / KeepWebApiClientTest.java
1 /*
2  * Copyright (C) The Arvados Authors. All rights reserved.
3  *
4  * SPDX-License-Identifier: AGPL-3.0 OR Apache-2.0
5  *
6  */
7
8 package org.arvados.client.api.client;
9
10 import org.arvados.client.test.utils.ArvadosClientMockedWebServerTest;
11 import org.junit.Test;
12
13 import java.io.File;
14 import java.nio.file.Files;
15
16 import static org.arvados.client.test.utils.ApiClientTestUtils.getResponse;
17 import static org.assertj.core.api.Assertions.assertThat;
18
19 public class KeepWebApiClientTest extends ArvadosClientMockedWebServerTest {
20
21     private KeepWebApiClient client = new KeepWebApiClient(CONFIG);
22
23     @Test
24     public void uploadFile() throws Exception {
25         // given
26         String collectionUuid = "112ci-4zz18-p51w7z3fpopo6sm";
27         File file = Files.createTempFile("keep-upload-test", "txt").toFile();
28         Files.write(file.toPath(), "test data".getBytes());
29
30         server.enqueue(getResponse("keep-client-upload-response"));
31
32         // when
33         String uploadResponse = client.upload(collectionUuid, file, uploadedBytes -> System.out.printf("Uploaded bytes: %s/%s%n", uploadedBytes, file.length()));
34
35         // then
36         assertThat(uploadResponse).isEqualTo("Created");
37     }
38
39 }