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

feat: add getByConfigId to v1 #7

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 @@ -49,6 +49,15 @@ public Response createSearchConfig(CreateSearchConfigRequestDTOV1 createSearchCo
.build();
}

@Override
public Response getConfigByConfigId(String configId) {
var searchConfig = dao.findByConfigId(configId);
if (searchConfig == null) {
return Response.status(NOT_FOUND).build();
}
return Response.ok().entity(mapper.map(searchConfig)).build();
}

@Override
public Response deleteSearchConfig(String configId) {
var data = dao.findByConfigId(configId);
Expand Down
21 changes: 21 additions & 0 deletions src/main/openapi/search-config-openapi-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ paths:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/v1/searchConfig/{configId}:
get:
tags:
- SearchConfig
summary: Finds search config by it's configId.
description: Gets the search config by it's configId.
operationId: getConfigByConfigId
parameters:
- name: configId
in: path
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/SearchConfig'
"404":
description: Not found
put:
tags:
- SearchConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.tkit.onecx.search.config.test.AbstractTest;
import org.tkit.quarkus.test.WithDBData;

import gen.org.tkit.onecx.search.config.rs.internal.model.SearchConfigDTO;
import gen.org.tkit.onecx.search.config.v1.model.*;
import io.quarkus.test.common.http.TestHTTPEndpoint;
import io.quarkus.test.junit.QuarkusTest;
Expand All @@ -37,6 +38,30 @@ private List<String> setupColumns() {
return columns;
}

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

var dto = given()
.contentType(APPLICATION_JSON)
.header(APM_HEADER_PARAM, createToken("org1", null))
.get(configId)
.then()
.statusCode(OK.getStatusCode())
.extract()
.body().as(SearchConfigDTO.class);

assertThat(dto).isNotNull();
assertThat(dto.getAppId()).isEqualTo("support-tool-ui");

given()
.contentType(APPLICATION_JSON)
.header(APM_HEADER_PARAM, createToken("org2", null))
.get(configId)
.then()
.statusCode(NOT_FOUND.getStatusCode());
}

@Test
void shouldCreateSearchConfig() {
String productName = "productName1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import gen.org.tkit.onecx.search.config.rs.internal.model.CreateSearchConfigRequestDTO;
import gen.org.tkit.onecx.search.config.rs.internal.model.ProblemDetailResponseDTO;
import gen.org.tkit.onecx.search.config.rs.internal.model.SearchConfigDTO;
import gen.org.tkit.onecx.search.config.v1.model.*;
import io.quarkus.test.common.http.TestHTTPEndpoint;
import io.quarkus.test.junit.QuarkusTest;
Expand All @@ -39,6 +40,22 @@ private List<String> setupColumns() {
return columns;
}

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

var dto = given()
.contentType(APPLICATION_JSON)
.get(configId)
.then()
.statusCode(OK.getStatusCode())
.extract()
.body().as(SearchConfigDTO.class);

assertThat(dto).isNotNull();
assertThat(dto.getAppId()).isEqualTo("support-tool-ui");
}

@Test
void shouldCreateSearchConfig() {
String productName = "productName1";
Expand Down
Loading