Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
inventory-service
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ascend
inventory-service
Commits
1a6f0322
Commit
1a6f0322
authored
May 12, 2021
by
Sumaiyya Burney
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes delete and update tests
parent
2fd1bc10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
8 deletions
+39
-8
ProductControllerTest.java
...um/ascend/inventory/controller/ProductControllerTest.java
+39
-8
No files found.
src/test/java/com/nisum/ascend/inventory/controller/ProductControllerTest.java
View file @
1a6f0322
...
...
@@ -36,6 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
reactor.core.publisher.Mono
;
import
java.util.Random
;
import
java.util.UUID
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
...
...
@@ -90,7 +91,8 @@ class ProductControllerTest {
.
expectBodyList
(
Product
.
class
)
.
consumeWith
(
product
->{
List
<
Product
>
products
=
product
.
getResponseBody
();
products
.
forEach
(
p
->{
assert
products
!=
null
;
products
.
forEach
(
p
->{
assertNotNull
(
p
.
getSku
());
assertNotNull
(
p
.
getUpc
());
System
.
out
.
println
(
"Product SKU: "
+
p
.
getSku
());
...
...
@@ -115,14 +117,42 @@ class ProductControllerTest {
*/
@Test
public
void
testDeleteProduct
(){
String
sku
=
"SH=1123"
;
webTestClient
.
delete
().
uri
(
"/api/products"
.
concat
(
"/{sku}"
),
sku
)
Product
deleteLater
=
new
Product
(
"SH=1123"
,
"3d2dsd9cm"
,
"Blue Sweater"
,
"A nice red sweater"
,
23.99f
,
45
,
""
,
"SweatCo"
,
"Sweatshirts"
);
webTestClient
.
get
()
.
uri
(
"/api/products"
.
concat
(
"/{productSku}"
),
deleteLater
.
getSku
())
.
exchange
()
.
expectStatus
().
isNotFound
();
webTestClient
.
post
()
.
uri
(
"/api/products"
)
.
contentType
(
MediaType
.
valueOf
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
body
(
Mono
.
just
(
deleteLater
),
Product
.
class
)
.
exchange
()
.
expectStatus
().
isOk
()
.
expectBody
(
Product
.
class
);
webTestClient
.
delete
()
.
uri
(
"/api/products"
.
concat
(
"/{productSku}"
),
deleteLater
.
getSku
())
.
accept
(
MediaType
.
valueOf
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
exchange
()
.
expectStatus
().
isOk
()
.
expectBody
(
Void
.
class
);
System
.
out
.
println
(
"Deletion Successful. Ending test..."
);
webTestClient
.
get
()
.
uri
(
"/api/products"
.
concat
(
"/{productSku}"
),
deleteLater
.
getSku
())
.
exchange
()
.
expectStatus
().
isNotFound
();
// String sku = "SH=1123";
// webTestClient.delete().uri("/api/products".concat("/{sku}"),sku)
// .accept(MediaType.valueOf(MediaType.APPLICATION_JSON_VALUE))
// .exchange()
// .expectStatus().isOk()
// .expectBody(Void.class);
//
// System.out.println("Deletion Successful. Ending test...");
}
@Test
...
...
@@ -142,10 +172,11 @@ class ProductControllerTest {
@Test
public
void
updateProduct
(){
double
newPrice
=
49.99
;
String
sku
=
"SH=1123"
;
Random
rd
=
new
Random
();
float
newPrice
=
rd
.
nextFloat
()*
100
;
String
sku
=
"SKU-PUT"
;
Product
product
=
new
Product
(
sku
,
"3d2dsd9cm"
,
"Blue Sweater"
,
"A Nice red sweater"
,
(
float
)
newPrice
,
45
,
""
,
"A Nice red sweater"
,
newPrice
,
45
,
""
,
"SweatCo"
,
"Sweatshirts"
);
webTestClient
.
put
().
uri
(
"/api/products"
.
concat
(
"/{sku}"
),
sku
)
.
contentType
(
MediaType
.
valueOf
(
MediaType
.
APPLICATION_JSON_VALUE
))
...
...
@@ -162,7 +193,7 @@ class ProductControllerTest {
double
newPrice
=
49.99
;
String
sku
=
"SH=2021"
;
Product
product
=
new
Product
(
sku
,
"3d2dsd9cm"
,
"Blue Sweater"
,
"A Nice red sweater"
,
(
float
)
23.99
,
45
,
""
,
"A Nice red sweater"
,
23.99f
,
45
,
""
,
"SweatCo"
,
"Sweatshirts"
);
webTestClient
.
put
().
uri
(
"/api/products"
.
concat
(
"/{sku}"
),
sku
)
.
contentType
(
MediaType
.
valueOf
(
MediaType
.
APPLICATION_JSON_VALUE
))
...
...
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