JR Utily

fix tests

......@@ -2,20 +2,15 @@ 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.*;
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;
......@@ -25,6 +20,7 @@ import static org.mockito.Mockito.when;
@RunWith(JUnitPlatform.class)
@ExtendWith(MockitoExtension.class)
@DisplayName("Indexes and searches with SearchRepository")
public class PublisherSearchRepositorySolrjTest {
private PublisherSearchRepository publisherSearchRepository;
......@@ -38,7 +34,7 @@ public class PublisherSearchRepositorySolrjTest {
@Nested
@DisplayName("save method")
class saveTests{
class saveTests {
@Test
@DisplayName("when called should addBean IndexedPublisher with commitWithinMs of 1 to repository")
......@@ -46,24 +42,14 @@ public class PublisherSearchRepositorySolrjTest {
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();
public void addBeanIOETest(@Mock IndexedPublisher indexedPublisher) throws SolrServerException, IOException {
when(solrClient.addBean(indexedPublisher, 1)).thenThrow(new IOException());
Assertions.assertThrows(IndexingException.class, () -> publisherSearchRepository.save(indexedPublisher));
}
try {
publisherSearchRepository.save(indexedPublisher);
} catch (IndexingException e) {
indexingException = e;
}
verify(ioException).equals(indexingException.getRootCause());
}
*/
}
}
......