Skip to content

Commit

Permalink
fix compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpochat committed Feb 7, 2024
1 parent 88cd572 commit bb5d51c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,6 +23,9 @@
@Sql(value = {"/sql/delete_test_data.sql"}, executionPhase = AFTER_TEST_METHOD)
class TestCustomerService {

@Autowired
ProducerService producerService;

@Autowired
CustomerService customerService;

Expand Down Expand Up @@ -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<Customer> customers = customerService.getCustomers().getBody();

// then
assertThat(customers).hasSize(1);
Customer customer1 = customers.get(0);
assertThat(customer1.getId().longValue()).isEqualTo(3000);
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Customer> customers = producerService.getProducerCustomers(1000).getBody();

// then
assertThat(customers).hasSize(1);
Customer customer1 = customers.get(0);
assertThat(customer1.getId().longValue()).isEqualTo(3000);
}
}

0 comments on commit bb5d51c

Please sign in to comment.