Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2017-02-07 17:01:55 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
894d1ac2e15615f952dac079d1f78348214ea5af
894d1ac2
1 parent
fd222568
Début de couverture de SharedServiceDefault
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
src/test/java/org/legrog/web/xyz/SharedServiceDefaultTest.java
src/test/java/org/legrog/web/xyz/SharedServiceDefaultTest.java
0 → 100644
View file @
894d1ac
package
org
.
legrog
.
web
.
xyz
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Nested
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.platform.runner.JUnitPlatform
;
import
org.junit.runner.RunWith
;
import
org.legrog.entities.AccountPropertyRepository
;
import
org.legrog.entities.AccountRoleRepository
;
import
org.legrog.entities.Country
;
import
org.legrog.entities.CountryRepository
;
import
org.legrog.test.MockitoExtension
;
import
org.legrog.web.user.UserService
;
import
org.mockito.Mock
;
import
org.mockito.*
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/*
Classe testant SharedServiceDefault
*/
@RunWith
(
JUnitPlatform
.
class
)
@ExtendWith
(
MockitoExtension
.
class
)
@DisplayName
(
"Service layer for data that is not content"
)
public
class
SharedServiceDefaultTest
{
SharedServiceDefault
sharedServiceDefault
;
@BeforeEach
public
void
setUp
(
@Mock
CountryRepository
countryRepository
,
@Mock
AccountRoleRepository
accountRoleRepository
,
@Mock
AccountPropertyRepository
accountPropertyRepository
,
@Mock
UserService
userService
)
{
sharedServiceDefault
=
new
SharedServiceDefault
(
countryRepository
,
accountRoleRepository
,
accountPropertyRepository
,
userService
);
}
@Nested
@DisplayName
(
"addCountry method"
)
class
AddCountryTest
{
@Captor
ArgumentCaptor
<
Country
>
countryArgumentCaptor
;
@Test
@DisplayName
(
"When adding country, should be saved to repository"
)
public
void
addSavesCountry
(
@Mock
CountryRepository
countryRepository
)
{
Country
country
=
new
Country
();
sharedServiceDefault
.
addCountry
(
country
);
Mockito
.
verify
(
countryRepository
).
save
(
countryArgumentCaptor
.
capture
());
assertThat
(
countryArgumentCaptor
.
getValue
()).
isEqualTo
(
country
);
}
}
@Nested
@DisplayName
(
"getAllCountries method"
)
class
GetAllCountries
{
@Test
@DisplayName
(
"When requesting all countries, should ask all from repository"
)
public
void
getAllAsksAll
(
@Mock
CountryRepository
countryRepository
)
{
sharedServiceDefault
.
getAllCountries
();
Mockito
.
verify
(
countryRepository
).
findAll
();
}
}
}
Please
register
or
login
to post a comment