Skip to content

Commit

Permalink
Batch part search key bug (#3899)
Browse files Browse the repository at this point in the history
* Fix batch part search keys in rest response bug

* Update BatchPartCollectionResourceTest description
  • Loading branch information
BertMatthys authored May 23, 2024
1 parent 7683479 commit e22cf89
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,8 @@ public BatchPartResponse createBatchPartResponse(BatchPart batchPart, RestUrlBui
response.setId(batchPart.getId());
response.setBatchId(batchPart.getBatchId());
response.setBatchType(batchPart.getBatchType());
response.setSearchKey(batchPart.getBatchSearchKey());
response.setSearchKey2(batchPart.getBatchSearchKey2());
response.setSearchKey(batchPart.getSearchKey());
response.setSearchKey2(batchPart.getSearchKey2());
response.setScopeId(batchPart.getScopeId());
response.setSubScopeId(batchPart.getSubScopeId());
response.setScopeType(batchPart.getScopeType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ public final class RestUrls {
/**
* URL template for the collection of batches: <i>management/batches/{0:batchId}/batch-parts</i>
*/
public static final String[] URL_BATCH_PART_COLLECTION = { SEGMENT_MANAGEMENT_RESOURCES, SEGMENT_BATCH_PARTS, "{0}", SEGMENT_BATCH_PARTS };
public static final String[] URL_BATCH_PART_COLLECTION = { SEGMENT_MANAGEMENT_RESOURCES, SEGMENT_BATCHES, "{0}", SEGMENT_BATCH_PARTS };

/**
* URL template for a single event subscription: <i>runtime/event-subscriptions/{0:eventSubscriptionId}</i>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.flowable.rest.service.api.management;

import static org.assertj.core.api.Assertions.assertThat;

import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.flowable.batch.api.Batch;
import org.flowable.batch.api.BatchPart;
import org.flowable.rest.service.BaseSpringRestTestCase;
import org.flowable.rest.service.api.RestUrls;
import org.junit.Test;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

/**
* Test getting a BatchPart with the BatchPartCollectionResource.
*/
public class BatchPartCollectionResourceTest extends BaseSpringRestTestCase {

@Test
public void testGetBatchParts() throws Exception {
ObjectNode docNode = objectMapper.createObjectNode();
docNode.put("test", "value");

Batch batch = managementService.createBatchBuilder()
.batchType(Batch.PROCESS_MIGRATION_TYPE)
.searchKey("test")
.searchKey2("anotherTest")
.batchDocumentJson(docNode.toString())
.create();

BatchPart batchPart = managementService.createBatchPartBuilder(batch)
.type("deleteProcess")
.status("waiting")
.searchKey("testPart")
.searchKey2("anotherTestPart")
.type(Batch.PROCESS_MIGRATION_TYPE)
.create();

String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_PART_COLLECTION, batch.getId());
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + url), HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
JsonNode batchPartNode = responseNode.get(0);
assertThat(batchPartNode).isNotNull();
assertThat(batchPartNode.get("id").asText()).isEqualTo(batchPart.getId());
assertThat(batchPartNode.get("batchId").asText()).isEqualTo(batchPart.getBatchId());
assertThat(batchPartNode.get("searchKey").asText()).isEqualTo(batchPart.getSearchKey());
assertThat(batchPartNode.get("searchKey2").asText()).isEqualTo(batchPart.getSearchKey2());
assertThat(batchPartNode.get("batchType").asText()).isEqualTo(batchPart.getBatchType());
assertThat(batchPartNode.get("status").asText()).isEqualTo(batchPart.getStatus());

managementService.deleteBatch(batch.getId());
}
}

0 comments on commit e22cf89

Please sign in to comment.