use of com.opentext.ia.sdk.support.http.UriBuilder in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenUsingInfoArchive method shouldFetchOrderContentSuccessfully.
@Test
@SuppressWarnings("rawtypes")
public void shouldFetchOrderContentSuccessfully() throws IOException {
UriBuilder uriBuilder = mock(UriBuilder.class);
String uri = randomString();
when(uriBuilder.build()).thenReturn(uri);
when(uriBuilder.addParameter(anyString(), anyString())).thenReturn(uriBuilder);
when(restClient.uri(anyString())).thenReturn(uriBuilder);
ResponseFactory contentResultFactory = mock(ContentResultFactory.class);
DefaultContentResult contentResult = mock(DefaultContentResult.class);
when(contentResultFactory.create(any(Response.class), any(Runnable.class))).thenReturn(contentResult);
when(restClient.get(eq(uri), any(ContentResultFactory.class))).thenReturn(contentResult);
OrderItem orderItem = new OrderItem();
orderItem.setType("EXPORT");
Link downloadLink = new Link();
downloadLink.setHref(randomString());
orderItem.getLinks().put(LINK_DOWNLOAD, downloadLink);
configureServer();
ContentResult result = archiveClient.fetchOrderContent(orderItem);
assertEquals(contentResult, result);
}
use of com.opentext.ia.sdk.support.http.UriBuilder in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenUsingInfoArchive method shouldExportSuccessfully.
@Test
void shouldExportSuccessfully() throws IOException {
UriBuilder uriBuilder = mock(UriBuilder.class);
String uri = randomString();
when(uriBuilder.build()).thenReturn(uri);
when(uriBuilder.addParameter(anyString(), anyString())).thenReturn(uriBuilder);
when(restClient.uri(any())).thenReturn(uriBuilder);
OrderItem orderItem = mock(OrderItem.class);
when(restClient.post(eq(uri), eq(OrderItem.class), anyString())).thenReturn(orderItem);
SearchResults searchResults = new SearchResults();
SearchResult searchResult = new SearchResult();
List<Row> rows = new ArrayList<>();
Row row = new Row();
row.setId(randomString());
rows.add(row);
searchResult.setRows(rows);
searchResults.addResult(searchResult);
ExportConfiguration exportConfiguration = mock(ExportConfiguration.class);
when(exportConfiguration.getSelfUri()).thenReturn(uri);
configureServer();
OrderItem result = archiveClient.export(searchResults, exportConfiguration, randomString());
assertEquals(orderItem, result);
}
use of com.opentext.ia.sdk.support.http.UriBuilder in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class RestClient method replacePageQueryParameters.
private String replacePageQueryParameters(String href, int page, int size) {
try {
URIBuilder uriBuilder = new URIBuilder(href);
List<NameValuePair> queryParameters = uriBuilder.getQueryParams().stream().filter(p -> !"page".equals(p.getName()) && !"size".equals(p.getName())).collect(Collectors.toList());
uriBuilder.setParameters(queryParameters);
uriBuilder.addParameter("page", String.valueOf(page));
uriBuilder.addParameter("size", String.valueOf(size));
return uriBuilder.build().toString();
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
}
use of com.opentext.ia.sdk.support.http.UriBuilder in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenMakingRestCalls method shouldForwardUri.
@Test
void shouldForwardUri() {
UriBuilder expected = mock(UriBuilder.class);
when(httpClient.uri(anyString())).thenReturn(expected);
UriBuilder actual = restClient.uri(randomString());
assertSame(expected, actual, "URI Builder");
}
Aggregations