use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse 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.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testDelete.
@Test
public void testDelete() 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);
QueueStateInfo queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(2);
}
use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testDeleteMultiple.
@Test
public void testDeleteMultiple() throws Exception {
localService.bulkAdd(new Status(), bulkAddRequest.build());
TaskQueueDeleteRequest deleteRequest = TaskQueueDeleteRequest.newBuilder().setQueueName(ByteString.copyFromUtf8(entry.getName())).addTaskName(bulkAddRequest.getAddRequest(1).getTaskName()).addTaskName(bulkAddRequest.getAddRequest(0).getTaskName()).build();
TaskQueueDeleteResponse deleteResponse = localService.delete(new Status(), deleteRequest);
assertThat(deleteResponse.getResultCount()).isEqualTo(2);
assertThat(deleteResponse.getResult(0)).isEqualTo(ErrorCode.OK);
assertThat(deleteResponse.getResult(1)).isEqualTo(ErrorCode.OK);
QueueStateInfo queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(1);
}
use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueue method delete.
/**
* Delete RPC implementation.
*/
public TaskQueueDeleteResponse delete(Status status, TaskQueueDeleteRequest request) {
String queueName = request.getQueueName().toStringUtf8();
// throws if queue does not exist so no need to check for null
DevQueue queue = getQueueByName(queueName);
TaskQueueDeleteResponse.Builder response = TaskQueueDeleteResponse.newBuilder();
for (ByteString taskName : request.getTaskNameList()) {
try {
if (!queue.deleteTask(taskName.toStringUtf8())) {
response.addResult(ErrorCode.UNKNOWN_TASK);
} else {
response.addResult(ErrorCode.OK);
}
} catch (ApiProxy.ApplicationException e) {
response.addResult(ErrorCode.forNumber(e.getApplicationError()));
}
}
return response.build();
}
Aggregations