Skip to content

Commit

Permalink
feat: updated api (#22)
Browse files Browse the repository at this point in the history
* feat: updated api

* fix: test
  • Loading branch information
JordenReuter authored May 29, 2024
1 parent 4622a6b commit ee2c737
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,38 +59,38 @@ h| Version
| tkit-quarkus-log-cdi
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-cdi.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.23.0
| tkit-quarkus-log-rs
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-rs.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.23.0
| tkit-quarkus-log-json
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-json.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.23.0
| tkit-quarkus-rest
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link]
| 2.23.0
| tkit-quarkus-rest-context
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest-context.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link]
| 2.23.0
| tkit-quarkus-jpa
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-jpa.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa.adoc[Link]
| 2.23.0
| quarkus-hibernate-validator
Expand Down Expand Up @@ -119,8 +119,8 @@ h| Version
| tkit-quarkus-security
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-security.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.22.0
| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.23.0
| onecx-core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public Response deleteImageInfoById(String id) {
}

@Override
public Response getAllImageInfos() {
try (Response response = welcomeClient.getAllImageInfos()) {
public Response getAllImageInfosByWorkspaceName(String workspaceName) {
try (Response response = welcomeClient.getAllImageInfosByWorkspaceName(workspaceName)) {
List<ImageInfoDTO> infoList = mapper.map(Arrays.stream(response.readEntity(ImageInfo[].class)).toList());
return Response.status(response.getStatus()).entity(infoList).build();
}
Expand Down
15 changes: 13 additions & 2 deletions src/main/openapi/openapi-bff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,22 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/images/{workspaceName}/info:
get:
x-onecx:
permissions:
image:
- read
tags:
- imagesInternal
description: get all existing Image informations
operationId: getAllImageInfos
description: get all existing Image informations by workspace name
operationId: getAllImageInfosByWorkspaceName
parameters:
- in: path
name: workspaceName
schema:
type: string
required: true
responses:
"200":
description: OK
Expand Down Expand Up @@ -259,6 +266,8 @@ components:
modificationUser:
type: string
ImageInfo:
required:
- workspaceName
type: object
properties:
position:
Expand All @@ -282,6 +291,8 @@ components:
$ref: '#/components/schemas/OffsetDateTime'
modificationUser:
type: string
workspaceName:
type: string
ImageInfoReorderRequest:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ void createImageInfoTest() {
ImageInfo info = new ImageInfo();
info.setUrl("someUrl");
info.setPosition("1");
info.setWorkspaceName("w1");

// create mock rest endpoint
mockServerClient.when(request().withPath("/internal/images/info").withMethod(HttpMethod.POST)
Expand All @@ -162,6 +163,7 @@ void createImageInfoTest() {
ImageInfoDTO infoDTO = new ImageInfoDTO();
infoDTO.setPosition("1");
infoDTO.setUrl("someUrl");
infoDTO.setWorkspaceName("w1");

var output = given()
.when()
Expand Down Expand Up @@ -234,6 +236,7 @@ void updateImageInfoByIdTest() {
ImageInfo info = new ImageInfo();
info.setUrl("someUrl");
info.setPosition("1");
info.setWorkspaceName("w1");

// create mock rest endpoint
mockServerClient.when(request().withPath("/internal/images/info/11-111").withMethod(HttpMethod.PUT)
Expand All @@ -247,6 +250,7 @@ void updateImageInfoByIdTest() {
ImageInfoDTO infoDTO = new ImageInfoDTO();
infoDTO.setPosition("1");
infoDTO.setUrl("someUrl");
infoDTO.setWorkspaceName("w1");

var output = given()
.when()
Expand All @@ -270,10 +274,12 @@ void updateOrderTest() {
info.setUrl("someUrl");
info.setPosition("1");
info.setId("11-111");
info.setWorkspaceName("w1");
ImageInfo info2 = new ImageInfo();
info2.setUrl("someUrl");
info2.setPosition("2");
info2.setId("22-222");
info2.setWorkspaceName("w1");

// create mock rest endpoint
mockServerClient.when(request().withPath("/internal/images/info/11-111").withMethod(HttpMethod.PUT)
Expand All @@ -297,11 +303,13 @@ void updateOrderTest() {
infoDTO.setPosition("1");
infoDTO.setUrl("someUrl");
infoDTO.setId("11-111");
infoDTO.setWorkspaceName("w1");

ImageInfoDTO info2DTO = new ImageInfoDTO();
info2DTO.setPosition("2");
info2DTO.setUrl("someUrl");
info2DTO.setId("22-222");
info2DTO.setWorkspaceName("w1");

ImageInfoReorderRequestDTO reorderRequestDTO = new ImageInfoReorderRequestDTO();
reorderRequestDTO.setImageInfos(List.of(infoDTO, info2DTO));
Expand Down Expand Up @@ -334,6 +342,21 @@ void updateOrderWithEmptyBodyTest() {
.statusCode(BAD_REQUEST.getStatusCode());
}

@Test
void updateOrderWithMissingBodyTest() {
ImageInfoReorderRequestDTO reorderRequestDTO = new ImageInfoReorderRequestDTO();
reorderRequestDTO.setImageInfos(List.of());

given()
.when()
.auth().oauth2(keycloakClient.getAccessToken(ADMIN))
.header(APM_HEADER_PARAM, ADMIN)
.contentType(APPLICATION_JSON)
.post("/info/reorder")
.then()
.statusCode(BAD_REQUEST.getStatusCode());
}

@Test
void deleteImageInfoByIdTest() {

Expand All @@ -357,18 +380,20 @@ void getAllImageInfosTest() {
List<ImageInfo> infos = new ArrayList<>();
ImageInfo info = new ImageInfo();
info.setImageId("111");
info.setWorkspaceName("w1");
infos.add(info);

// create mock rest endpoint
mockServerClient.when(request().withPath("/internal/images/info").withMethod(HttpMethod.GET))
mockServerClient.when(request().withPath("/internal/images/w1/info").withMethod(HttpMethod.GET))
.withId(mockId)
.respond(httpRequest -> response().withStatusCode(Response.Status.OK.getStatusCode())
.withContentType(MediaType.APPLICATION_JSON)
.withBody(JsonBody.json(infos)));
var output = given()
.auth().oauth2(keycloakClient.getAccessToken(ADMIN))
.header(APM_HEADER_PARAM, ADMIN)
.get("/info")
.pathParam("workspaceName", "w1")
.get("/{workspaceName}/info")
.then()
.contentType(APPLICATION_JSON)
.extract().as(ImageInfoDTO[].class);
Expand Down

0 comments on commit ee2c737

Please sign in to comment.