Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
Orders
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Vladimir Trubachoff
Orders
Commits
9aba07ea
Commit
9aba07ea
authored
Jul 25, 2024
by
Vladimir Trubachoff
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'add-tests' into develop
parents
7c7f55d1
ec405098
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
260 additions
and
126 deletions
+260
-126
Order.java
src/main/java/com/example/testj/domain/Order.java
+4
-2
OrderLine.java
src/main/java/com/example/testj/domain/OrderLine.java
+3
-3
ApiError.java
src/main/java/com/example/testj/exception/ApiError.java
+39
-0
RestResponseEntityExceptionHandler.java
...e/testj/exception/RestResponseEntityExceptionHandler.java
+55
-0
OrderDto.java
src/main/java/com/example/testj/service/dto/OrderDto.java
+10
-3
data.sql
src/main/resources/data.sql
+108
-100
OrderRepositoryTest.java
...ava/com/example/testj/repository/OrderRepositoryTest.java
+3
-2
OrderLineServiceTest.java
.../java/com/example/testj/service/OrderLineServiceTest.java
+2
-1
OrderServiceTest.java
...test/java/com/example/testj/service/OrderServiceTest.java
+7
-6
GoodsControllerTest.java
.../java/com/example/testj/web/rest/GoodsControllerTest.java
+4
-1
OrderControllerTest.java
.../java/com/example/testj/web/rest/OrderControllerTest.java
+25
-8
No files found.
src/main/java/com/example/testj/domain/Order.java
View file @
9aba07ea
...
@@ -2,12 +2,14 @@ package com.example.testj.domain;
...
@@ -2,12 +2,14 @@ package com.example.testj.domain;
import
jakarta.persistence.*
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.NotBlank
;
import
jakarta.validation.constraints.NotBlank
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.Setter
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -27,10 +29,10 @@ public class Order {
...
@@ -27,10 +29,10 @@ public class Order {
@Column
(
name
=
"client"
)
@Column
(
name
=
"client"
)
private
String
client
;
private
String
client
;
@Not
Blank
@Not
Null
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
@Column
(
name
=
"date"
)
@Column
(
name
=
"date"
)
private
String
date
;
private
LocalDate
date
;
@NotBlank
@NotBlank
@Column
(
name
=
"address"
)
@Column
(
name
=
"address"
)
...
...
src/main/java/com/example/testj/domain/OrderLine.java
View file @
9aba07ea
...
@@ -22,19 +22,19 @@ public class OrderLine {
...
@@ -22,19 +22,19 @@ public class OrderLine {
@Column
(
name
=
"id"
)
@Column
(
name
=
"id"
)
private
Long
id
;
private
Long
id
;
@NotNull
@JsonIgnore
@JsonIgnore
@ManyToOne
@ManyToOne
@JoinColumn
(
name
=
"order_id"
)
@JoinColumn
(
name
=
"order_id"
)
@NotNull
private
Order
order
;
private
Order
order
;
@NotNull
@ManyToOne
@ManyToOne
@JoinColumn
(
name
=
"goods_id"
)
@JoinColumn
(
name
=
"goods_id"
)
@NotNull
private
Goods
goods
;
private
Goods
goods
;
@Column
(
name
=
"count"
)
@NumberFormat
@NumberFormat
@Min
(
1
)
@Min
(
1
)
@Column
(
name
=
"count"
)
private
int
count
;
private
int
count
;
}
}
src/main/java/com/example/testj/exception/ApiError.java
0 → 100644
View file @
9aba07ea
package
com
.
example
.
testj
.
exception
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.springframework.http.HttpStatus
;
import
java.util.*
;
@Getter
@Setter
public
class
ApiError
{
private
final
Date
timestamp
;
private
HttpStatus
status
;
private
String
message
;
private
List
<
Map
<
String
,
String
>>
errors
;
public
ApiError
()
{
timestamp
=
new
Date
();
}
public
ApiError
(
HttpStatus
status
,
String
message
,
List
<
Map
<
String
,
String
>>
errors
)
{
super
();
timestamp
=
new
Date
();
this
.
status
=
status
;
this
.
message
=
message
;
this
.
errors
=
errors
;
}
public
ApiError
(
HttpStatus
status
,
String
message
,
String
error
)
{
super
();
timestamp
=
new
Date
();
this
.
status
=
status
;
this
.
message
=
message
;
errors
=
new
ArrayList
<>((
Collection
)
Map
.
of
(
"message"
,
error
));
}
}
\ No newline at end of file
src/main/java/com/example/testj/exception/RestResponseEntityExceptionHandler.java
0 → 100644
View file @
9aba07ea
package
com
.
example
.
testj
.
exception
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatusCode
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.converter.HttpMessageNotReadableException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.context.request.WebRequest
;
import
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
;
import
java.time.format.DateTimeParseException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@ControllerAdvice
public
class
RestResponseEntityExceptionHandler
extends
ResponseEntityExceptionHandler
{
@ExceptionHandler
({
DateTimeParseException
.
class
})
public
ResponseEntity
<
Object
>
handleDateTimeParseException
(
Exception
ex
,
WebRequest
request
)
{
List
<
Map
<
String
,
String
>>
errors
=
List
.
of
(
Map
.
of
(
"field"
,
"date"
,
"message"
,
ex
.
getMessage
()));
ApiError
body
=
new
ApiError
(
HttpStatus
.
BAD_REQUEST
,
"Date parse error"
,
errors
);
return
new
ResponseEntity
<>(
body
,
new
HttpHeaders
(),
HttpStatus
.
BAD_REQUEST
);
}
// 500
@ExceptionHandler
({
Exception
.
class
})
public
ResponseEntity
<
Object
>
handleAll
(
Exception
ex
,
WebRequest
request
)
{
final
ApiError
apiError
=
new
ApiError
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
ex
.
getLocalizedMessage
(),
"error occurred"
);
return
new
ResponseEntity
<>(
apiError
,
new
HttpHeaders
(),
apiError
.
getStatus
());
}
protected
ResponseEntity
<
Object
>
handleMethodArgumentNotValid
(
MethodArgumentNotValidException
ex
,
HttpHeaders
headers
,
HttpStatusCode
status
,
WebRequest
request
)
{
//Get all fields errors
List
<
Map
<
String
,
String
>>
errors
=
ex
.
getBindingResult
()
.
getFieldErrors
()
.
stream
()
.
map
(
err
->
Map
.
of
(
"field"
,
err
.
getField
(),
"message"
,
err
.
getDefaultMessage
()))
.
collect
(
Collectors
.
toList
());
ApiError
body
=
new
ApiError
(
HttpStatus
.
BAD_REQUEST
,
ex
.
getBody
().
getDetail
(),
errors
);
return
handleExceptionInternal
(
ex
,
body
,
headers
,
status
,
request
);
}
protected
ResponseEntity
<
Object
>
handleHttpMessageNotReadable
(
HttpMessageNotReadableException
ex
,
HttpHeaders
headers
,
HttpStatusCode
status
,
WebRequest
request
)
{
ApiError
body
=
new
ApiError
(
HttpStatus
.
BAD_REQUEST
,
ex
.
getMessage
(),
new
ArrayList
<>());
return
handleExceptionInternal
(
ex
,
body
,
headers
,
status
,
request
);
}
}
src/main/java/com/example/testj/service/dto/OrderDto.java
View file @
9aba07ea
package
com
.
example
.
testj
.
service
.
dto
;
package
com
.
example
.
testj
.
service
.
dto
;
import
jakarta.validation.constraints.NotBlank
;
import
jakarta.validation.constraints.NotBlank
;
import
lombok.*
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.time.LocalDate
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -19,8 +25,9 @@ public class OrderDto implements Serializable {
...
@@ -19,8 +25,9 @@ public class OrderDto implements Serializable {
@NotBlank
@NotBlank
private
String
client
;
private
String
client
;
@NotBlank
@NotNull
private
String
date
;
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
private
LocalDate
date
;
@NotBlank
@NotBlank
private
String
address
;
private
String
address
;
...
...
src/main/resources/data.sql
View file @
9aba07ea
...
@@ -10,581 +10,589 @@ values
...
@@ -10,581 +10,589 @@ values
(
(
1
,
1
,
'Griz Soppit'
,
'Griz Soppit'
,
'
1/8/2023
'
,
'
2023-08-01
'
,
'4 Fieldstone Pass'
'4 Fieldstone Pass'
),
),
(
2
,
'Lorain Kroin'
,
'2/23/2024'
,
'3 Boyd Hill'
),
(
2
,
'Lorain Kroin'
,
'2024-03-02'
,
'3 Boyd Hill'
),
(
(
3
,
3
,
'Benedikta Earry'
,
'Benedikta Earry'
,
'
12/2/2023
'
,
'
2023-02-12
'
,
'9 Ridge Oak Road'
'9 Ridge Oak Road'
),
),
(
(
4
,
4
,
'Viola Airdrie'
,
'Viola Airdrie'
,
'
7/6/2023
'
,
'
2023-06-07
'
,
'587 Sloan Drive'
'587 Sloan Drive'
),
),
(
(
5
,
5
,
'Tedmund Yukhin'
,
'Tedmund Yukhin'
,
'
1/9/2024
'
,
'
2024-09-01
'
,
'1 Northport Trail'
'1 Northport Trail'
),
),
(
(
6
,
6
,
'Niki Thibodeaux'
,
'Niki Thibodeaux'
,
'
1/5/2024
'
,
'
2024-05-01
'
,
'734 Vera Point'
'734 Vera Point'
),
),
(
(
7
,
7
,
'Sheri Habershaw'
,
'Sheri Habershaw'
,
'
5/5/2024
'
,
'
2024-05-05
'
,
'7689 Melrose Center'
'7689 Melrose Center'
),
),
(
(
8
,
8
,
'Coral Dellatorre'
,
'Coral Dellatorre'
,
'
7/8/2023
'
,
'
2023-08-07
'
,
'95 Onsgard Junction'
'95 Onsgard Junction'
),
),
(
(
9
,
9
,
'Leisha Barnicott'
,
'Leisha Barnicott'
,
'
3/5/2024
'
,
'
2024-05-03
'
,
'945 Hanover Park'
'945 Hanover Park'
),
),
(
(
10
,
10
,
'Dukie Yushin'
,
'Dukie Yushin'
,
'
4/11/202
4'
,
'
2024-11-0
4'
,
'9 Tennyson Junction'
'9 Tennyson Junction'
),
),
(
(
11
,
11
,
'Toni Lenchenko'
,
'Toni Lenchenko'
,
'2
/6/2024
'
,
'2
024-06-02
'
,
'83 Jenifer Lane'
'83 Jenifer Lane'
),
),
(
(
12
,
12
,
'Ynez Moncreiff'
,
'Ynez Moncreiff'
,
'
5/2/2024
'
,
'
2024-02-05
'
,
'4182 Sutteridge Parkway'
'4182 Sutteridge Parkway'
),
),
(
(
13
,
13
,
'Forrest Schiersch'
,
'Forrest Schiersch'
,
'
10/10/2023
'
,
'
2023-10-10
'
,
'3 Anderson Center'
'3 Anderson Center'
),
),
(
(
14
,
14
,
'Franky Ply'
,
'Franky Ply'
,
'
3/6/2024
'
,
'
2024-06-03
'
,
'037 Heffernan Drive'
'037 Heffernan Drive'
),
),
(
(
15
,
15
,
'Shel Aykroyd'
,
'Shel Aykroyd'
,
'
6/8/2023
'
,
'
2023-08-06
'
,
'53 Del Mar Terrace'
'53 Del Mar Terrace'
),
),
(
(
16
,
16
,
'Peyter Colegate'
,
'Peyter Colegate'
,
'2
/8/2024
'
,
'2
024-08-02
'
,
'55889 Haas Point'
'55889 Haas Point'
),
),
(
(
17
,
17
,
'Garald Blunsden'
,
'Garald Blunsden'
,
'
9/3/2023
'
,
'
2023-03-09
'
,
'7 Acker Drive'
'7 Acker Drive'
),
),
(
(
18
,
18
,
'Carree Yakunkin'
,
'Carree Yakunkin'
,
'
4/9/202
4'
,
'
2024-09-0
4'
,
'40 Transport Court'
'40 Transport Court'
),
),
(
(
19
,
19
,
'Even Axleby'
,
'Even Axleby'
,
'
9/12/2023
'
,
'
2023-12-09
'
,
'087 Bonner Hill'
'087 Bonner Hill'
),
),
(
(
20
,
20
,
'Birch Cobelli'
,
'Birch Cobelli'
,
'
9/6/2023
'
,
'
2023-06-09
'
,
'74707 Haas Circle'
'74707 Haas Circle'
),
),
(
(
21
,
21
,
'Lu Malshinger'
,
'Lu Malshinger'
,
'
3/6/2024
'
,
'
2024-06-03
'
,
'667 Tony Junction'
'667 Tony Junction'
),
),
(
(
22
,
22
,
'Hebert Canfer'
,
'Hebert Canfer'
,
'
9/4/2023
'
,
'
2023-04-09
'
,
'829 Rusk Trail'
'829 Rusk Trail'
),
),
(
(
23
,
23
,
'Rickard MacQuarrie'
,
'Rickard MacQuarrie'
,
'
3/7/2024
'
,
'
2024-07-03
'
,
'123 Service Junction'
'123 Service Junction'
),
),
(
(
24
,
24
,
'Alyse Triplow'
,
'Alyse Triplow'
,
'
12/12/2023
'
,
'
2023-12-12
'
,
'51 Jana Junction'
'51 Jana Junction'
),
),
(
(
25
,
25
,
'Cissiee De Angelis'
,
'Cissiee De Angelis'
,
'
1/8/2024
'
,
'
2024-08-01
'
,
'660 Talisman Place'
'660 Talisman Place'
),
),
(
(
26
,
26
,
'Rurik Killshaw'
,
'Rurik Killshaw'
,
'
3/4/2024
'
,
'
2024-04-03
'
,
'3 Dapin Park'
'3 Dapin Park'
),
),
(
(
27
,
27
,
'Carmelle Philler'
,
'Carmelle Philler'
,
'
4/4/202
4'
,
'
2024-04-0
4'
,
'355 Morning Road'
'355 Morning Road'
),
),
(
(
28
,
28
,
'Sara-ann Pook'
,
'Sara-ann Pook'
,
'
3/1/2024
'
,
'
2024-01-03
'
,
'7967 Welch Plaza'
'7967 Welch Plaza'
),
),
(
29
,
'Piper Libero'
,
'
1/3/2024
'
,
'3 Prentice Way'
),
(
29
,
'Piper Libero'
,
'
2024-03-01
'
,
'3 Prentice Way'
),
(
(
30
,
30
,
'Shermy Simonnin'
,
'Shermy Simonnin'
,
'
11/9/2023
'
,
'
2023-09-11
'
,
'44910 Debra Court'
'44910 Debra Court'
),
),
(
(
31
,
31
,
'Ilene Flores'
,
'Ilene Flores'
,
'2
/8/2024
'
,
'2
024-08-02
'
,
'201 Brickson Park Center'
'201 Brickson Park Center'
),
),
(
(
32
,
32
,
'Vonnie Packer'
,
'Vonnie Packer'
,
'
9/11/2023
'
,
'
2023-11-09
'
,
'7 Park Meadow Street'
'7 Park Meadow Street'
),
),
(
(
33
,
33
,
'Armstrong Jessard'
,
'Armstrong Jessard'
,
'
5/3/2024
'
,
'
2024-03-05
'
,
'1 Center Park'
'1 Center Park'
),
),
(
(
34
,
34
,
'Binnie Pearde'
,
'Binnie Pearde'
,
'
5/3/2024
'
,
'
2024-03-05
'
,
'72808 Johnson Place'
'72808 Johnson Place'
),
),
(
(
35
,
35
,
'Rena Gontier'
,
'Rena Gontier'
,
'
6/5/2023
'
,
'
2023-05-06
'
,
'277 Anzinger Terrace'
'277 Anzinger Terrace'
),
),
(
(
36
,
36
,
'Calli Cockshoot'
,
'Calli Cockshoot'
,
'
11/3/2023
'
,
'
2023-03-11
'
,
'23 Glendale Circle'
'23 Glendale Circle'
),
),
(
37
,
'Mariana Kift'
,
'
9/1/2023
'
,
'94 Linden Hill'
),
(
37
,
'Mariana Kift'
,
'
2023-01-09
'
,
'94 Linden Hill'
),
(
(
38
,
38
,
'Celestia Grewe'
,
'Celestia Grewe'
,
'
4/6/202
4'
,
'
2024-06-0
4'
,
'0 Forster Way'
'0 Forster Way'
),
),
(
(
39
,
39
,
'Westbrook Thomsson'
,
'Westbrook Thomsson'
,
'
5/3/2024
'
,
'
2024-03-05
'
,
'097 Mcbride Pass'
'097 Mcbride Pass'
),
),
(
(
40
,
40
,
'Charley Westrip'
,
'Charley Westrip'
,
'
11/8/2023
'
,
'
2023-08-11
'
,
'30327 Moland Alley'
'30327 Moland Alley'
),
),
(
(
41
,
41
,
'Currie Bartosek'
,
'Currie Bartosek'
,
'
1/8/2024
'
,
'
2024-08-01
'
,
'34503 Rockefeller Trail'
'34503 Rockefeller Trail'
),
),
(
(
42
,
42
,
'Quincy Breese'
,
'Quincy Breese'
,
'
11/9/2023
'
,
'
2023-09-11
'
,
'03 Springs Road'
'03 Springs Road'
),
),
(
(
43
,
43
,
'Blaine Giff'
,
'Blaine Giff'
,
'
12/6/2023
'
,
'
2023-06-12
'
,
'0718 Amoth Way'
'0718 Amoth Way'
),
),
(
(
44
,
44
,
'Lemmy Stidworthy'
,
'Lemmy Stidworthy'
,
'
12/2/2023
'
,
'
2023-02-12
'
,
'6258 Cottonwood Crossing'
'6258 Cottonwood Crossing'
),
),
(
(
45
,
45
,
'Feliza Erett'
,
'Feliza Erett'
,
'
3/11/2024
'
,
'
2024-11-03
'
,
'2588 Brentwood Avenue'
'2588 Brentwood Avenue'
),
),
(
(
46
,
46
,
'Massimiliano Bogays'
,
'Massimiliano Bogays'
,
'
10/4/2023
'
,
'
2023-04-10
'
,
'578 Northridge Parkway'
'578 Northridge Parkway'
),
),
(
(
47
,
47
,
'Frannie Droogan'
,
'Frannie Droogan'
,
'
5/11/2024
'
,
'
2024-11-05
'
,
'444 4th Park'
'444 4th Park'
),
),
(
(
48
,
48
,
'Ichabod Goulbourne'
,
'Ichabod Goulbourne'
,
'
9/8/2023
'
,
'
2023-08-09
'
,
'325 Comanche Park'
'325 Comanche Park'
),
),
(
(
49
,
49
,
'Rab Marishenko'
,
'Rab Marishenko'
,
'
9/6/2023
'
,
'
2023-06-09
'
,
'310 Stuart Terrace'
'310 Stuart Terrace'
),
),
(
(
50
,
50
,
'Elinore Healings'
,
'Elinore Healings'
,
'
10/2/2023
'
,
'
2023-02-10
'
,
'4 Clyde Gallagher Terrace'
'4 Clyde Gallagher Terrace'
),
),
(
(
51
,
51
,
'Dorita Batchelder'
,
'Dorita Batchelder'
,
'
5/4/2024
'
,
'
2024-04-05
'
,
'241 Lien Center'
'241 Lien Center'
),
),
(
(
52
,
52
,
'Amandy Ridolfo'
,
'Amandy Ridolfo'
,
'
6/3/2023
'
,
'
2023-03-06
'
,
'8 Muir Court'
'8 Muir Court'
),
),
(
(
53
,
53
,
'Daveta Mantha'
,
'Daveta Mantha'
,
'
8/9/2023
'
,
'
2023-09-08
'
,
'0809 Coolidge Place'
'0809 Coolidge Place'
),
),
(
(
54
,
54
,
'Adolf Ricoald'
,
'Adolf Ricoald'
,
'2
/5/2024
'
,
'2
024-05-02
'
,
'90865 Lawn Park'
'90865 Lawn Park'
),
),
(
(
55
,
55
,
'Ilene Hardey'
,
'Ilene Hardey'
,
'
3/2/2024
'
,
'
2024-02-03
'
,
'72 Redwing Hill'
'72 Redwing Hill'
),
),
(
(
56
,
56
,
'Hortense Settle'
,
'Hortense Settle'
,
'
12/4/2023
'
,
'
2023-04-12
'
,
'488 Lakeland Alley'
'488 Lakeland Alley'
),
),
(
(
57
,
57
,
'Rakel Gunter'
,
'Rakel Gunter'
,
'
12/8/2023
'
,
'
2023-08-12
'
,
'33 Melvin Street'
'33 Melvin Street'
),
),
(
(
58
,
58
,
'Marielle Semour'
,
'Marielle Semour'
,
'
3/1/2024
'
,
'
2024-01-03
'
,
'804 Ohio Place'
'804 Ohio Place'
),
),
(
(
59
,
59
,
'Ciro Paulillo'
,
'Ciro Paulillo'
,
'
9/6/2023
'
,
'
2023-06-09
'
,
'637 Spohn Plaza'
'637 Spohn Plaza'
),
),
(
(
60
,
60
,
'Danyette Parmenter'
,
'Danyette Parmenter'
,
'
7/5/2023
'
,
'
2023-05-07
'
,
'735 Jenna Terrace'
'735 Jenna Terrace'
),
),
(
(
61
,
61
,
'Brooks Licciardi'
,
'Brooks Licciardi'
,
'
7/8/2023
'
,
'
2023-08-07
'
,
'01404 Waxwing Lane'
'01404 Waxwing Lane'
),
),
(
(
62
,
62
,
'Hunt Trusler'
,
'Hunt Trusler'
,
'
6/2/2023
'
,
'
2023-02-06
'
,
'172 Hudson Crossing'
'172 Hudson Crossing'
),
),
(
(
63
,
63
,
'Euphemia Raywood'
,
'Euphemia Raywood'
,
'
1/2/2024
'
,
'
2024-02-01
'
,
'7 Moland Park'
'7 Moland Park'
),
),
(
(
64
,
64
,
'Barn Poyntz'
,
'Barn Poyntz'
,
'
10/9/2023
'
,
'
2023-09-10
'
,
'610 Lakewood Center'
'610 Lakewood Center'
),
),
(
(
65
,
65
,
'Ethe Croston'
,
'Ethe Croston'
,
'
11/11/2023
'
,
'
2023-11-11
'
,
'49 Kennedy Alley'
'49 Kennedy Alley'
),
),
(
(
66
,
66
,
'Farr Bruhnicke'
,
'Farr Bruhnicke'
,
'
3/6/2024
'
,
'
2024-06-03
'
,
'05 Arrowood Alley'
'05 Arrowood Alley'
),
),
(
(
67
,
67
,
'Ruth Blankau'
,
'Ruth Blankau'
,
'2
/4/2024
'
,
'2
024-04-02
'
,
'8683 Oakridge Pass'
'8683 Oakridge Pass'
),
),
(
(
68
,
68
,
'Pearline Tubbles'
,
'Pearline Tubbles'
,
'
11/7/2023
'
,
'
2023-07-11
'
,
'01122 Vidon Drive'
'01122 Vidon Drive'
),
),
(
(
69
,
69
,
'Des Penddreth'
,
'Des Penddreth'
,
'
5/3/2024
'
,
'
2024-03-05
'
,
'87034 Melody Center'
'87034 Melody Center'
),
),
(
(
70
,
70
,
'Abram Paddeley'
,
'Abram Paddeley'
,
'
12/12/2023
'
,
'
2023-12-12
'
,
'97 Magdeline Avenue'
'97 Magdeline Avenue'
),
),
(
(
71
,
71
,
'Corly Mc Meekin'
,
'Corly Mc Meekin'
,
'
10/3/2023
'
,
'
2023-03-10
'
,
'0 Forest Drive'
'0 Forest Drive'
),
),
(
(
72
,
72
,
'Arvie Daen'
,
'Arvie Daen'
,
'
11/3/2023
'
,
'
2023-03-11
'
,
'063 Thierer Pass'
'063 Thierer Pass'
),
),
(
(
73
,
73
,
'Karla Waryk'
,
'Karla Waryk'
,
'
3/4/2024
'
,
'
2024-04-03
'
,
'072 Lindbergh Circle'
'072 Lindbergh Circle'
),
),
(
(
74
,
74
,
'Axel Syson'
,
'Axel Syson'
,
'
9/6/2023
'
,
'
2023-06-09
'
,
'9880 Butternut Trail'
'9880 Butternut Trail'
),
),
(
(
75
,
75
,
'Elliot Beswick'
,
'Elliot Beswick'
,
'
11/3/2023
'
,
'
2023-03-11
'
,
'81686 Lakewood Way'
'81686 Lakewood Way'
),
),
(
(
76
,
76
,
'Stepha Jan'
,
'Stepha Jan'
,
'
4/4/202
4'
,
'
2024-04-0
4'
,
'3 Weeping Birch Place'
'3 Weeping Birch Place'
),
),
(
(
77
,
77
,
'Ignace Rockey'
,
'Ignace Rockey'
,
'
11/5/2023
'
,
'
2023-05-11
'
,
'82131 Rieder Parkway'
'82131 Rieder Parkway'
),
),
(
(
78
,
78
,
'Zelig Oughton'
,
'Zelig Oughton'
,
'
3/22/2024
'
,
'
2024-02-03
'
,
'5 School Avenue'
'5 School Avenue'
),
),
(
(
79
,
79
,
'Madeleine Loudiane'
,
'Madeleine Loudiane'
,
'
7/9/2023
'
,
'
2023-09-07
'
,
'4 Vahlen Court'
'4 Vahlen Court'
),
),
(
(
80
,
80
,
'Courtney Roke'
,
'Courtney Roke'
,
'
1/6/2024
'
,
'
2024-06-01
'
,
'1 Donald Circle'
'1 Donald Circle'
),
),
(
(
81
,
81
,
'Cyrillus Jordon'
,
'Cyrillus Jordon'
,
'
11/1/2023
'
,
'
2023-01-11
'
,
'4229 Longview Court'
'4229 Longview Court'
),
),
(
(
82
,
82
,
'Matthaeus Batterham'
,
'Matthaeus Batterham'
,
'
11/5/2023
'
,
'
2023-05-11
'
,
'928 Kings Drive'
'928 Kings Drive'
),
),
(
(
83
,
83
,
'Rock Kellington'
,
'Rock Kellington'
,
'
8/2/2023
'
,
'
2023-02-08
'
,
'5403 2nd Street'
'5403 2nd Street'
),
),
(
(
84
,
84
,
'Zolly Screase'
,
'Zolly Screase'
,
'
7/4/2023
'
,
'
2023-04-07
'
,
'09057 Bayside Street'
'09057 Bayside Street'
),
),
(
(
85
,
85
,
'Walden Sholl'
,
'Walden Sholl'
,
'
10/10/2023
'
,
'
2023-10-10
'
,
'3082 Tomscot Terrace'
'3082 Tomscot Terrace'
),
),
(
(
86
,
86
,
'Julienne Corballis'
,
'Julienne Corballis'
,
'
3/4/2024
'
,
'
2024-04-03
'
,
'5 Johnson Alley'
'5 Johnson Alley'
),
),
(
(
87
,
87
,
'Flemming Mecco'
,
'Flemming Mecco'
,
'
6/2/2023
'
,
'
2023-02-06
'
,
'99211 Killdeer Pass'
'99211 Killdeer Pass'
),
),
(
(
88
,
88
,
'Aarika Garcia'
,
'Aarika Garcia'
,
'2
/2/2024
'
,
'2
024-02-02
'
,
'001 Kinsman Drive'
'001 Kinsman Drive'
),
),
(
(
89
,
89
,
'Marjory Traske'
,
'Marjory Traske'
,
'
7/5/2023
'
,
'
2023-05-07
'
,
'37049 Manufacturers Center'
'37049 Manufacturers Center'
),
),
(
(
90
,
90
,
'Ida Newlands'
,
'Ida Newlands'
,
'
1/9/2024
'
,
'
2024-09-01
'
,
'00 Thierer Alley'
'00 Thierer Alley'
),
),
(
(
91
,
91
,
'Letti Merrisson'
,
'Letti Merrisson'
,
'
7/7/2023
'
,
'
2023-07-07
'
,
'36 Green Plaza'
'36 Green Plaza'
),
),
(
92
,
'Fran Bullene'
,
'7/2/2023'
,
'5 Bowman Plaza'
),
(
92
,
'Fran Bullene'
,
'2023-02-07'
,
'5 Bowman Plaza'
),
(
(
93
,
93
,
'Natala Harteley'
,
'Natala Harteley'
,
'
1/2/2024
'
,
'
2024-02-01
'
,
'20 High Crossing Junction'
'20 High Crossing Junction'
),
),
(
(
94
,
94
,
'Golda Stout'
,
'Golda Stout'
,
'
1/7/2024
'
,
'
2024-07-01
'
,
'7 Bunker Hill Alley'
'7 Bunker Hill Alley'
),
),
(
(
95
,
95
,
'Stinky Le Grove'
,
'Stinky Le Grove'
,
'
12/3/2023
'
,
'
2023-03-12
'
,
'415 Haas Plaza'
'415 Haas Plaza'
),
),
(
(
96
,
96
,
'Nalani Ravenshear'
,
'Nalani Ravenshear'
,
'
3/4/2024
'
,
'
2024-04-03
'
,
'56132 Vera Street'
'56132 Vera Street'
),
),
(
(
97
,
97
,
'Georgia Mungham'
,
'Georgia Mungham'
,
'
1/1/2024
'
,
'
2024-01-01
'
,
'680 Acker Circle'
'680 Acker Circle'
),
),
(
(
98
,
98
,
'Elsworth Dearell'
,
'Elsworth Dearell'
,
'
12/4/2023
'
,
'
2023-04-12
'
,
'0875 Springview Circle'
'0875 Springview Circle'
),
),
(
(
99
,
99
,
'Philippe Madelin'
,
'Philippe Madelin'
,
'
11/2/2023
'
,
'
2023-02-11
'
,
'312 Morningstar Street'
'312 Morningstar Street'
),
),
(
(
100
,
100
,
'Bing Everwin'
,
'Bing Everwin'
,
'
6/2/2023
'
,
'
2023-02-06
'
,
'07218 Mitchell Park'
'07218 Mitchell Park'
);
);
...
...
src/test/java/com/example/testj/repository/OrderRepositoryTest.java
View file @
9aba07ea
...
@@ -7,6 +7,7 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
...
@@ -7,6 +7,7 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import
org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.ActiveProfiles
;
import
java.time.LocalDate
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.StreamSupport
;
import
java.util.stream.StreamSupport
;
...
@@ -27,7 +28,7 @@ public class OrderRepositoryTest {
...
@@ -27,7 +28,7 @@ public class OrderRepositoryTest {
Order
order
=
new
Order
();
Order
order
=
new
Order
();
order
.
setClient
(
"Client 1"
);
order
.
setClient
(
"Client 1"
);
order
.
setAddress
(
"Address 1"
);
order
.
setAddress
(
"Address 1"
);
order
.
setDate
(
"2000-01-01"
);
order
.
setDate
(
LocalDate
.
of
(
2000
,
1
,
1
)
);
// when
// when
orderRepository
.
save
(
order
);
orderRepository
.
save
(
order
);
// then
// then
...
@@ -61,7 +62,7 @@ public class OrderRepositoryTest {
...
@@ -61,7 +62,7 @@ public class OrderRepositoryTest {
Order
order
=
entityManager
.
find
(
Order
.
class
,
1L
);
Order
order
=
entityManager
.
find
(
Order
.
class
,
1L
);
order
.
setAddress
(
"Address 2"
);
order
.
setAddress
(
"Address 2"
);
order
.
setClient
(
"Client 2"
);
order
.
setClient
(
"Client 2"
);
order
.
setDate
(
"2000-01-01"
);
order
.
setDate
(
LocalDate
.
of
(
2002
,
2
,
2
)
);
// when
// when
Order
saved
=
orderRepository
.
save
(
order
);
Order
saved
=
orderRepository
.
save
(
order
);
// then
// then
...
...
src/test/java/com/example/testj/service/OrderLineServiceTest.java
View file @
9aba07ea
...
@@ -18,6 +18,7 @@ import org.mockito.Mock;
...
@@ -18,6 +18,7 @@ import org.mockito.Mock;
import
org.mockito.Spy
;
import
org.mockito.Spy
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
java.time.LocalDate
;
import
java.util.Optional
;
import
java.util.Optional
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
...
@@ -52,7 +53,7 @@ public class OrderLineServiceTest {
...
@@ -52,7 +53,7 @@ public class OrderLineServiceTest {
@BeforeAll
@BeforeAll
static
void
init
()
{
static
void
init
()
{
orderDto
=
new
OrderDto
(
1L
,
"client 1"
,
"20-20-2020"
,
"address 1"
,
null
);
orderDto
=
new
OrderDto
(
1L
,
"client 1"
,
LocalDate
.
of
(
2020
,
1
,
20
)
,
"address 1"
,
null
);
goodsDto
=
new
GoodsDto
(
1L
,
"product 1"
,
10.99
);
goodsDto
=
new
GoodsDto
(
1L
,
"product 1"
,
10.99
);
orderLine
=
new
OrderLine
(
orderLine
=
new
OrderLine
(
1L
,
1L
,
...
...
src/test/java/com/example/testj/service/OrderServiceTest.java
View file @
9aba07ea
...
@@ -19,6 +19,7 @@ import org.springframework.data.domain.PageImpl;
...
@@ -19,6 +19,7 @@ import org.springframework.data.domain.PageImpl;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.web.PagedModel
;
import
org.springframework.data.web.PagedModel
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -46,13 +47,13 @@ public class OrderServiceTest {
...
@@ -46,13 +47,13 @@ public class OrderServiceTest {
order
.
setId
(
1L
);
order
.
setId
(
1L
);
order
.
setClient
(
"client 1"
);
order
.
setClient
(
"client 1"
);
order
.
setAddress
(
"address 1"
);
order
.
setAddress
(
"address 1"
);
order
.
setDate
(
"20-20-2020"
);
order
.
setDate
(
LocalDate
.
of
(
2020
,
1
,
1
)
);
Order
order1
=
new
Order
();
Order
order1
=
new
Order
();
order1
.
setId
(
2L
);
order1
.
setId
(
2L
);
order1
.
setClient
(
"client 2"
);
order1
.
setClient
(
"client 2"
);
order1
.
setAddress
(
"address 2"
);
order1
.
setAddress
(
"address 2"
);
order1
.
setDate
(
"10-10-2021"
);
order1
.
setDate
(
LocalDate
.
of
(
2020
,
2
,
20
)
);
ordersList
=
Stream
.
of
(
ordersList
=
Stream
.
of
(
order
,
order
,
...
@@ -63,7 +64,7 @@ public class OrderServiceTest {
...
@@ -63,7 +64,7 @@ public class OrderServiceTest {
@Test
@Test
void
testCreateOrUpdateOrder
()
{
void
testCreateOrUpdateOrder
()
{
// given
// given
Order
order
=
new
Order
(
null
,
"client new"
,
"01-01-2021"
,
"address new"
,
null
);
Order
order
=
new
Order
(
null
,
"client new"
,
LocalDate
.
of
(
2021
,
1
,
1
)
,
"address new"
,
null
);
Order
result
=
new
Order
(
Order
result
=
new
Order
(
ordersList
.
getLast
().
getId
()
+
1
,
ordersList
.
getLast
().
getId
()
+
1
,
...
@@ -84,7 +85,7 @@ public class OrderServiceTest {
...
@@ -84,7 +85,7 @@ public class OrderServiceTest {
@Disabled
@Disabled
void
testSaveOrderWithEmptyClient
()
{
void
testSaveOrderWithEmptyClient
()
{
// given
// given
Order
order
=
new
Order
(
null
,
""
,
"01-01-2020"
,
"address new"
,
null
);
Order
order
=
new
Order
(
null
,
""
,
LocalDate
.
of
(
2020
,
1
,
1
)
,
"address new"
,
null
);
// when
// when
assertThrows
(
ConstraintViolationException
.
class
,
()
->
orderService
.
createOrUpdateOrder
(
order
));
assertThrows
(
ConstraintViolationException
.
class
,
()
->
orderService
.
createOrUpdateOrder
(
order
));
// then
// then
...
@@ -95,7 +96,7 @@ public class OrderServiceTest {
...
@@ -95,7 +96,7 @@ public class OrderServiceTest {
@Disabled
@Disabled
void
testSaveOrderWithNullName
()
{
void
testSaveOrderWithNullName
()
{
// given
// given
Order
order
=
new
Order
(
null
,
null
,
"01-01-2020"
,
"address"
,
null
);
Order
order
=
new
Order
(
null
,
null
,
LocalDate
.
of
(
2020
,
1
,
1
)
,
"address"
,
null
);
// when
// when
assertThrows
(
ConstraintViolationException
.
class
,
()
->
orderService
.
createOrUpdateOrder
(
order
));
assertThrows
(
ConstraintViolationException
.
class
,
()
->
orderService
.
createOrUpdateOrder
(
order
));
// then
// then
...
@@ -133,7 +134,7 @@ public class OrderServiceTest {
...
@@ -133,7 +134,7 @@ public class OrderServiceTest {
Order
order
=
ordersList
.
getFirst
();
Order
order
=
ordersList
.
getFirst
();
order
.
setClient
(
"client new"
);
order
.
setClient
(
"client new"
);
order
.
setAddress
(
"address new"
);
order
.
setAddress
(
"address new"
);
order
.
setDate
(
"02-02-2020"
);
order
.
setDate
(
LocalDate
.
of
(
2020
,
2
,
2
)
);
// when
// when
when
(
orderRepository
.
save
(
order
)).
thenReturn
(
order
);
when
(
orderRepository
.
save
(
order
)).
thenReturn
(
order
);
OrderDto
updated
=
orderService
.
createOrUpdateOrder
(
order
);
OrderDto
updated
=
orderService
.
createOrUpdateOrder
(
order
);
...
...
src/test/java/com/example/testj/web/rest/GoodsControllerTest.java
View file @
9aba07ea
...
@@ -5,6 +5,7 @@ import com.example.testj.service.GoodsService;
...
@@ -5,6 +5,7 @@ import com.example.testj.service.GoodsService;
import
com.example.testj.service.dto.GoodsDto
;
import
com.example.testj.service.dto.GoodsDto
;
import
com.example.testj.service.mapper.GoodsMapper
;
import
com.example.testj.service.mapper.GoodsMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.hamcrest.Matchers
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -109,7 +110,9 @@ public class GoodsControllerTest {
...
@@ -109,7 +110,9 @@ public class GoodsControllerTest {
JSONObject
bodyJson
=
new
JSONObject
(
"{'name': null, 'price': 0}"
);
JSONObject
bodyJson
=
new
JSONObject
(
"{'name': null, 'price': 0}"
);
mvc
.
perform
(
post
(
"/api/goods"
).
contentType
(
MediaType
.
APPLICATION_JSON
).
content
(
bodyJson
.
toString
()))
mvc
.
perform
(
post
(
"/api/goods"
).
contentType
(
MediaType
.
APPLICATION_JSON
).
content
(
bodyJson
.
toString
()))
.
andExpect
(
status
().
isBadRequest
());
.
andExpect
(
status
().
isBadRequest
())
.
andExpect
(
jsonPath
(
"$.errors[*].field"
).
value
(
Matchers
.
containsInAnyOrder
(
"name"
,
"price"
)));
}
}
@Test
@Test
...
...
src/test/java/com/example/testj/web/rest/OrderControllerTest.java
View file @
9aba07ea
...
@@ -4,6 +4,8 @@ import com.example.testj.service.OrderService;
...
@@ -4,6 +4,8 @@ import com.example.testj.service.OrderService;
import
com.example.testj.service.dto.OrderDto
;
import
com.example.testj.service.dto.OrderDto
;
import
com.example.testj.service.mapper.OrderMapper
;
import
com.example.testj.service.mapper.OrderMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.hamcrest.Matchers
;
import
org.json.JSONObject
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -18,6 +20,7 @@ import org.springframework.data.web.PagedModel;
...
@@ -18,6 +20,7 @@ import org.springframework.data.web.PagedModel;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MockMvc
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
...
@@ -34,6 +37,9 @@ public class OrderControllerTest {
...
@@ -34,6 +37,9 @@ public class OrderControllerTest {
@Autowired
@Autowired
private
MockMvc
mvc
;
private
MockMvc
mvc
;
@Autowired
private
ObjectMapper
objectMapper
;
@MockBean
@MockBean
private
OrderService
orderService
;
private
OrderService
orderService
;
...
@@ -46,10 +52,10 @@ public class OrderControllerTest {
...
@@ -46,10 +52,10 @@ public class OrderControllerTest {
static
void
init
()
{
static
void
init
()
{
ordersList
=
Stream
.
of
(
ordersList
=
Stream
.
of
(
new
OrderDto
(
new
OrderDto
(
1L
,
"client 1"
,
"20-20-2020"
,
"address 1"
,
null
1L
,
"client 1"
,
LocalDate
.
of
(
2020
,
1
,
20
)
,
"address 1"
,
null
),
),
new
OrderDto
(
new
OrderDto
(
2L
,
"client 2"
,
"20-20-2020"
,
"address 2"
,
null
2L
,
"client 2"
,
LocalDate
.
of
(
2020
,
1
,
21
)
,
"address 2"
,
null
)
)
).
toList
();
).
toList
();
}
}
...
@@ -83,9 +89,9 @@ public class OrderControllerTest {
...
@@ -83,9 +89,9 @@ public class OrderControllerTest {
@DisplayName
(
"POST /api/orders [201 Created]"
)
@DisplayName
(
"POST /api/orders [201 Created]"
)
void
testCreateOrder
()
throws
Exception
{
void
testCreateOrder
()
throws
Exception
{
OrderDto
orderDto
=
new
OrderDto
(
OrderDto
orderDto
=
new
OrderDto
(
null
,
"client new"
,
"21-21-2021"
,
"address new"
,
null
null
,
"client new"
,
LocalDate
.
of
(
2021
,
1
,
21
)
,
"address new"
,
null
);
);
String
body
=
new
ObjectMapper
()
.
writeValueAsString
(
orderDto
);
String
body
=
objectMapper
.
writeValueAsString
(
orderDto
);
Long
nextId
=
(
ordersList
.
getLast
().
getId
()
+
1
);
Long
nextId
=
(
ordersList
.
getLast
().
getId
()
+
1
);
orderDto
.
setId
(
nextId
);
orderDto
.
setId
(
nextId
);
...
@@ -96,7 +102,18 @@ public class OrderControllerTest {
...
@@ -96,7 +102,18 @@ public class OrderControllerTest {
.
andExpect
(
jsonPath
(
"$.id"
).
isNumber
())
.
andExpect
(
jsonPath
(
"$.id"
).
isNumber
())
.
andExpect
(
jsonPath
(
"$.client"
).
value
(
orderDto
.
getClient
()))
.
andExpect
(
jsonPath
(
"$.client"
).
value
(
orderDto
.
getClient
()))
.
andExpect
(
jsonPath
(
"$.address"
).
value
(
orderDto
.
getAddress
()))
.
andExpect
(
jsonPath
(
"$.address"
).
value
(
orderDto
.
getAddress
()))
.
andExpect
(
jsonPath
(
"$.date"
).
value
(
orderDto
.
getDate
())).
andReturn
();
.
andExpect
(
jsonPath
(
"$.date"
).
value
(
orderDto
.
getDate
().
toString
())).
andReturn
();
}
@Test
@DisplayName
(
"POST /api/orders [400 Bad Request]"
)
void
testCreateOrderBadRequest
()
throws
Exception
{
JSONObject
bodyJson
=
new
JSONObject
(
"{'client': null, 'address': '', 'date': ''}"
);
mvc
.
perform
(
post
(
"/api/orders"
).
contentType
(
MediaType
.
APPLICATION_JSON
).
content
(
bodyJson
.
toString
()))
.
andExpect
(
status
().
isBadRequest
())
.
andExpect
(
jsonPath
(
"$.errors[*].field"
).
value
(
Matchers
.
containsInAnyOrder
(
"client"
,
"address"
,
"date"
)));
}
}
@Test
@Test
...
@@ -104,9 +121,9 @@ public class OrderControllerTest {
...
@@ -104,9 +121,9 @@ public class OrderControllerTest {
void
testUpdateOrder
()
throws
Exception
{
void
testUpdateOrder
()
throws
Exception
{
Long
id
=
1L
;
Long
id
=
1L
;
OrderDto
orderDto
=
new
OrderDto
(
OrderDto
orderDto
=
new
OrderDto
(
id
,
"client new"
,
"21-21-2021"
,
"address new"
,
null
id
,
"client new"
,
LocalDate
.
of
(
2021
,
1
,
21
)
,
"address new"
,
null
);
);
String
body
=
new
ObjectMapper
()
.
writeValueAsString
(
orderDto
);
String
body
=
objectMapper
.
writeValueAsString
(
orderDto
);
when
(
orderService
.
getOrder
(
id
)).
thenReturn
(
ordersList
.
getFirst
());
when
(
orderService
.
getOrder
(
id
)).
thenReturn
(
ordersList
.
getFirst
());
when
(
orderService
.
createOrUpdateOrder
(
orderMapper
.
toEntity
(
orderDto
))).
thenReturn
(
orderDto
);
when
(
orderService
.
createOrUpdateOrder
(
orderMapper
.
toEntity
(
orderDto
))).
thenReturn
(
orderDto
);
...
@@ -117,7 +134,7 @@ public class OrderControllerTest {
...
@@ -117,7 +134,7 @@ public class OrderControllerTest {
.
andExpect
(
status
().
isOk
())
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.client"
).
value
(
orderDto
.
getClient
()))
.
andExpect
(
jsonPath
(
"$.client"
).
value
(
orderDto
.
getClient
()))
.
andExpect
(
jsonPath
(
"$.address"
).
value
(
orderDto
.
getAddress
()))
.
andExpect
(
jsonPath
(
"$.address"
).
value
(
orderDto
.
getAddress
()))
.
andExpect
(
jsonPath
(
"$.date"
).
value
(
orderDto
.
getDate
()));
.
andExpect
(
jsonPath
(
"$.date"
).
value
(
orderDto
.
getDate
()
.
toString
()
));
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment