Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
payments-vendor-simulator
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
2
Merge Requests
2
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
payments
payments-vendor-simulator
Commits
21b1151b
Commit
21b1151b
authored
Sep 16, 2021
by
Ben Anderson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit test for cc/authorize route that tests for successful authorization
parent
7d7f9d1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
build.gradle
build.gradle
+1
-0
CreditCardControllerTest.java
...ator/creditcard/controllers/CreditCardControllerTest.java
+30
-0
No files found.
build.gradle
View file @
21b1151b
...
...
@@ -27,6 +27,7 @@ dependencies {
annotationProcessor
'org.projectlombok:lombok'
implementation
"io.springfox:springfox-boot-starter:3.0.0"
compileOnly
"io.springfox:springfox-swagger-ui:3.0.0"
testImplementation
'org.mockito:mockito-core:3.12.4'
}
test
{
...
...
src/test/java/com/nisum/paymentvendorsimulator/creditcard/controllers/CreditCardControllerTest.java
0 → 100644
View file @
21b1151b
package
com
.
nisum
.
paymentvendorsimulator
.
creditcard
.
controllers
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.servlet.MockMvc
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.*;
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
MOCK
)
@AutoConfigureMockMvc
class
CreditCardControllerTest
{
@Autowired
private
MockMvc
mockMvc
;
@Test
void
authorize
()
throws
Exception
{
mockMvc
.
perform
(
post
(
"/api/cc/authorize"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
"{ \"card\": { \"number\": \"4111111111111111\", \"expiryMonth\": \"03\", \"expiryYear\": \"2030\", \"cvc\": \"737\", \"holderName\": \"John Smith\" }, \"amount\": { \"value\": 1500, \"currency\": \"EUR\" }, \"reference\": \"YOUR_REFERENCE\", \"merchantAccount\": \"YOUR_MERCHANT_ACCOUNT\" }"
)
.
accept
(
MediaType
.
APPLICATION_JSON
))
.
andExpect
(
status
().
is2xxSuccessful
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON
))
.
andExpect
(
jsonPath
(
"$.cardNumber"
).
value
(
"4111111111111111"
))
.
andExpect
(
jsonPath
(
"$.cvv"
).
value
(
"737"
));
}
}
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