Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Team6-Digital Insight for Health
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chen Liang
Team6-Digital Insight for Health
Commits
a61ccde1
Commit
a61ccde1
authored
4 months ago
by
Chen Liang
Browse files
Options
Downloads
Patches
Plain Diff
Delete LightweightTest.java
parent
9d24550a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/com/cardiff/wylTest/LightweightTest.java
+0
-101
0 additions, 101 deletions
src/test/java/com/cardiff/wylTest/LightweightTest.java
with
0 additions
and
101 deletions
src/test/java/com/cardiff/wylTest/LightweightTest.java
deleted
100644 → 0
+
0
−
101
View file @
9d24550a
package
com.cardiff.wylTest
;
import
com.cardiff.client_project.HealthCareApplication
;
import
com.cardiff.client_project.config.WebSecurityConfig
;
import
com.cardiff.client_project.controller.admin.SuperAdminController
;
import
com.cardiff.client_project.pojo.dto.SelectDTO
;
import
com.cardiff.client_project.pojo.dto.SignUserDTO
;
import
com.cardiff.client_project.service.SuperAdminService
;
import
com.cardiff.client_project.utils.Result
;
import
org.junit.internal.Classes
;
import
org.junit.jupiter.api.Named
;
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.servlet.WebMvcTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.http.MediaType
;
import
org.springframework.security.test.context.support.WithMockUser
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.test.web.servlet.MockMvc
;
import
java.util.Arrays
;
import
static
org
.
mockito
.
Mockito
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
jsonPath
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
javax.naming.Name
;
@ExtendWith
(
SpringExtension
.
class
)
@WebMvcTest
(
SuperAdminController
.
class
)
public
class
LightweightTest
{
@Autowired
private
MockMvc
mockMvc
;
@MockBean
private
SuperAdminService
superAdminService
;
@Autowired
private
ObjectMapper
objectMapper
;
// Jackson 用于 JSON 序列化
/**
* Testing the user registration interface
* private String name;
* private String password;
* private String email;
* private String phone;
* private String address;
* private String type;
* private String role;
* private int status;
*/
@WithMockUser
(
username
=
"2649783657@qq.com"
,
password
=
"admin"
,
roles
=
"super"
)
@Test
public
void
testSignIn
()
throws
Exception
{
SignUserDTO
signUserDTO
=
new
SignUserDTO
();
signUserDTO
.
setName
(
"57@qq.com"
);
signUserDTO
.
setPassword
(
"admin"
);
signUserDTO
.
setEmail
(
"57657@qq.com"
);
signUserDTO
.
setPhone
(
"2649783657@qq.com"
);
signUserDTO
.
setAddress
(
"test"
);
signUserDTO
.
setType
(
"admin"
);
signUserDTO
.
setRole
(
"admin"
);
signUserDTO
.
setStatus
(
1
);
Result
mockResult
=
Result
.
error
(
"User registered error"
);
when
(
superAdminService
.
insertUserInform
(
any
(
SignUserDTO
.
class
))).
thenReturn
(
mockResult
);
mockMvc
.
perform
(
post
(
"/superAdmin/sign"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
objectMapper
.
writeValueAsString
(
signUserDTO
)))
.
andExpect
(
status
().
is
(
403
));
}
/**
* Test the paging query interface
*/
@WithMockUser
(
username
=
"2649783657@qq.com"
,
password
=
"admin"
)
@Test
public
void
testPageSelect
()
throws
Exception
{
Result
mockResult
=
Result
.
success
(
"Page select success"
);
when
(
superAdminService
.
selectPage
(
"admin"
,
10
,
1
)).
thenReturn
(
mockResult
);
mockMvc
.
perform
(
get
(
"/superAdmin/pageSelect"
)
.
param
(
"type"
,
"admin"
)
.
param
(
"pageSize"
,
"10"
)
.
param
(
"pageNumber"
,
"1"
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.msg"
).
value
(
"Page select success"
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment