use of com.opentext.ia.sdk.client.api.QueryResult in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenUsingInfoArchive method shouldQuerySuccessfully.
@Test
public void shouldQuerySuccessfully() throws IOException {
when(aics.getItems()).thenReturn(Stream.of(aic));
Link dipLink = new Link();
dipLink.setHref(randomString());
aic.getLinks().put(LINK_DIP, dipLink);
aic.setName("MyAic");
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);
QueryResultFactory queryResultFactory = mock(QueryResultFactory.class);
DefaultQueryResult queryResult = mock(DefaultQueryResult.class);
when(queryResultFactory.create(any(Response.class), any(Runnable.class))).thenReturn(queryResult);
when(restClient.get(eq(uri), any(QueryResultFactory.class))).thenReturn(queryResult);
SearchQuery query = new SearchQuery();
query.getItems().add(new Comparison("variable", Operator.EQUAL, "value"));
String aicName = "MyAic";
String schema = NAMESPACE;
configureServer();
QueryResult result = archiveClient.query(query, aicName, schema, 10);
assertEquals(queryResult, result);
}
use of com.opentext.ia.sdk.client.api.QueryResult in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenWorkingWithQueryResult method shouldHaveDescriptiveToString.
@Test
void shouldHaveDescriptiveToString() throws IOException {
try (QueryResult result = newQueryResult()) {
String string = result.toString();
assertTrue(string.contains(result.getClass().getSimpleName()));
assertTrue(string.contains(String.valueOf(aipQouta)));
assertTrue(string.contains(String.valueOf(aiuQuota)));
assertTrue(string.contains(String.valueOf(resultSetQuota)));
assertTrue(string.contains(String.valueOf(resultSetCount)));
assertTrue(string.contains(String.valueOf(cacheOutIgnored)));
assertTrue(string.contains(String.valueOf(stream)));
}
}
use of com.opentext.ia.sdk.client.api.QueryResult in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenWorkingWithQueryResult method shouldHonorSetValues.
@Test
void shouldHonorSetValues() throws IOException {
try (QueryResult result = newQueryResult()) {
assertEquals(resultSetQuota, result.getResultSetQuota());
assertEquals(resultSetCount, result.getResultSetCount());
assertEquals(aipQouta, result.getAipQuota());
assertEquals(aiuQuota, result.getAiuQuota());
assertEquals(cacheOutIgnored, result.isCacheOutAipIgnored());
assertEquals(stream, result.getResultStream());
}
}
use of com.opentext.ia.sdk.client.api.QueryResult in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenCreatingQueryResultFromResponse method shouldCreateResultAndNotCloseResponse.
@Test
void shouldCreateResultAndNotCloseResponse() throws IOException {
int aipQuota = data.integer();
int resultSetCount = data.integer();
int aiuQuota = data.integer();
int resultSetQuota = data.integer();
// NOPMD mock only
Response response = mock(Response.class);
// NOPMD mock only
InputStream body = mock(InputStream.class);
when(response.getBody()).thenReturn(body);
when(response.getHeaderValue("cacheOutAipIgnored", false)).thenReturn(Boolean.TRUE);
when(response.getHeaderValue("aipQuota", 0)).thenReturn(aipQuota);
when(response.getHeaderValue("resultSetCount", 0)).thenReturn(resultSetCount);
when(response.getHeaderValue("aiuQuota", 0)).thenReturn(aiuQuota);
when(response.getHeaderValue("resultSetQuota", 0)).thenReturn(resultSetQuota);
try (QueryResult result = factory.create(response, () -> {
})) {
assertTrue(result.isCacheOutAipIgnored(), "Is cache-out of AIPs ignored");
assertEquals(aipQuota, result.getAipQuota(), "AIP quota");
assertEquals(aiuQuota, result.getAiuQuota(), "AIU quota");
assertEquals(resultSetCount, result.getResultSetCount(), "# results");
assertEquals(resultSetQuota, result.getResultSetQuota(), "Result set quota");
verify(body, never()).close();
verify(response, never()).close();
}
verify(body).close();
verify(response).close();
}
Aggregations