use of com.google.appengine.tools.development.LocalRpcService.Status in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testDeleteUnknownTask.
@Test
public void testDeleteUnknownTask() throws Exception {
localService.bulkAdd(new Status(), bulkAddRequest.build());
TaskQueueDeleteRequest deleteRequest = TaskQueueDeleteRequest.newBuilder().setQueueName(ByteString.copyFromUtf8(entry.getName())).addTaskName(bulkAddRequest.getAddRequest(1).getTaskName()).build();
TaskQueueDeleteResponse deleteResponse = localService.delete(new Status(), deleteRequest);
assertThat(deleteResponse.getResultCount()).isEqualTo(1);
assertThat(deleteResponse.getResult(0)).isEqualTo(ErrorCode.OK);
deleteResponse = localService.delete(new Status(), deleteRequest);
assertThat(deleteResponse.getResultCount()).isEqualTo(1);
assertThat(deleteResponse.getResult(0)).isEqualTo(ErrorCode.UNKNOWN_TASK);
}
use of com.google.appengine.tools.development.LocalRpcService.Status in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testFlushQueue.
@Test
public void testFlushQueue() throws Exception {
QueueStateInfo queueInfo;
localService.bulkAdd(new Status(), bulkAddRequest.build());
queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(3);
localService.flushQueue(entry.getName());
queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(0);
localService.flushQueue(entry.getName());
queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(0);
}
use of com.google.appengine.tools.development.LocalRpcService.Status in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testAddUnNamedTask.
@Test
public void testAddUnNamedTask() throws Exception {
TaskQueueAddRequest.Builder request = bulkAddRequest.getAddRequestBuilder(0);
TaskQueueAddResponse.Builder expectedResponse = TaskQueueAddResponse.newBuilder();
request.setTaskName(ByteString.copyFromUtf8(""));
TaskQueueAddResponse response = localService.add(new Status(), request.buildPartial());
assertThat(response.getChosenTaskName().toStringUtf8()).startsWith("task-");
expectedResponse.setChosenTaskName(response.getChosenTaskName());
assertThat(response).isEqualTo(expectedResponse.build());
}
use of com.google.appengine.tools.development.LocalRpcService.Status in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testAddExistingTask.
@Test
public void testAddExistingTask() throws Exception {
TaskQueueBulkAddResponse response = localService.bulkAdd(new Status(), bulkAddRequest.build());
assertThat(response).isEqualTo(expectedBulkAddResponse.build());
addRequest1.setTaskName(ByteString.copyFromUtf8("Unique1"));
expectedTaskResult2.setResult(ErrorCode.TASK_ALREADY_EXISTS);
addRequest3.setTaskName(ByteString.copyFromUtf8("Unique3"));
TaskQueueBulkAddResponse existingTaskresponse = localService.bulkAdd(new Status(), bulkAddRequest.build());
assertThat(existingTaskresponse).isEqualTo(expectedBulkAddResponse.build());
}
use of com.google.appengine.tools.development.LocalRpcService.Status in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testPurgeEmptyQueue.
@Test
public void testPurgeEmptyQueue() throws Exception {
QueueStateInfo queueInfo;
localService.purgeQueue(new Status(), purgeQueueRequest.build());
queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(0);
localService.bulkAdd(new Status(), bulkAddRequest.build());
queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(3);
localService.purgeQueue(new Status(), purgeQueueRequest.build());
queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(0);
localService.purgeQueue(new Status(), purgeQueueRequest.build());
queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(0);
}
Aggregations