From bb5d51c067a8f16afe8355597138ec8a7e0bcc7e Mon Sep 17 00:00:00 2001 From: Benjamin POCHAT Date: Wed, 7 Feb 2024 20:45:38 +0100 Subject: [PATCH] fix compilation error --- .../service/TestCustomerService.java | 18 ++++-------------- .../service/TestProducerService.java | 12 ++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/backend/app/src/test/java/eu/viandeendirect/service/TestCustomerService.java b/backend/app/src/test/java/eu/viandeendirect/service/TestCustomerService.java index d3939b1..8ae8022 100644 --- a/backend/app/src/test/java/eu/viandeendirect/service/TestCustomerService.java +++ b/backend/app/src/test/java/eu/viandeendirect/service/TestCustomerService.java @@ -12,8 +12,6 @@ import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit.jupiter.SpringExtension; -import java.util.List; - import static org.assertj.core.api.Assertions.*; import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.AFTER_TEST_METHOD; import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TEST_METHOD; @@ -25,6 +23,9 @@ @Sql(value = {"/sql/delete_test_data.sql"}, executionPhase = AFTER_TEST_METHOD) class TestCustomerService { + @Autowired + ProducerService producerService; + @Autowired CustomerService customerService; @@ -60,15 +61,4 @@ void createCustomer_should_persist_customer_and_user_in_database() { assertThat(reloadedUser.getLastName()).isEqualTo("YORK"); assertThat(reloadedUser.getPhone()).isEqualTo("0609080706"); } - - @Test - void getCustomers_should_return_all_customers_with_orders_related_to_current_producer() { - // when - List customers = customerService.getCustomers().getBody(); - - // then - assertThat(customers).hasSize(1); - Customer customer1 = customers.get(0); - assertThat(customer1.getId().longValue()).isEqualTo(3000); - } -} \ No newline at end of file +} diff --git a/backend/app/src/test/java/eu/viandeendirect/service/TestProducerService.java b/backend/app/src/test/java/eu/viandeendirect/service/TestProducerService.java index 56aef3d..be8e666 100644 --- a/backend/app/src/test/java/eu/viandeendirect/service/TestProducerService.java +++ b/backend/app/src/test/java/eu/viandeendirect/service/TestProducerService.java @@ -1,5 +1,6 @@ package eu.viandeendirect.service; +import eu.viandeendirect.model.Customer; import eu.viandeendirect.model.Producer; import eu.viandeendirect.model.Sale; import eu.viandeendirect.repository.SaleRepository; @@ -88,4 +89,15 @@ void createProducerSale_should_raise_an_error_if_creating_a_sale_for_another_pro // then assertThat(status).isEqualTo(HttpStatusCode.valueOf(403)); } + + @Test + void getProducerCustomers_should_return_all_customers_with_orders_related_to_current_producer() { + // when + List customers = producerService.getProducerCustomers(1000).getBody(); + + // then + assertThat(customers).hasSize(1); + Customer customer1 = customers.get(0); + assertThat(customer1.getId().longValue()).isEqualTo(3000); + } }