use of com.opentext.ia.sdk.support.http.Response 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();
}
use of com.opentext.ia.sdk.support.http.Response in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenCreatingQueryResultFromResponse method shouldReturnNullIfResponseBodyIsNull.
@Test
void shouldReturnNullIfResponseBodyIsNull() throws IOException {
// NOPMD mock only
Response response = mock(Response.class);
Runnable closer = mock(Runnable.class);
assertNull(factory.create(response, closer), "Missing query result");
verify(closer).run();
}
Aggregations