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
a6e4dd25
Commit
a6e4dd25
authored
May 05, 2021
by
Sumaiyya Burney
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests getAllPromos
parent
a363227b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
2 deletions
+58
-2
PromotionsController.java
...um/ascend/promotions/controller/PromotionsController.java
+1
-1
Promotion.java
...ain/java/com/nisum/ascend/promotions/model/Promotion.java
+1
-1
application-test.properties
src/main/resources/application-test.properties
+5
-0
PromotionsControllerTest.java
...scend/promotions/controller/PromotionsControllerTest.java
+51
-0
No files found.
src/main/java/com/nisum/ascend/promotions/controller/PromotionsController.java
View file @
a6e4dd25
...
...
@@ -20,7 +20,7 @@ public class PromotionsController {
PromotionService
promotionService
;
@GetMapping
()
public
ResponseEntity
<
Flux
<
PromotionDto
>>
getAllPromotions
(
@RequestParam
(
required
=
false
)
String
itemS
ku
){
public
ResponseEntity
<
Flux
<
PromotionDto
>>
getAllPromotions
(
@RequestParam
(
required
=
false
)
String
s
ku
){
//TODO: test once we have real data
return
ResponseEntity
.
ok
(
promotionService
.
findAll
());
}
...
...
src/main/java/com/nisum/ascend/promotions/model/Promotion.java
View file @
a6e4dd25
...
...
@@ -8,7 +8,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
@Getter
@Setter
@Document
@Document
(
collection
=
"promotions"
)
public
class
Promotion
{
@Id
private
String
id
;
...
...
src/main/resources/application-test.properties
0 → 100644
View file @
a6e4dd25
spring.config.import
=
classpath:secret.properties
spring.data.mongodb.uri
=
mongodb+srv://admin:${db.password}@inventory-promotions.d4nfz.mongodb
\
.net/${spring.data.mongodb.database}?retryWrites=true&w=majority
spring.data.mongodb.database
=
test
\ No newline at end of file
src/test/java/com/nisum/ascend/promotions/controller/PromotionsControllerTest.java
0 → 100644
View file @
a6e4dd25
package
com
.
nisum
.
ascend
.
promotions
.
controller
;
import
com.nisum.ascend.promotions.dto.PromotionDto
;
import
com.nisum.ascend.promotions.model.Promotion
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.test.web.reactive.server.WebTestClient
;
import
java.util.List
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
@ExtendWith
(
SpringExtension
.
class
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@DirtiesContext
@AutoConfigureWebTestClient
@ActiveProfiles
(
"test"
)
@Slf4j
class
PromotionsControllerTest
{
@Autowired
private
WebTestClient
webTestClient
;
@BeforeEach
void
setUp
()
{
}
@Test
void
getAllPromotions
()
{
webTestClient
.
get
().
uri
(
"http://localhost:8081/api/promos"
).
exchange
()
.
expectStatus
().
isOk
()
.
expectHeader
().
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)
.
expectBodyList
(
PromotionDto
.
class
)
.
hasSize
(
2
)
.
consumeWith
(
promo
->{
List
<
PromotionDto
>
promos
=
promo
.
getResponseBody
();
assert
promos
!=
null
;
promos
.
forEach
(
p
->{
assertNotNull
(
p
.
getPromotionId
());
assertNotNull
(
p
.
getProductSku
());
System
.
out
.
println
(
p
.
getPromotionId
());
});
});
}
}
\ 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