Skip to content

Commit 03601ae

Browse files
author
soonann
committed
Merge branch 'development'
2 parents 030a886 + a2ca060 commit 03601ae

File tree

5 files changed

+56
-4
lines changed

5 files changed

+56
-4
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package me.plantngo.backend.config;
2+
3+
import java.util.List;
4+
5+
import org.springframework.boot.CommandLineRunner;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
9+
import me.plantngo.backend.models.Customer;
10+
import me.plantngo.backend.models.Preference;
11+
import me.plantngo.backend.repositories.CustomerRepository;
12+
13+
@Configuration
14+
public class SampleDataConfig {
15+
16+
@Bean
17+
CommandLineRunner commandLineRunner(CustomerRepository customerRepository) {
18+
return args -> {
19+
Preference preference = new Preference();
20+
21+
Customer cust1 = new Customer(
22+
null,
23+
"soonann",
24+
"soonann@example.com",
25+
"Password123!",
26+
null,
27+
0,
28+
null,
29+
null,
30+
null);
31+
Customer cust2 = new Customer(
32+
null,
33+
"gabriel",
34+
"gabriel@example.com",
35+
"Password123!",
36+
null,
37+
0,
38+
null,
39+
null,
40+
null);
41+
42+
customerRepository.saveAll(List.of(cust1, cust2));
43+
44+
};
45+
}
46+
}

src/main/java/me/plantngo/backend/models/Order.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
@NoArgsConstructor
2828
@EqualsAndHashCode
2929
@Entity
30-
@Table(name = "order")
30+
@Table(name = "ordering")
3131
public class Order {
3232
@Id
3333
@GeneratedValue(strategy = GenerationType.IDENTITY)
3434
private Integer id;
3535

3636
@NotNull
37-
@Column(name = "Orders_Customer_Id")
37+
@Column(name = "ordering_customer_id")
3838
private Integer customer_Id;
3939

4040
private Double totalPrice;

src/main/java/me/plantngo/backend/models/OrderItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@NoArgsConstructor
2323
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
2424
@Entity
25-
@Table(name = "order_items")
25+
@Table(name = "order_item")
2626
public class OrderItem {
2727

2828
@Id

src/main/java/me/plantngo/backend/models/Product.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class Product {
6868
private List<OrderItem> orderItem;
6969

7070
@ManyToMany
71-
@JoinTable(name = "product_promotions", joinColumns = @JoinColumn(name = "product_id"), inverseJoinColumns = @JoinColumn(name = "promotions_id"))
71+
@JoinTable(name = "product_promotion", joinColumns = @JoinColumn(name = "product_id"), inverseJoinColumns = @JoinColumn(name = "promotion_id"))
7272
private Set<Promotion> productPromotions;
7373

7474
}

src/test/java/me/plantngo/backend/controllers/CustomerControllerTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.List;
1010

1111
import org.junit.jupiter.api.AfterEach;
12+
import org.junit.jupiter.api.BeforeEach;
1213
import org.junit.jupiter.api.Test;
1314
import org.junit.jupiter.api.extension.ExtendWith;
1415
import org.springframework.beans.factory.annotation.Autowired;
@@ -50,6 +51,11 @@ void tearDown() {
5051
customerRepository.deleteAll();
5152
}
5253

54+
@BeforeEach
55+
void setUp() {
56+
customerRepository.deleteAll();
57+
}
58+
5359
@Test
5460
void testGetAllUsers_CustomersExist_CustomerList() throws Exception {
5561

0 commit comments

Comments
 (0)