Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
promotions-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
promotions-service
Commits
2d930609
Commit
2d930609
authored
May 10, 2021
by
Julius Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete route
parent
302aa8ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
7 deletions
+13
-7
PromotionsController.java
...um/ascend/promotions/controller/PromotionsController.java
+3
-2
ResourceNotFoundException.java
...scend/promotions/exception/ResourceNotFoundException.java
+0
-1
PromotionService.java
...com/nisum/ascend/promotions/service/PromotionService.java
+3
-3
PromotionsControllerTest.java
...scend/promotions/controller/PromotionsControllerTest.java
+7
-1
No files found.
src/main/java/com/nisum/ascend/promotions/controller/PromotionsController.java
View file @
2d930609
...
...
@@ -54,10 +54,11 @@ public class PromotionsController {
@DeleteMapping
(
"/{promoId}"
)
public
Mono
<
ResponseEntity
<
PromotionDto
>>
deletePromotionById
(
@PathVariable
String
promoId
){
public
Mono
<
ResponseEntity
<
Void
>>
deletePromotionById
(
@PathVariable
(
"promoId"
)
String
promoId
){
return
promotionService
.
deletePromotion
(
promoId
)
.
map
(
res
->
ResponseEntity
.
ok
().<
PromotionDto
>
build
())
.
map
(
res
->
ResponseEntity
.
ok
().<
Void
>
build
())
.
defaultIfEmpty
(
ResponseEntity
.
notFound
().
build
());
}
}
src/main/java/com/nisum/ascend/promotions/exception/ResourceNotFoundException.java
View file @
2d930609
...
...
@@ -4,7 +4,6 @@ import org.springframework.http.HttpStatus;
import
org.springframework.web.bind.annotation.ResponseStatus
;
@ResponseStatus
(
value
=
HttpStatus
.
NOT_FOUND
)
public
class
ResourceNotFoundException
extends
Exception
{
HttpStatus
status
;
...
...
src/main/java/com/nisum/ascend/promotions/service/PromotionService.java
View file @
2d930609
...
...
@@ -37,12 +37,12 @@ public class PromotionService {
});
}
public
Mono
<
Promotion
Dto
>
deletePromotion
(
String
promoId
){
public
Mono
<
Promotion
>
deletePromotion
(
String
promoId
){
return
promotionRepository
.
findByPromotionId
(
promoId
)
.
flatMap
(
promo
->
promotionRepository
.
delete
(
promo
)
.
then
(
Mono
.
just
(
promo
)))
.
map
(
PromotionDto:
:
generateDtoFromPromotion
)
.
switchIfEmpty
(
Mono
.
error
(
new
ResourceNotFoundException
(
HttpStatus
.
NOT_FOUND
,
"Product Not Found"
)));
.
switchIfEmpty
(
Mono
.
error
(
new
ResourceNotFoundException
(
HttpStatus
.
NOT_FOUND
,
"Promo Not Found"
)));
}
}
src/test/java/com/nisum/ascend/promotions/controller/PromotionsControllerTest.java
View file @
2d930609
...
...
@@ -114,6 +114,12 @@ class PromotionsControllerTest {
}
@Test
void
deletePromotion
(){
String
promoId
=
"asd123"
;
webTestClient
.
delete
()
.
uri
(
"/api/promos"
.
concat
(
"/{promoId}"
),
promoId
)
.
accept
(
MediaType
.
valueOf
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
exchange
()
.
expectStatus
().
isOk
()
.
expectBody
(
Void
.
class
);
}
}
\ No newline at end of file
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