Jean-Francois Leveque

Nommage plus clair et uniformisation des commentaires

......@@ -26,7 +26,7 @@ public interface AccountService {
/**
*
* @param indexedAccounts IndexedAccount to convert
* @return Accounts
* @return Account List
*/
List<Account> convert(List<IndexedAccount> indexedAccounts);
List<Account> convertIndexedAccountsIntoAccounts(List<IndexedAccount> indexedAccounts);
}
......
......@@ -48,11 +48,11 @@ public class AccountServiceDefault implements AccountService {
@Override
public List<Account> search(@NotNull String string) throws SearchingException {
return convert(accountSearchRepository.search(string));
return convertIndexedAccountsIntoAccounts(accountSearchRepository.search(string));
}
@Override
public List<Account> convert(List<IndexedAccount> indexedAccounts) {
public List<Account> convertIndexedAccountsIntoAccounts(List<IndexedAccount> indexedAccounts) {
List<Integer> integers = new ArrayList<>(indexedAccounts.size());
indexedAccounts.forEach(indexedAccount -> integers.add(indexedAccount.getUserId()));
......
......@@ -80,8 +80,8 @@ public interface PublisherService {
/**
*
* @param indexedPublishers IndexedPublisher List
* @param indexedPublishers to convert
* @return PublisherVersion List
*/
List<PublisherVersion> convert(List<IndexedPublisher> indexedPublishers);
List<PublisherVersion> convertIndexedPublishersIntoPublisherVersions(List<IndexedPublisher> indexedPublishers);
}
\ No newline at end of file
......
......@@ -138,11 +138,11 @@ public class PublisherServiceDefault implements PublisherService {
@Override
public List<PublisherVersion> search(@NotNull String string) throws SearchingException {
return convert(publisherSearchRepository.search(string));
return convertIndexedPublishersIntoPublisherVersions(publisherSearchRepository.search(string));
}
@Override
public List<PublisherVersion> convert(List<IndexedPublisher> indexedPublishers) {
public List<PublisherVersion> convertIndexedPublishersIntoPublisherVersions(List<IndexedPublisher> indexedPublishers) {
List<Integer> integers = new ArrayList<>(indexedPublishers.size());
indexedPublishers.forEach(indexedPublisher -> integers.add(indexedPublisher.getPublisherId()));
......
package org.legrog.web.xyz;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import java.io.Serializable;
/**
* View for reindex.xhtml
*/
@Named
@RequestScoped
public class ReindexView implements Serializable {
private int indexedAccountsNumber;
private int indexedPublishersNumber;
ReindexView() {
//no args constructor to make it proxyable
}
public int getIndexedAccountsNumber() {
return indexedAccountsNumber;
}
public void setIndexedAccountsNumber(int indexedAccountsNumber) {
this.indexedAccountsNumber = indexedAccountsNumber;
}
public int getIndexedPublishersNumber() {
return indexedPublishersNumber;
}
public void setIndexedPublishersNumber(int indexedPublishersNumber) {
this.indexedPublishersNumber = indexedPublishersNumber;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:outputLabel value="Hello, world"/>
</f:view>
</html>
......@@ -40,22 +40,22 @@ public class AccountServiceDefaultTest {
}
@DisplayName("When getting IndexedAccounts from search, should convert them")
@DisplayName("When getting IndexedAccounts from search, should convertIndexedAccountsIntoAccounts them")
@Test
public void testConvertReturnedIndexedAccounts(@Mock AccountSearchRepository accountSearchRepository) throws SearchingException {
List<IndexedAccount> indexedAccounts = new ArrayList<>();
when(accountSearchRepository.search("4")).thenReturn(indexedAccounts);
accountServiceDefault.search("4");
verify(accountServiceDefault, times(1)).convert(indexedAccounts);
verify(accountServiceDefault, times(1)).convertIndexedAccountsIntoAccounts(indexedAccounts);
}
@DisplayName("When called, should return the Accounts it gets from convert")
@DisplayName("When called, should return the Accounts it gets from convertIndexedAccountsIntoAccounts")
@Test
public void testReturnFromConvert(@Mock AccountSearchRepository accountSearchRepository) throws SearchingException {
List<Account> accounts = new ArrayList<>();
List<IndexedAccount> indexedAccounts = new ArrayList<>();
Mockito.doReturn(accounts).when(accountServiceDefault).convert(indexedAccounts);
Mockito.doReturn(accounts).when(accountServiceDefault).convertIndexedAccountsIntoAccounts(indexedAccounts);
when(accountSearchRepository.search("5")).thenReturn(indexedAccounts);
assertThat(accountServiceDefault.search("5")).isEqualTo(accounts);
}
......@@ -63,7 +63,7 @@ public class AccountServiceDefaultTest {
}
@Nested
@DisplayName("convert method")
@DisplayName("convertIndexedAccountsIntoAccounts method")
class ConvertTests {
@DisplayName("When called, should return the Accounts it gets from findByUserIdIn")
@Test
......@@ -71,7 +71,7 @@ public class AccountServiceDefaultTest {
List<Account> accounts = new ArrayList<>();
List<IndexedAccount> indexedAccounts = new ArrayList<>();
when(accountRepository.findByUserIdIn(Mockito.any())).thenReturn(accounts);
assertThat(accountServiceDefault.convert(indexedAccounts)).isEqualTo(accounts);
assertThat(accountServiceDefault.convertIndexedAccountsIntoAccounts(indexedAccounts)).isEqualTo(accounts);
}
}
......
......@@ -170,22 +170,22 @@ public class PublisherServiceDefaultTest {
}
@DisplayName("When getting IndexedPublishers from search, should convert them")
@DisplayName("When getting IndexedPublishers from search, should convertIndexedAccountsIntoAccounts them")
@Test
public void testConvertReturnedIndexedPublishers(@Mock PublisherSearchRepository publisherSearchRepository) throws SearchingException {
List<IndexedPublisher> indexedPublishers = new ArrayList<>();
when(publisherSearchRepository.search("4")).thenReturn(indexedPublishers);
publisherServiceDefault.search("4");
verify(publisherServiceDefault, times(1)).convert(indexedPublishers);
verify(publisherServiceDefault, times(1)).convertIndexedPublishersIntoPublisherVersions(indexedPublishers);
}
@DisplayName("When called, should return the PublisherVersions it gets from convert")
@DisplayName("When called, should return the PublisherVersions it gets from convertIndexedAccountsIntoAccounts")
@Test
public void testReturnFromConvert(@Mock PublisherSearchRepository publisherSearchRepository) throws SearchingException {
List<PublisherVersion> publisherVersions = new ArrayList<>();
List<IndexedPublisher> indexedPublishers = new ArrayList<>();
Mockito.doReturn(publisherVersions).when(publisherServiceDefault).convert(indexedPublishers);
Mockito.doReturn(publisherVersions).when(publisherServiceDefault).convertIndexedPublishersIntoPublisherVersions(indexedPublishers);
when(publisherSearchRepository.search("5")).thenReturn(indexedPublishers);
assertThat(publisherServiceDefault.search("5")).isEqualTo(publisherVersions);
}
......@@ -193,7 +193,7 @@ public class PublisherServiceDefaultTest {
}
@Nested
@DisplayName("convert method")
@DisplayName("convertIndexedAccountsIntoAccounts method")
class ConvertTests {
@DisplayName("When called, should return the PublisherVersions it gets from findByPublisherVersionIdIn")
@Test
......@@ -201,7 +201,7 @@ public class PublisherServiceDefaultTest {
List<PublisherVersion> publisherVersions = new ArrayList<>();
List<IndexedPublisher> indexedPublishers = new ArrayList<>();
when(publisherVersionRepository.findByPublisherVersionIdIn(Mockito.any())).thenReturn(publisherVersions);
assertThat(publisherServiceDefault.convert(indexedPublishers)).isEqualTo(publisherVersions);
assertThat(publisherServiceDefault.convertIndexedPublishersIntoPublisherVersions(indexedPublishers)).isEqualTo(publisherVersions);
}
}
......
package org.legrog.web.xyz;
/**
* Classe testing ReindexView
*/
public class ReindexViewTest {
}