Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
c800cf11
Commit
c800cf11
authored
Dec 26, 2017
by
Java—红包—徐 然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
a86d9332
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
0 deletions
+95
-0
TestUserService.java
src/test/java/userService/TestUserService.java
+95
-0
No files found.
src/test/java/userService/TestUserService.java
0 → 100644
View file @
c800cf11
package
userService
;
import
cn.quantgroup.xyqb.Bootstrap
;
import
cn.quantgroup.xyqb.controller.internal.user.UserController
;
import
cn.quantgroup.xyqb.entity.Address
;
import
cn.quantgroup.xyqb.entity.Contact
;
import
cn.quantgroup.xyqb.service.user.IAddressService
;
import
cn.quantgroup.xyqb.service.user.IContactService
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Parameterized
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.TestContextManager
;
import
org.springframework.test.context.TestExecutionListeners
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.support.DependencyInjectionTestExecutionListener
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.sql.Timestamp
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.List
;
/**
* Created by xuran on 2017/12/26.
*/
@SpringBootTest
(
classes
=
Bootstrap
.
class
)
@Slf4j
@Rollback
@Transactional
@RunWith
(
Parameterized
.
class
)
public
class
TestUserService
{
private
TestContextManager
testContextManager
;
@Autowired
private
IAddressService
addressService
;
@Autowired
private
IContactService
contactService
;
private
Address
addressObj
;
public
TestUserService
(
Address
addressObj
)
{
super
();
this
.
addressObj
=
addressObj
;
}
@Before
public
void
setUpContext
()
throws
Exception
{
//this is where the magic happens, we actually do "by hand" what the spring runner would do for us,
// read the JavaDoc for the class bellow to know exactly what it does, the method names are quite accurate though
this
.
testContextManager
=
new
TestContextManager
(
getClass
());
this
.
testContextManager
.
prepareTestInstance
(
this
);
}
@Parameterized
.
Parameters
public
static
Collection
data
()
{
Address
addressObj
=
new
Address
();
addressObj
.
setUserId
(
123456L
);
addressObj
.
setCity
(
"悉尼"
);
addressObj
.
setCityCode
(
1L
);
addressObj
.
setDistrict
(
"悉尼"
);
addressObj
.
setDistrictCode
(
1L
);
addressObj
.
setProvince
(
"悉尼"
);
addressObj
.
setProvinceCode
(
1L
);
addressObj
.
setAddress
(
"嘻哈"
);
Timestamp
timestamp
=
Timestamp
.
valueOf
(
LocalDateTime
.
now
());
addressObj
.
setCreatedAt
(
timestamp
);
addressObj
.
setUpdateAt
(
timestamp
);
return
Arrays
.
asList
(
new
Object
[][]{{
addressObj
}});
}
@Test
public
void
testAddress
()
{
addressService
.
save
(
addressObj
);
addressObj
=
addressService
.
findByUserId
(
addressObj
.
getUserId
());
System
.
out
.
println
(
"测试地址"
+
addressObj
);
List
<
Long
>
userIds
=
Lists
.
newArrayList
();
userIds
.
add
(
123456L
);
List
<
Address
>
addresses
=
addressService
.
findByUserIds
(
userIds
);
System
.
out
.
println
(
"测试地址集合"
+
addresses
.
get
(
0
));
}
}
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