Search in sources :

Example 1 with TaskQueueDeleteResponse

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);
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueDeleteRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteRequest) TaskQueueDeleteResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse) Test(org.junit.Test)

Example 2 with TaskQueueDeleteResponse

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);
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueDeleteRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteRequest) TaskQueueDeleteResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse) Test(org.junit.Test)

Example 3 with TaskQueueDeleteResponse

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);
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueDeleteRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteRequest) TaskQueueDeleteResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse) Test(org.junit.Test)

Example 4 with TaskQueueDeleteResponse

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();
}
Also used : ApiProxy(com.google.apphosting.api.ApiProxy) ByteString(com.google.protobuf.ByteString) TaskQueueDeleteResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse) ByteString(com.google.protobuf.ByteString)

Aggregations

TaskQueueDeleteResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse)4 TaskQueueDeleteRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteRequest)3 Status (com.google.appengine.tools.development.LocalRpcService.Status)3 Test (org.junit.Test)3 ApiProxy (com.google.apphosting.api.ApiProxy)1 ByteString (com.google.protobuf.ByteString)1