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
2016-11-16 17:26:15 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cb6d34c7d9d7197dc64d983dbe43eeb14b5856a3
cb6d34c7
1 parent
4c5c0a92
Premiers tests de PublisherServiceSpring.
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
src/test/java/org/legrog/web/publisher/PublisherServiceSpringTest.java
src/test/java/org/legrog/web/publisher/PublisherServiceSpringTest.java
0 → 100644
View file @
cb6d34c
package
org
.
legrog
.
web
.
publisher
;
import
org.junit.Test
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.platform.runner.JUnitPlatform
;
import
org.junit.runner.RunWith
;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherRepository
;
import
org.legrog.entities.PublisherVersion
;
import
org.legrog.entities.PublisherVersionRepository
;
import
org.legrog.test.MockitoExtension
;
import
org.legrog.web.xyz.SharedService
;
import
org.mockito.Mock
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.*;
/**
* Classe testant PublisherServiceSpring.
*/
@RunWith
(
JUnitPlatform
.
class
)
@ExtendWith
(
MockitoExtension
.
class
)
@DisplayName
(
"Couche service de gestion d'éditeur"
)
public
class
PublisherServiceSpringTest
{
PublisherServiceSpring
publisherServiceSpring
;
PublisherVersion
publisherVersion
;
PublisherVersion
publisherVersion1
;
Publisher
publisher
;
PublisherRepository
publisherRepository
;
PublisherVersionRepository
publisherVersionRepository
;
@BeforeEach
public
void
setUp
(
@Mock
PublisherRepository
publisherRepository
,
@Mock
PublisherVersionRepository
publisherVersionRepository
,
@Mock
SharedService
sharedService
)
throws
Exception
{
publisherServiceSpring
=
new
PublisherServiceSpring
(
publisherRepository
,
publisherVersionRepository
,
sharedService
);
publisherVersion
=
new
PublisherVersion
();
publisherVersion1
=
new
PublisherVersion
();
this
.
publisherRepository
=
publisherRepository
;
}
@DisplayName
(
"Test ajout nouvel éditeur"
)
@Test
public
void
testAddNewPublisher
()
{
publisherServiceSpring
.
addNewPublisher
(
publisherVersion
);
publisher
=
publisherVersion
.
getPublisher
();
assertThat
(
publisher
.
getVersions
()).
containsExactly
(
publisherVersion
);
assertThat
(
publisherVersion
.
getPublisher
()).
isEqualTo
(
publisher
);
verify
(
publisherRepository
).
save
(
publisher
);
verify
(
publisherVersionRepository
).
save
(
publisherVersion
);
}
@DisplayName
(
"Test ajout nouvelle version éditeur"
)
@Test
public
void
testAddVersionToPublisher
()
{
publisherServiceSpring
.
addNewPublisher
(
publisherVersion
);
publisher
=
publisherVersion
.
getPublisher
();
publisherServiceSpring
.
addVersionToPublisher
(
publisher
,
publisherVersion1
);
assertThat
(
publisherVersion1
.
getPublisher
()).
isEqualTo
(
publisher
);
assertThat
(
publisher
.
getVersions
()).
contains
(
publisherVersion
,
publisherVersion1
);
verify
(
publisherRepository
).
save
(
publisher
);
verify
(
publisherVersionRepository
).
save
(
publisherVersion1
);
}
}
Please
register
or
login
to post a comment