Jean-Francois Leveque

Nouveaux tests, attention à celui qui est commenté dans PublisherSearchRepositorySolrjTest.

package org.legrog.entities;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
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.test.MockitoExtension;
import org.mockito.Mock;
import org.mockito.Mockito;
import java.io.IOException;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/*
Classe testant PublisherSearchRepositorySolrj
*/
@RunWith(JUnitPlatform.class)
@ExtendWith(MockitoExtension.class)
@DisplayName("Indexes and searches with SearchRepository")
public class PublisherSearchRepositorySolrjTest {
private PublisherSearchRepository publisherSearchRepository;
private SolrClient solrClient;
@BeforeEach
public void setup(@Mock SolrClient solrClient) {
publisherSearchRepository = new PublisherSearchRepositorySolrj(solrClient);
this.solrClient = solrClient;
}
@Nested
@DisplayName("save method")
class saveTests{
@Test
@DisplayName("when called should addBean IndexedPublisher with commitWithinMs of 1 to repository")
public void addBeanTest(@Mock IndexedPublisher indexedPublisher) throws IndexingException, SolrServerException, IOException {
publisherSearchRepository.save(indexedPublisher);
verify(solrClient).addBean(indexedPublisher, 1);
}
/*
@Test
@DisplayName("When call gets an IOException, should throw an IndexingException cobtaining it")
public void addBeanIOETest(@Mock IndexedPublisher indexedPublisher, @Mock IOException ioException) throws SolrServerException {
IndexingException indexingException = null;
try {
when(solrClient.addBean(indexedPublisher, 1)).thenThrow(ioException);
} catch (IOException e) {
e.printStackTrace();
}
try {
publisherSearchRepository.save(indexedPublisher);
} catch (IndexingException e) {
indexingException = e;
}
verify(ioException).equals(indexingException.getRootCause());
}
*/
}
}
......@@ -71,7 +71,7 @@ public class ListPublisherActionsViewTest {
@Test
@DisplayName("when publisher is set, should show only its actions")
public void testFilter(@Mock PublisherService publisherServiceMock) {
public void testFilter() {
List<PublisherAction> publisherActions = new ArrayList<PublisherAction>();
Publisher publisher = new Publisher();
......