Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix minor issues in v1 #9

Merged
merged 4 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import static org.jboss.resteasy.reactive.RestResponse.StatusCode.NOT_FOUND;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.persistence.OptimisticLockException;
import jakarta.validation.ConstraintViolationException;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;

Expand All @@ -24,8 +22,7 @@
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApplicationScoped
public class SearchConfigControllerV1 implements SearchConfigV1Api {

@Inject
Expand Down Expand Up @@ -79,7 +76,6 @@ public Response updateSearchConfig(String configId, UpdateSearchConfigRequestDTO
if (searchConfig == null) {
return Response.status(NOT_FOUND).build();
}

mapper.update(searchConfig, updateSearchConfigRequestDTOV1);
var updatedSearchConfig = dao.update(searchConfig);
return Response.ok(mapper.mapUpdate(updatedSearchConfig)).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ default CreateSearchConfigResponseDTOV1 mapCreate(SearchConfig searchConfig) {
return new CreateSearchConfigResponseDTOV1().config(map(searchConfig));
}

@Mapping(target = "productName", ignore = true)
@Mapping(target = "page", ignore = true)
@Mapping(target = "appId", ignore = true)
@Mapping(target = "id", ignore = true)
@Mapping(target = "creationDate", ignore = true)
@Mapping(target = "modificationDate", ignore = true)
Expand Down
10 changes: 1 addition & 9 deletions src/main/openapi/search-config-openapi-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,11 @@ components:
type: object
required:
- modificationCount
- productName
- page
- name
- appId
properties:
page:
type: string
name:
type: string
appId:
type: string
productName:
type: string
minLength: 1
modificationCount:
type: integer
fieldListVersion:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ void shouldUpdateModificationCount() {
String page = "criteria-page";

UpdateSearchConfigRequestDTOV1 updateRequestBody = new UpdateSearchConfigRequestDTOV1();
updateRequestBody.setAppId(application);
updateRequestBody.setProductName("productName1");
updateRequestBody.setName(name);
updateRequestBody.setPage(page);
updateRequestBody.setModificationCount(0);

given()
Expand All @@ -152,9 +149,7 @@ void shouldUpdateModificationCount() {
assertThat(searchConfigDTO).isNotNull();
assertThat(searchConfigDTO.getConfig()).isNotNull();
assertThat(searchConfigDTO.getConfig().getName()).isEqualTo(name);
assertThat(searchConfigDTO.getConfig().getAppId()).isEqualTo(updateRequestBody.getAppId());
assertThat(searchConfigDTO.getConfig().getName()).isEqualTo(updateRequestBody.getName());
assertThat(searchConfigDTO.getConfig().getPage()).isEqualTo(updateRequestBody.getPage());
assertThat(searchConfigDTO.getConfig().getModificationCount()).isEqualTo(1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,10 @@ void shouldNotCreateSearchConfigDuplicate() {
void shouldUpdateModificationCount() {
String searchConfigId = "c1";

String application = "support-tool-ui";
String name = "criteria-name";
String page = "criteria-page";

UpdateSearchConfigRequestDTOV1 updateRequestBody = new UpdateSearchConfigRequestDTOV1();
updateRequestBody.setProductName("productName1");
updateRequestBody.setAppId(application);
updateRequestBody.setName(name);
updateRequestBody.setPage(page);
updateRequestBody.setModificationCount(0);

var searchConfigDTO = given()
Expand All @@ -163,9 +158,7 @@ void shouldUpdateModificationCount() {
assertThat(searchConfigDTO).isNotNull();
assertThat(searchConfigDTO.getConfig()).isNotNull();
assertThat(searchConfigDTO.getConfig().getConfigId()).isEqualTo(searchConfigId);
assertThat(searchConfigDTO.getConfig().getAppId()).isEqualTo(updateRequestBody.getAppId());
assertThat(searchConfigDTO.getConfig().getName()).isEqualTo(updateRequestBody.getName());
assertThat(searchConfigDTO.getConfig().getPage()).isEqualTo(updateRequestBody.getPage());
assertThat(searchConfigDTO.getConfig().getModificationCount()).isEqualTo(1);

}
Expand All @@ -174,15 +167,10 @@ void shouldUpdateModificationCount() {
void shouldUpdateModificationCountOptLock() {
String searchConfigId = "c1";

String application = "support-tool-ui";
String name = "criteria-name";
String page = "criteria-page";

UpdateSearchConfigRequestDTOV1 updateRequestBody = new UpdateSearchConfigRequestDTOV1();
updateRequestBody.setProductName("productName1");
updateRequestBody.setAppId(application);
updateRequestBody.setName(name);
updateRequestBody.setPage(page);
updateRequestBody.setModificationCount(0);

given()
Expand Down Expand Up @@ -221,15 +209,10 @@ void shouldNotUpdateSearchConfigWhenBadRequest() {
void shouldNotUpdateSearchConfigNotExists() {
String searchConfigId = "NotExists";

String application = "support-tool-ui";
String name = "criteria-name";
String page = "criteria-page";

UpdateSearchConfigRequestDTOV1 updateRequestBody = new UpdateSearchConfigRequestDTOV1();
updateRequestBody.setProductName("productName1");
updateRequestBody.setAppId(application);
updateRequestBody.setName(name);
updateRequestBody.setPage(page);
updateRequestBody.setModificationCount(1);

given()
Expand Down
Loading