Commit 7592ec7c authored by Abzal Kultayev's avatar Abzal Kultayev

[TASK #CMER] Запись УРЛ файла в реестр

parent 47582db0
package kz.arta.synergy.api.services;
import kz.arta.synergy.api.JsonUtils;
import kz.arta.synergy.api.Query;
import kz.arta.synergy.api.QueryContext;
import kz.arta.synergy.api.RestHttpQuery;
import java.io.IOException;
/**
* Created by: Abzal Kultayev
* Date: 12.11.16
* Time: 16:37
*/
public class StorageService {
private final RestHttpQuery restHttpQuery;
private StorageService(QueryContext context) {
this.restHttpQuery = new RestHttpQuery(context);
}
public static StorageService newInstance(QueryContext context) {
return new StorageService(context);
}
/**
* Создает временный файл на сервере
* @return Возвращает путь временного файла на сервере
* @throws IOException
*/
public String startUploadFile() throws IOException {
Query query = Query.newInstance().url("/rest/api/storage/start_upload");
String result = restHttpQuery.doQuery(query);
return JsonUtils.getValueByKey(result, "file");
}
}
package kz.arta.synergy.api.services;
import kz.arta.synergy.api.QueryContext;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
/**
* Created by: Abzal Kultayev
* Date: 12.11.16
* Time: 16:56
*/
public class StorageServiceTest {
StorageService service = StorageService.newInstance(new QueryContext("http://192.168.3.233:8080/Synergy", "NppAdmin", "123456"));
@Test
public void testStartUploadFile() throws Exception {
String tempFileName = service.startUploadFile();
assertNotNull(tempFileName);
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment