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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chen Liang
Team6-Digital Insight for Health
Commits
759182ee
Commit
759182ee
authored
5 months ago
by
Chen Liang
Browse files
Options
Downloads
Patches
Plain Diff
Delete SuperAdminControllErintegrationTest.java
parent
a61ccde1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/com/cardiff/wylTest/SuperAdminControllErintegrationTest.java
+0
-105
0 additions, 105 deletions
.../cardiff/wylTest/SuperAdminControllErintegrationTest.java
with
0 additions
and
105 deletions
src/test/java/com/cardiff/wylTest/SuperAdminControllErintegrationTest.java
deleted
100644 → 0
+
0
−
105
View file @
a61ccde1
package
com.cardiff.wylTest
;
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
com.fasterxml.jackson.databind.ObjectMapper
;
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.boot.test.mock.mockito.MockBean
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.servlet.MockMvc
;
import
java.util.Arrays
;
import
java.util.List
;
import
static
org
.
mockito
.
Mockito
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
jsonPath
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@SpringBootTest
@AutoConfigureMockMvc
public
class
SuperAdminControllErintegrationTest
{
@Autowired
private
MockMvc
mockMvc
;
@MockBean
private
SuperAdminService
superAdminService
;
@Test
void
testSignIn
()
throws
Exception
{
// Construct test data
SignUserDTO
signDTO
=
new
SignUserDTO
();
signDTO
.
setName
(
"testUser"
);
signDTO
.
setPassword
(
"password123"
);
Result
expectedResult
=
Result
.
success
(
"User registered successfully"
);
when
(
superAdminService
.
insertUserInform
(
any
(
SignUserDTO
.
class
))).
thenReturn
(
expectedResult
);
// post
mockMvc
.
perform
(
post
(
"/superAdmin/sign"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
new
ObjectMapper
().
writeValueAsString
(
signDTO
)))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.msg"
).
value
(
"User registered successfully"
));
// Verify that the service layer is invoked
verify
(
superAdminService
,
times
(
1
)).
insertUserInform
(
any
(
SignUserDTO
.
class
));
}
@Test
void
testDeleteHospitalById
()
throws
Exception
{
List
<
Integer
>
ids
=
Arrays
.
asList
(
1
,
2
,
3
);
Result
mockResult
=
Result
.
success
(
"successfully"
);
when
(
superAdminService
.
deleteById
(
eq
(
ids
),
eq
(
"hospital"
))).
thenReturn
(
mockResult
);
mockMvc
.
perform
(
delete
(
"/superAdmin/deleteHospitalById"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
new
ObjectMapper
().
writeValueAsString
(
ids
)))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.code"
).
value
(
1
))
.
andExpect
(
jsonPath
(
"$.msg"
).
value
(
"successfully"
));
verify
(
superAdminService
,
times
(
1
)).
deleteById
(
eq
(
ids
),
eq
(
"hospital"
));
}
@Test
void
testSelectByItem
()
throws
Exception
{
SelectDTO
selectDTO
=
new
SelectDTO
();
selectDTO
.
setName
(
"testQuery"
);
Result
mockResult
=
Result
.
success
(
"Query successful"
);
when
(
superAdminService
.
selectByItem
(
any
(
SelectDTO
.
class
))).
thenReturn
(
mockResult
);
mockMvc
.
perform
(
post
(
"/superAdmin/select"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
new
ObjectMapper
().
writeValueAsString
(
selectDTO
)))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.code"
).
value
(
1
))
.
andExpect
(
jsonPath
(
"$.msg"
).
value
(
"Query successful"
));
verify
(
superAdminService
,
times
(
1
)).
selectByItem
(
any
(
SelectDTO
.
class
));
}
@Test
void
testUpdateById
()
throws
Exception
{
SelectDTO
selectDTO
=
new
SelectDTO
();
selectDTO
.
setId
(
1
);
selectDTO
.
setName
(
"newData"
);
Result
mockResult
=
Result
.
success
(
"Update successful"
);
when
(
superAdminService
.
update
(
any
(
SelectDTO
.
class
))).
thenReturn
(
mockResult
);
mockMvc
.
perform
(
put
(
"/superAdmin/update"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
new
ObjectMapper
().
writeValueAsString
(
selectDTO
)))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.code"
).
value
(
1
))
.
andExpect
(
jsonPath
(
"$.msg"
).
value
(
"Update successful"
));
verify
(
superAdminService
,
times
(
1
)).
update
(
any
(
SelectDTO
.
class
));
}
}
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