Search in sources :

Example 11 with TaskQueueBulkAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueTest method testBulkAddPullTasksToPushQueue.

@Test
public void testBulkAddPullTasksToPushQueue() throws Exception {
    for (TaskQueueAddRequest.Builder addRequest : bulkAddPullRequest.getAddRequestBuilderList()) {
        addRequest.setQueueName(ByteString.copyFromUtf8(entry.getName()));
    }
    TaskQueueBulkAddResponse response = localService.bulkAdd(new Status(), bulkAddPullRequest.build());
    assertThat(response.getTaskResult(0).getResult().getNumber()).isEqualTo(ErrorCode.INVALID_QUEUE_MODE_VALUE);
    assertThat(response.getTaskResult(1).getResult().getNumber()).isEqualTo(ErrorCode.INVALID_QUEUE_MODE_VALUE);
    assertThat(response.getTaskResult(2).getResult().getNumber()).isEqualTo(ErrorCode.INVALID_QUEUE_MODE_VALUE);
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) TaskQueueBulkAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse) Test(org.junit.Test)

Example 12 with TaskQueueBulkAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueTest method testBulkAdd.

@Test
public void testBulkAdd() throws Exception {
    TaskQueueBulkAddResponse response = localService.bulkAdd(new Status(), bulkAddRequest.build());
    assertThat(response).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 13 with TaskQueueBulkAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueTest method testBulkAddPullNoName.

@Test
public void testBulkAddPullNoName() throws Exception {
    addPullRequest1.clearTaskName();
    addPullRequest2.clearTaskName();
    addPullRequest3.clearTaskName();
    TaskQueueBulkAddResponse response = localService.bulkAdd(new Status(), bulkAddPullRequest.buildPartial());
    assertThat(response.getTaskResult(0).getChosenTaskName().toStringUtf8()).startsWith("task-");
    assertThat(response.getTaskResult(1).getChosenTaskName().toStringUtf8()).startsWith("task-");
    assertThat(response.getTaskResult(2).getChosenTaskName().toStringUtf8()).startsWith("task-");
    expectedTaskResult1.setChosenTaskName(response.getTaskResult(0).getChosenTaskName());
    expectedTaskResult2.setChosenTaskName(response.getTaskResult(1).getChosenTaskName());
    expectedTaskResult3.setChosenTaskName(response.getTaskResult(2).getChosenTaskName());
    assertThat(response).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 14 with TaskQueueBulkAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueTest method testBulkAddPushTasksToPullQueue.

@Test
public void testBulkAddPushTasksToPullQueue() throws Exception {
    for (TaskQueueAddRequest.Builder addRequest : bulkAddRequest.getAddRequestBuilderList()) {
        addRequest.setQueueName(ByteString.copyFromUtf8("pull-queue"));
    }
    TaskQueueBulkAddResponse response = localService.bulkAdd(new Status(), bulkAddRequest.build());
    assertThat(response.getTaskResult(0).getResult().getNumber()).isEqualTo(ErrorCode.INVALID_QUEUE_MODE_VALUE);
    assertThat(response.getTaskResult(1).getResult().getNumber()).isEqualTo(ErrorCode.INVALID_QUEUE_MODE_VALUE);
    assertThat(response.getTaskResult(2).getResult().getNumber()).isEqualTo(ErrorCode.INVALID_QUEUE_MODE_VALUE);
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) TaskQueueBulkAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse) Test(org.junit.Test)

Example 15 with TaskQueueBulkAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueTest method testTransactionalTasks.

@Test
public void testTransactionalTasks() throws Exception {
    DevQueue.taskNameGenerator = new AtomicInteger();
    final int tx = 321;
    localService.stop();
    localService = LocalTaskQueueTestConfig.getLocalTaskQueue();
    initLocalTaskQueue(Clock.DEFAULT);
    QueueXml queueXml = makeQueueXml();
    localService.setQueueXml(queueXml);
    localService.start();
    addRequest1.getTransactionBuilder().setHandle(tx).setApp("foo");
    addRequest2.getTransactionBuilder().setHandle(tx).setApp("foo");
    addRequest3.getTransactionBuilder().setHandle(tx).setApp("foo");
    addRequest1.setTaskName(ByteString.copyFromUtf8(""));
    addRequest2.setTaskName(ByteString.copyFromUtf8(""));
    addRequest3.setTaskName(ByteString.copyFromUtf8(""));
    expectedTaskResult1.setChosenTaskName(ByteString.copyFromUtf8("task1"));
    expectedTaskResult2.setChosenTaskName(ByteString.copyFromUtf8("task2"));
    expectedTaskResult3.setChosenTaskName(ByteString.copyFromUtf8("task3"));
    Delegate<?> oldDelegate = ApiProxy.getDelegate();
    ApiProxy.setDelegate(mockDelegate);
    TaskQueueBulkAddRequest.Builder expectedAddActionsRequest = bulkAddRequest.clone();
    expectedAddActionsRequest.getAddRequestBuilder(0).setTaskName(ByteString.copyFromUtf8("task1"));
    expectedAddActionsRequest.getAddRequestBuilder(1).setTaskName(ByteString.copyFromUtf8("task2"));
    expectedAddActionsRequest.getAddRequestBuilder(2).setTaskName(ByteString.copyFromUtf8("task3"));
    when(mockDelegate.makeSyncCall(ApiProxy.getCurrentEnvironment(), "datastore_v3", "addActions", expectedAddActionsRequest.build().toByteArray())).thenReturn(new byte[0]);
    // add an entry in the default queue, this makes sure that the default
    // queue is automagically added, but task is not (it's sent to datastore).
    TaskQueueBulkAddResponse response = localService.bulkAdd(new Status(), bulkAddRequest.build());
    assertThat(response).isEqualTo(expectedBulkAddResponse.build());
    verify(mockDelegate).makeSyncCall(any(), any(), any(), any());
    Map<String, QueueStateInfo> queueInfo = localService.getQueueStateInfo();
    assertThat(queueInfo).hasSize(queueXml.getEntries().size() + 1);
    assertThat(queueInfo.get(addRequest1.getQueueName().toStringUtf8()).getCountTasks()).isEqualTo(0);
    // We have to restore the old delegate so that LocalServiceTestHelper won't break in tearDown
    ApiProxy.setDelegate(oldDelegate);
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueBulkAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QueueXml(com.google.apphosting.utils.config.QueueXml) TaskQueueBulkAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

TaskQueueBulkAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse)21 Status (com.google.appengine.tools.development.LocalRpcService.Status)18 Test (org.junit.Test)16 ByteString (com.google.protobuf.ByteString)5 TaskQueueAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest)4 TaskQueueBulkAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest)4 TaskQueueQueryAndOwnTasksRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksRequest)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)3 LatencyPercentiles (com.google.appengine.tools.development.LatencyPercentiles)2 InternalFailureException (com.google.appengine.api.taskqueue.InternalFailureException)1 TaskQueueAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse)1 TaskQueueModifyTaskLeaseRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest)1 TaskQueueModifyTaskLeaseResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseResponse)1 ErrorCode (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueServiceError.ErrorCode)1 ApiProxy (com.google.apphosting.api.ApiProxy)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IdentityHashMap (java.util.IdentityHashMap)1