Skip to content

Commit

Permalink
fixing the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jurabek committed Jul 13, 2024
1 parent c4b9c6f commit bac9e4f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public void getShouldReturnData(){
mockResults.add(new OrderDto());
mockResults.add(new OrderDto());

when(ordersService.getAll()).thenReturn(mockResults);
List<OrderDto> result = ordersController.getData();
when(ordersService.getAll(0, 10)).thenReturn(mockResults);
List<OrderDto> result = ordersController.getData(0, 10);
Assertions.assertEquals(mockResults, result);
verify(ordersService, times(1)).getAll();
verify(ordersService, times(1)).getAll(0, 10);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.jurabek.restaurant.order.api.models.OrderItems;
import org.jurabek.restaurant.order.api.repositories.OrdersRepository;


import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.mockito.InjectMock;
import jakarta.inject.Inject;
Expand All @@ -42,17 +41,17 @@ public void setup() {

// @Test
// public void CreateShouldCreateWhenCustomerBasketDto() {
// var customerBasketDto = new CustomerBasket();
// var order = new Order();
// var orderItems = new ArrayList<OrderItems>();
// orderItems.add(new OrderItems());
// order.setOrderItems(orderItems);
// var customerBasketDto = new CustomerBasket();
// var order = new Order();
// var orderItems = new ArrayList<OrderItems>();
// orderItems.add(new OrderItems());
// order.setOrderItems(orderItems);

// when(mapper.mapDtoToOrder(customerBasketDto)).thenReturn(order);
// when(mapper.mapDtoToOrder(customerBasketDto)).thenReturn(order);

// ordersService.Create(customerBasketDto);
// ordersService.Create(customerBasketDto);

// verify(ordersRepository, times(1)).persist(order);
// verify(ordersRepository, times(1)).persist(order);
// }

@Test
Expand All @@ -62,10 +61,10 @@ public void GetAllShouldReturnAllOrderDtos() {

var dto = new OrderDto();

when(ordersRepository.fetchAll()).thenReturn(orders);
when(ordersRepository.fetchAll(0, 10)).thenReturn(orders);
when(mapper.mapOrderToDto(order)).thenReturn(dto);

List<OrderDto> result = ordersService.getAll();
List<OrderDto> result = ordersService.getAll(0, 10);

Assertions.assertEquals(1, result.size());
Assertions.assertEquals(result.get(0), dto);
Expand Down

0 comments on commit bac9e4f

Please sign in to comment.