@ApiOperation(value = "List batches", tags = { "Batches" }, nickname = "listBatches")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", dataType = "string", value = "Only return batch with the given id", paramType = "query"),
            @ApiImplicitParam(name = "batchType", dataType = "string", value = "Only return batches for the given type", paramType = "query"),
            @ApiImplicitParam(name = "searchKey", dataType = "string", value = "Only return batches for the given search key", paramType = "query"),
            @ApiImplicitParam(name = "searchKey2", dataType = "string", value = "Only return batches for the given search key2", paramType = "query"),
            @ApiImplicitParam(name = "createTimeBefore", dataType = "string", format="date-time", value = "Only return batches created before the given date", paramType = "query"),
            @ApiImplicitParam(name = "createTimeAfter", dataType = "string", format="date-time", value = "Only batches batches created after the given date", paramType = "query"),
            @ApiImplicitParam(name = "completeTimeBefore", dataType = "string", format="date-time", value = "Only return batches completed before the given date", paramType = "query"),
            @ApiImplicitParam(name = "completeTimeAfter", dataType = "string", format="date-time", value = "Only batches batches completed after the given date", paramType = "query"),
            @ApiImplicitParam(name = "status", dataType = "string", value = "Only return batches for the given status", paramType = "query"),
            @ApiImplicitParam(name = "tenantId", dataType = "string", value = "Only return batches for the given tenant id", paramType = "query"),
            @ApiImplicitParam(name = "tenantIdLike", dataType = "string", value = "Only return batches like given search key", paramType = "query"),
            @ApiImplicitParam(name = "withoutTenantId", dataType = "boolean", value = "If true, only returns batches without a tenantId set. If false, the withoutTenantId parameter is ignored.", paramType = "query")
    })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Indicates the requested batches were returned."),
            @ApiResponse(code = 400, message = "Indicates an illegal value has been used in a url query parameter. Status description contains additional details about the error.")
    })
    @GetMapping(value = "/management/batches", produces = "application/json")
    public DataResponse<BatchResponse> getBatches(@ApiParam(hidden = true) @RequestParam Map<String, String> allRequestParams) {
        BatchQuery query = managementService.createBatchQuery();

        if (allRequestParams.containsKey("id")) {
            query.batchId(allRequestParams.get("id"));
        }
        if (allRequestParams.containsKey("batchType")) {
            query.batchType(allRequestParams.get("batchType"));
        }
        if (allRequestParams.containsKey("searchKey")) {
            query.searchKey(allRequestParams.get("searchKey"));
        }
        if (allRequestParams.containsKey("searchKey2")) {
            query.searchKey2(allRequestParams.get("searchKey2"));
        }
        if (allRequestParams.containsKey("createTimeBefore")) {
            query.createTimeLowerThan(RequestUtil.getDate(allRequestParams, "createTimeBefore"));
        }
        if (allRequestParams.containsKey("createTimeAfter")) {
            query.createTimeHigherThan(RequestUtil.getDate(allRequestParams, "createTimeAfter"));
        }
        if (allRequestParams.containsKey("completeTimeBefore")) {
            query.completeTimeLowerThan(RequestUtil.getDate(allRequestParams, "completeTimeBefore"));
        }
        if (allRequestParams.containsKey("completeTimeAfter")) {
            query.completeTimeHigherThan(RequestUtil.getDate(allRequestParams, "completeTimeAfter"));
        }
        if (allRequestParams.containsKey("status")) {
            query.status(allRequestParams.get("status"));
        }
        if (allRequestParams.containsKey("tenantId")) {
            query.tenantId(allRequestParams.get("tenantId"));
        }
        if (allRequestParams.containsKey("tenantIdLike")) {
            query.tenantIdLike(allRequestParams.get("tenantIdLike"));
        }
        if (allRequestParams.containsKey("withoutTenantId")) {
            if (Boolean.parseBoolean(allRequestParams.get("withoutTenantId"))) {
                query.withoutTenantId();
            }
        }
        
        if (restApiInterceptor != null) {
            restApiInterceptor.accessBatchInfoWithQuery(query);
        }

        return paginateList(allRequestParams, query, "id", JobQueryProperties.PROPERTIES, restResponseFactory::createBatchResponse);
    }
@Test
    public void testGetBatches() throws Exception {
        Calendar hourAgo = Calendar.getInstance();
        hourAgo.add(Calendar.HOUR, -1);

        Calendar inAnHour = Calendar.getInstance();
        inAnHour.add(Calendar.HOUR, 1);

        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();

        String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION);
        assertResultsPresentInDataResponse(url, batch.getId());

        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?createTimeBefore=" + getISODateString(inAnHour.getTime());
        assertResultsPresentInDataResponse(url, batch.getId());

        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?createTimeBefore=" + getISODateString(hourAgo.getTime());
        assertResultsPresentInDataResponse(url);

        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?createTimeAfter=" + getISODateString(hourAgo.getTime());
        assertResultsPresentInDataResponse(url, batch.getId());

        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?createTimeAfter=" + getISODateString(inAnHour.getTime());
        assertResultsPresentInDataResponse(url);
        
        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?batchType=" + Batch.PROCESS_MIGRATION_TYPE;
        assertResultsPresentInDataResponse(url, batch.getId());
        
        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?batchType=unknown";
        assertEmptyResultsPresentInDataResponse(url);
        
        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?searchKey=test";
        assertResultsPresentInDataResponse(url, batch.getId());
        
        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?searchKey=unknown";
        assertEmptyResultsPresentInDataResponse(url);
        
        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?searchKey2=anotherTest";
        assertResultsPresentInDataResponse(url, batch.getId());
        
        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?searchKey2=unknown";
        assertEmptyResultsPresentInDataResponse(url);

        url = RestUrls.createRelativeResourceUrl(RestUrls.URL_BATCH_COLLECTION) + "?withoutTenantId=true";
        assertResultsPresentInDataResponse(url, batch.getId());
        
        managementService.deleteBatch(batch.getId());
    }