use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class SearchCountClusteredTest method assertTotalAndPageSize.
private void assertTotalAndPageSize(CompletionStage<RestResponse> response, int totalResults, int pageSize) {
RestResponse restResponse = await(response);
String body = restResponse.getBody();
Json responseDoc = Json.read(body);
Json total = responseDoc.at("total_results");
assertEquals(totalResults, total.asLong());
long hitsSize = responseDoc.at("hits").asJsonList().size();
assertEquals(pageSize, hitsSize);
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class SearchCountClusteredTest method setUp.
@BeforeClass
public void setUp() {
LongStream.range(0, INDEXED_ENTRIES).forEach(i -> {
String str = "index " + i;
String value = Json.object().set("_type", "IndexedEntity").set("indexedStoredField", str).set("indexedNotStoredField", str).set("sortableStoredField", i % 20).set("sortableNotStoredField", "index_" + i % 20).set("notIndexedField", str).toString();
RestResponse response = await(indexedCache().put(String.valueOf(i), RestEntity.create(APPLICATION_JSON, value)));
assertEquals(204, response.getStatus());
assertTrue(response.getBody().isEmpty());
});
LongStream.range(0, NOT_INDEXED_ENTRIES).forEach(i -> {
String value = "text " + i;
Json json = Json.object().set("_type", "NotIndexedEntity").set("field1", value).set("field2", value);
RestResponse response = await(nonIndexedCache().put(String.valueOf(i), RestEntity.create(APPLICATION_JSON, json.toString())));
assertEquals(204, response.getStatus());
assertTrue(response.getBody().isEmpty());
});
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class BackupManagerIT method testManagerBackupParameters.
@Test
public void testManagerBackupParameters() throws Exception {
String name = "testManagerBackupParameters";
performTest(client -> {
Map<String, List<String>> params = new HashMap<>();
params.put("caches", Collections.singletonList("*"));
params.put("counters", Collections.singletonList("weak-volatile"));
RestCacheManagerClient cm = client.cacheManager("clustered");
RestResponse response = await(cm.createBackup(name, params));
assertEquals(202, response.getStatus());
return awaitOk(() -> cm.getBackup(name, false));
}, client -> await(client.cacheManager("clustered").deleteBackup(name)), (zip, client) -> {
Map<String, List<String>> params = new HashMap<>();
params.put("caches", Collections.singletonList("cache1"));
params.put("counters", Collections.singletonList("*"));
RestCacheManagerClient cm = client.cacheManager("clustered");
RestResponse response = await(cm.restore(name, zip, params));
assertEquals(202, response.getStatus());
return awaitCreated(() -> cm.getRestore(name));
}, client -> {
// Assert that only caches and the specified "weak-volatile" counter have been backed up. Internal caches will still be present
assertEquals("[\"___protobuf_metadata\",\"memcachedCache\",\"cache1\",\"___script_cache\"]", await(client.caches()).getBody());
assertEquals("[\"weak-volatile\"]", await(client.counters()).getBody());
assertEquals(404, await(client.schemas().get("schema.proto")).getStatus());
assertEquals("[]", await(client.tasks().list(RestTaskClient.ResultType.USER)).getBody());
}, false);
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class BackupManagerIT method createCounter.
private void createCounter(String name, Element type, Storage storage, RestClient client, long delta) {
String config = String.format("{\n" + " \"%s\":{\n" + " \"initial-value\":0,\n" + " \"storage\":\"%s\"\n" + " }\n" + "}", type, storage.toString());
RestCounterClient counterClient = client.counter(name);
RestResponse rsp = await(counterClient.create(RestEntity.create(MediaType.APPLICATION_JSON, config)));
assertEquals(200, rsp.getStatus());
if (delta != 0) {
rsp = await(counterClient.add(delta));
assertEquals(name, name.contains("strong") ? 200 : 204, rsp.getStatus());
assertNotNull(rsp.getBody());
}
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class BackupManagerIT method testClusterBackupFromFile.
@Test
public void testClusterBackupFromFile() throws Exception {
String name = "testClusterBackup";
performTest(client -> {
RestClusterClient cluster = client.cluster();
RestResponse response = await(cluster.createBackup(name));
assertEquals(202, response.getStatus());
return awaitOk(() -> cluster.getBackup(name, false));
}, client -> await(client.cacheManager("clustered").deleteBackup(name)), (zip, client) -> {
RestClusterClient c = client.cluster();
RestResponse response = await(c.restore(name, zip.getPath()));
assertEquals(202, response.getStatus());
return awaitCreated(() -> c.getRestore(name));
}, this::assertWildcardContent, true);
}
Aggregations