Search in sources :

Example 1 with Status

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);
}
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 Status

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

Example 3 with Status

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

Example 4 with Status

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

Example 5 with Status

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

Aggregations

Status (com.google.appengine.tools.development.LocalRpcService.Status)34 Test (org.junit.Test)31 TaskQueueBulkAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse)18 TaskQueueQueryAndOwnTasksRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksRequest)5 ApiProxy (com.google.apphosting.api.ApiProxy)5 ByteString (com.google.protobuf.ByteString)5 TaskQueueAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest)4 TaskQueueModifyTaskLeaseRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest)4 TaskQueueQueryAndOwnTasksResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksResponse)4 Clock (com.google.appengine.tools.development.Clock)4 QueueXml (com.google.apphosting.utils.config.QueueXml)4 TaskQueueDeleteRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteRequest)3 TaskQueueDeleteResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse)3 TaskQueueAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse)2 TaskQueueBulkAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ImageData (com.google.appengine.api.images.ImagesServicePb.ImageData)1 MIME_TYPE (com.google.appengine.api.images.ImagesServicePb.OutputSettings.MIME_TYPE)1 Transform (com.google.appengine.api.images.ImagesServicePb.Transform)1 TaskQueueFetchQueueStatsRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueFetchQueueStatsRequest)1