Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
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
idatt2106-v23-03
backend
Commits
efe2d894
Commit
efe2d894
authored
2 years ago
by
harryTheWizzard
Browse files
Options
Downloads
Patches
Plain Diff
unit test for user entity
parent
7a776248
No related branches found
Branches containing commit
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/ntnu/idatt2016/v233/SmartMat/entity/user/UserTest.java
+68
-0
68 additions, 0 deletions
...va/ntnu/idatt2016/v233/SmartMat/entity/user/UserTest.java
with
68 additions
and
0 deletions
src/test/java/ntnu/idatt2016/v233/SmartMat/entity/user/UserTest.java
0 → 100644
+
68
−
0
View file @
efe2d894
package
ntnu.idatt2016.v233.SmartMat.entity.user
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
java.util.Collections
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
class
UserTest
{
@Test
void
testGetAuthorities
()
{
User
user
=
User
.
builder
()
.
authority
(
Authority
.
USER
)
.
build
();
assertEquals
(
Collections
.
singletonList
(
new
SimpleGrantedAuthority
(
Authority
.
USER
.
name
())),
user
.
getAuthorities
());
}
@Test
void
testGetPassword
()
{
User
user
=
User
.
builder
()
.
password
(
"password123"
)
.
build
();
assertEquals
(
"password123"
,
user
.
getPassword
());
}
@Test
void
testGetUsername
()
{
User
user
=
User
.
builder
()
.
username
(
"johndoe"
)
.
build
();
assertEquals
(
"johndoe"
,
user
.
getUsername
());
}
@Test
void
testIsAccountNonExpired
()
{
User
user
=
new
User
();
assertTrue
(
user
.
isAccountNonExpired
());
}
@Test
void
testIsAccountNonLocked
()
{
User
user
=
new
User
();
assertTrue
(
user
.
isAccountNonLocked
());
}
@Test
void
testIsCredentialsNonExpired
()
{
User
user
=
new
User
();
assertTrue
(
user
.
isCredentialsNonExpired
());
}
@Test
void
testIsEnabled
()
{
User
user
=
User
.
builder
()
.
enabled
(
true
)
.
build
();
assertTrue
(
user
.
isEnabled
());
}
}
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