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 api #8

Merged
merged 1 commit into from
Mar 6, 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 @@ -62,7 +62,7 @@ public Response getConfigByConfigId(String configId) {
public Response deleteSearchConfig(String configId) {
var data = dao.findByConfigId(configId);
if (data != null) {
dao.deleteQueryById(configId);
dao.deleteQueryById(data.getId());
}
return Response.noContent().build();
}
Expand All @@ -75,7 +75,7 @@ public Response findSearchConfigsBySearchCriteria(SearchConfigSearchRequestDTOV1

@Override
public Response updateSearchConfig(String configId, UpdateSearchConfigRequestDTOV1 updateSearchConfigRequestDTOV1) {
var searchConfig = dao.findById(configId);
var searchConfig = dao.findByConfigId(configId);
if (searchConfig == null) {
return Response.status(NOT_FOUND).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private List<String> setupColumns() {

@Test
void shouldGetSearchConfigsById() {
String configId = "1";
String configId = "c1";

var dto = given()
.contentType(APPLICATION_JSON)
Expand Down Expand Up @@ -115,7 +115,7 @@ void shouldCreateSearchConfig() {

@Test
void shouldUpdateModificationCount() {
String searchConfigId = "1";
String searchConfigId = "c1";

String application = "support-tool-ui";
String name = "criteria-name";
Expand Down Expand Up @@ -159,8 +159,8 @@ void shouldUpdateModificationCount() {
}

@Test
void shouldDeleteById() {
String configId = "8";
void shouldDeleteByConfigId() {
String configId = "c8";

given()
.when()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private List<String> setupColumns() {

@Test
void shouldGetSearchConfigsById() {
String configId = "1";
String configId = "c1";

var dto = given()
.contentType(APPLICATION_JSON)
Expand Down Expand Up @@ -136,7 +136,7 @@ void shouldNotCreateSearchConfigDuplicate() {

@Test
void shouldUpdateModificationCount() {
String searchConfigId = "1";
String searchConfigId = "c1";

String application = "support-tool-ui";
String name = "criteria-name";
Expand Down Expand Up @@ -172,7 +172,7 @@ void shouldUpdateModificationCount() {

@Test
void shouldUpdateModificationCountOptLock() {
String searchConfigId = "1";
String searchConfigId = "c1";

String application = "support-tool-ui";
String name = "criteria-name";
Expand Down Expand Up @@ -208,7 +208,7 @@ void shouldUpdateModificationCountOptLock() {

@Test
void shouldNotUpdateSearchConfigWhenBadRequest() {
String configId = "1";
String configId = "c1";

given()
.contentType(APPLICATION_JSON)
Expand Down Expand Up @@ -242,20 +242,38 @@ void shouldNotUpdateSearchConfigNotExists() {
}

@Test
void shouldDeleteById() {
String configId = "1";
void shouldDeleteByConfigId() {
String configId = "c1";

given()
.contentType(APPLICATION_JSON)
.get(configId)
.then()
.statusCode(OK.getStatusCode());

given()
.contentType(APPLICATION_JSON)
.delete(configId)
.then()
.statusCode(NO_CONTENT.getStatusCode());

given()
.contentType(APPLICATION_JSON)
.get(configId)
.then()
.statusCode(NOT_FOUND.getStatusCode());
}

@Test
void shouldNotDeleteWhenNotExists() {
String configId = "NotExists";

given()
.contentType(APPLICATION_JSON)
.get(configId)
.then()
.statusCode(NOT_FOUND.getStatusCode());

given()
.contentType(APPLICATION_JSON)
.delete(configId)
Expand All @@ -270,7 +288,7 @@ void shouldFindByCriteria() {
var requestBody = new SearchConfigSearchRequestDTOV1()
.productName("productName1").appId(application).page("page2");

String[] expectedIds = { "3", "4" };
String[] expectedIds = { "c3", "c4" };

var responseDTO = given()
.contentType(APPLICATION_JSON)
Expand Down Expand Up @@ -344,7 +362,7 @@ void shouldFindOneResultByCriteria() {
assertThat(responseDTO.getStream()).isNotNull().isNotEmpty().hasSize(2);
List<SearchConfigSearchResultDTOV1> configs = responseDTO.getStream();

assertThat(configs.stream().map(SearchConfigSearchResultDTOV1::getConfigId).toList()).contains("2", "1");
assertThat(configs.stream().map(SearchConfigSearchResultDTOV1::getConfigId).toList()).contains("c2", "c1");
}

@Test
Expand Down
16 changes: 8 additions & 8 deletions src/test/resources/search-config-data.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<!-- search_config -->
<search_config guid='1' config_id='1' optlock='0' product_name='productName1' appId='support-tool-ui' page='page1' name='test' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='2' config_id='2' optlock='0' product_name='productName1' appId='support-tool-ui' page='page1' name='name1' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='3' config_id='3' optlock='0' product_name='productName1' appId='support-tool-ui' page='page2' name='name2' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='4' config_id='4' optlock='0' product_name='productName1' appId='support-tool-ui' page='page2' name='name3' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='5' config_id='5' optlock='0' product_name='productName2' appId='task-list-ui' page='task-page1' name='test' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='6' config_id='6' optlock='0' product_name='productName2' appId='task-list-ui' page='task-page1' name='name1' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='7' config_id='7' optlock='0' product_name='productName3' appId='task-list-ui' page='task-page2' name='name2' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='8' config_id='8' optlock='0' product_name='productName3' appId='task-list-ui' page='task-page2' name='name3' tenant_id='tenant-200' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='1' config_id='c1' optlock='0' product_name='productName1' appId='support-tool-ui' page='page1' name='test' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='2' config_id='c2' optlock='0' product_name='productName1' appId='support-tool-ui' page='page1' name='name1' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='3' config_id='c3' optlock='0' product_name='productName1' appId='support-tool-ui' page='page2' name='name2' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='4' config_id='c4' optlock='0' product_name='productName1' appId='support-tool-ui' page='page2' name='name3' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='5' config_id='c5' optlock='0' product_name='productName2' appId='task-list-ui' page='task-page1' name='test' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='6' config_id='c6' optlock='0' product_name='productName2' appId='task-list-ui' page='task-page1' name='name1' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='7' config_id='c7' optlock='0' product_name='productName3' appId='task-list-ui' page='task-page2' name='name2' tenant_id='tenant-100' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>
<search_config guid='8' config_id='c8' optlock='0' product_name='productName3' appId='task-list-ui' page='task-page2' name='name3' tenant_id='tenant-200' fieldlistversion='2' values='{&quot;additionalProp1&quot;:&quot;name&quot;,&quot;additionalProp2&quot;:&quot;surname&quot;,&quot;additionalProp3&quot;:&quot;address&quot;}' read_only='FALSE' advanced='TRUE' columns='[&quot;name&quot;,&quot;surname&quot;,&quot;address&quot;]'/>

</dataset>
Loading