Skip to content

Commit

Permalink
feat: added impl of productNames crtiteria as list
Browse files Browse the repository at this point in the history
  • Loading branch information
JordenReuter committed Mar 4, 2024
1 parent 46469cb commit 48a4ca5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.tkit.onecx.permission.domain.criteria;

import java.util.List;

import lombok.Getter;
import lombok.Setter;

Expand All @@ -8,6 +10,7 @@
public class PermissionSearchCriteria {

private String appId;
private List<String> productNames;
private Integer pageNumber;
private Integer pageSize;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public PageResult<Permission> findByCriteria(PermissionSearchCriteria criteria)

List<Predicate> predicates = new ArrayList<>();
addSearchStringPredicate(predicates, cb, root.get(Permission_.appId), criteria.getAppId());

if (criteria.getProductNames() != null) {
predicates.add(root.get(Permission_.PRODUCT_NAME).in(criteria.getProductNames()));
}
if (!predicates.isEmpty()) {
cq.where(predicates.toArray(new Predicate[] {}));
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/openapi/onecx-permission-internal-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,11 @@ components:
properties:
appId:
type: string
productName:
type: string
productNames:
type: array
items:
type:
string
pageNumber:
format: int32
description: The number of page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import static org.jboss.resteasy.reactive.RestResponse.Status.BAD_REQUEST;
import static org.jboss.resteasy.reactive.RestResponse.Status.OK;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.tkit.onecx.permission.rs.internal.mappers.ExceptionMapper;
import org.tkit.onecx.permission.test.AbstractTest;
Expand Down Expand Up @@ -75,6 +77,23 @@ void searchCriteriaTest() {
assertThat(data).isNotNull();
assertThat(data.getTotalElements()).isEqualTo(5);
assertThat(data.getStream()).isNotNull().hasSize(5);

var productNamesCriteria = new PermissionSearchCriteriaDTO();
productNamesCriteria.setProductNames(List.of("test1"));
var output = given()
.contentType(APPLICATION_JSON)
.body(productNamesCriteria)
.post()
.then()
.statusCode(OK.getStatusCode())
.contentType(APPLICATION_JSON)
.extract()
.as(PermissionPageResultDTO.class);

assertThat(output).isNotNull();
assertThat(output.getTotalElements()).isEqualTo(7);
assertThat(output.getStream()).isNotNull().hasSize(7);

}

@Test
Expand Down

0 comments on commit 48a4ca5

Please sign in to comment.