use of org.infinispan.client.rest.RestTaskClient in project infinispan by infinispan.
the class TasksResourceTest method testParameterizedTaskExec.
@Test
public void testParameterizedTaskExec() {
RestTaskClient taskClient = client.tasks();
CompletionStage<RestResponse> response = taskClient.exec("PARAMETERIZED_TASK", singletonMap("parameter", "Hello"));
ResponseAssertion.assertThat(response).isOk();
Json jsonNode = Json.read(join(response).getBody());
assertEquals("Hello", jsonNode.asString());
}
use of org.infinispan.client.rest.RestTaskClient in project infinispan by infinispan.
the class TasksResourceTest method testTaskList.
@Test
public void testTaskList() {
RestTaskClient taskClient = adminClient.tasks();
RestResponse response = join(taskClient.list(ALL));
ResponseAssertion.assertThat(response).isOk();
Json jsonNode = Json.read(response.getBody());
assertEquals(4, jsonNode.asList().size());
Json task = jsonNode.at(0);
assertEquals("Dummy", task.at("type").asString());
assertEquals("ONE_NODE", task.at("execution_mode").asString());
assertEquals("DummyRole", task.at("allowed_role").asString());
}
use of org.infinispan.client.rest.RestTaskClient in project infinispan by infinispan.
the class TasksResourceTest method testFailingTaskExec.
@Test
public void testFailingTaskExec() {
RestTaskClient taskClient = client.tasks();
CompletionStage<RestResponse> response = taskClient.exec("FAILING_TASK");
ResponseAssertion.assertThat(response).isError();
}
use of org.infinispan.client.rest.RestTaskClient in project infinispan by infinispan.
the class TasksResourceTest method testTaskExec.
@Test
public void testTaskExec() {
RestTaskClient taskClient = client.tasks();
RestResponse response = join(taskClient.exec("SUCCESSFUL_TASK"));
ResponseAssertion.assertThat(response).isOk();
Json jsonNode = Json.read(response.getBody());
assertEquals("result", jsonNode.asString());
}
use of org.infinispan.client.rest.RestTaskClient in project infinispan by infinispan.
the class TasksResourceTest method testTaskUpload.
@Test
public void testTaskUpload() throws Exception {
RestTaskClient taskClient = client.tasks();
String script = getResourceAsString("hello.js", getClass().getClassLoader());
RestEntity scriptEntity = RestEntity.create(APPLICATION_JAVASCRIPT, script);
CompletionStage<RestResponse> response = taskClient.uploadScript("hello", scriptEntity);
ResponseAssertion.assertThat(response).isOk();
response = taskClient.exec("hello", Collections.singletonMap("greetee", "Friend"));
ResponseAssertion.assertThat(response).isOk();
Json jsonNode = Json.read(join(response).getBody());
assertEquals("Hello Friend", jsonNode.asString());
}
Aggregations