Skip to content

Commit

Permalink
fix : junit and polish swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli authored Oct 7, 2023
1 parent 9302536 commit bc55ee6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,50 @@ Licensed under MIT License Copyright (c) 2023 Raja Kolli.
import com.example.orderservice.utils.AppConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import org.springframework.http.MediaType;
import org.springframework.http.ProblemDetail;
import org.springframework.validation.annotation.Validated;

@Validated
@Tag(name = "order-controller", description = "the order-controller API")
public interface OrderApi {

@Operation(summary = "fetches all orders from Kinesis Stream")
@Operation(
summary = "fetches all orders from kafka Streams",
tags = {"order-controller"},
responses = {
@ApiResponse(
responseCode = "200",
description = "Success",
content = {
@Content(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = OrderDto.class))
}),
@ApiResponse(
responseCode = "400",
description = "Bad Request",
content = {
@Content(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ProblemDetail.class))
})
})
List<OrderDto> all(
@Parameter(name = "pageNo", example = AppConstants.DEFAULT_PAGE_SIZE) int pageNo,
@Parameter(name = "pageSize", example = AppConstants.DEFAULT_PAGE_SIZE) int pageSize);
@Parameter(
name = "pageNo",
example = AppConstants.DEFAULT_PAGE_SIZE,
in = ParameterIn.QUERY)
int pageNo,
@Parameter(
name = "pageSize",
example = AppConstants.DEFAULT_PAGE_SIZE,
in = ParameterIn.QUERY)
int pageSize);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ Licensed under MIT License Copyright (c) 2021-2023 Raja Kolli.
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.doNothing;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.example.orderservice.entities.Order;
import com.example.orderservice.model.request.OrderItemRequest;
Expand Down Expand Up @@ -234,7 +239,8 @@ void shouldUpdateOrder() throws Exception {
void shouldReturn404WhenUpdatingNonExistingOrder() throws Exception {
Long orderId = 1L;
given(orderService.findOrderById(orderId)).willReturn(Optional.empty());
OrderRequest order = new OrderRequest(1L, new ArrayList<>());
OrderRequest order =
new OrderRequest(1L, List.of(new OrderItemRequest("Product1", 10, BigDecimal.TEN)));

this.mockMvc
.perform(
Expand Down

0 comments on commit bc55ee6

Please sign in to comment.