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 10:37:19 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
175db56e5ea9b390444e4126d4fda05fddd151bb
175db56e
1 parent
978a4054
Nouveau test de contrôle des exceptions côté Solr.
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
src/test/java/org/legrog/entities/PublisherSearchRepositorySolrjTest.java
src/test/java/org/legrog/entities/PublisherSearchRepositorySolrjTest.java
View file @
175db56
...
...
@@ -2,6 +2,7 @@ package org.legrog.entities;
import
org.apache.solr.client.solrj.SolrClient
;
import
org.apache.solr.client.solrj.SolrServerException
;
import
org.apache.solr.client.solrj.beans.BindingException
;
import
org.junit.jupiter.api.*
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.platform.runner.JUnitPlatform
;
...
...
@@ -14,6 +15,8 @@ import java.io.IOException;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/*
Classe testant PublisherSearchRepositorySolrj
*/
...
...
@@ -44,12 +47,22 @@ public class PublisherSearchRepositorySolrjTest {
}
@Test
@DisplayName
(
"When repository in error, should throw an IndexingException"
)
@DisplayName
(
"When repository in
IO
error, should throw an IndexingException"
)
public
void
addBeanIOETest
(
@Mock
IndexedPublisher
indexedPublisher
)
throws
SolrServerException
,
IOException
{
when
(
solrClient
.
addBean
(
indexedPublisher
,
1
)).
thenThrow
(
new
IOException
());
Assertions
.
assertThrows
(
IndexingException
.
class
,
()
->
publisherSearchRepository
.
save
(
indexedPublisher
));
}
@Test
@DisplayName
(
"When repository in SolrServerException, should throw an IndexingException with its root cause"
)
public
void
addBeanSSETest
(
@Mock
IndexedPublisher
indexedPublisher
)
throws
SolrServerException
,
IOException
{
when
(
solrClient
.
addBean
(
indexedPublisher
,
1
)).
thenThrow
(
new
SolrServerException
(
new
BindingException
(
"BE test"
)));
try
{
publisherSearchRepository
.
save
(
indexedPublisher
);
}
catch
(
IndexingException
ie
)
{
assertThat
(
ie
.
getRootCause
().
getClass
()).
isEqualTo
(
BindingException
.
class
);
}
}
}
}
...
...
Please
register
or
login
to post a comment