Showing
9 changed files
with
75 additions
and
20 deletions
... | @@ -26,7 +26,7 @@ public interface AccountService { | ... | @@ -26,7 +26,7 @@ public interface AccountService { |
26 | /** | 26 | /** |
27 | * | 27 | * |
28 | * @param indexedAccounts IndexedAccount to convert | 28 | * @param indexedAccounts IndexedAccount to convert |
29 | - * @return Accounts | 29 | + * @return Account List |
30 | */ | 30 | */ |
31 | - List<Account> convert(List<IndexedAccount> indexedAccounts); | 31 | + List<Account> convertIndexedAccountsIntoAccounts(List<IndexedAccount> indexedAccounts); |
32 | } | 32 | } | ... | ... |
... | @@ -48,11 +48,11 @@ public class AccountServiceDefault implements AccountService { | ... | @@ -48,11 +48,11 @@ public class AccountServiceDefault implements AccountService { |
48 | 48 | ||
49 | @Override | 49 | @Override |
50 | public List<Account> search(@NotNull String string) throws SearchingException { | 50 | public List<Account> search(@NotNull String string) throws SearchingException { |
51 | - return convert(accountSearchRepository.search(string)); | 51 | + return convertIndexedAccountsIntoAccounts(accountSearchRepository.search(string)); |
52 | } | 52 | } |
53 | 53 | ||
54 | @Override | 54 | @Override |
55 | - public List<Account> convert(List<IndexedAccount> indexedAccounts) { | 55 | + public List<Account> convertIndexedAccountsIntoAccounts(List<IndexedAccount> indexedAccounts) { |
56 | List<Integer> integers = new ArrayList<>(indexedAccounts.size()); | 56 | List<Integer> integers = new ArrayList<>(indexedAccounts.size()); |
57 | indexedAccounts.forEach(indexedAccount -> integers.add(indexedAccount.getUserId())); | 57 | indexedAccounts.forEach(indexedAccount -> integers.add(indexedAccount.getUserId())); |
58 | 58 | ... | ... |
... | @@ -80,8 +80,8 @@ public interface PublisherService { | ... | @@ -80,8 +80,8 @@ public interface PublisherService { |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * | 82 | * |
83 | - * @param indexedPublishers IndexedPublisher List | 83 | + * @param indexedPublishers to convert |
84 | * @return PublisherVersion List | 84 | * @return PublisherVersion List |
85 | */ | 85 | */ |
86 | - List<PublisherVersion> convert(List<IndexedPublisher> indexedPublishers); | 86 | + List<PublisherVersion> convertIndexedPublishersIntoPublisherVersions(List<IndexedPublisher> indexedPublishers); |
87 | } | 87 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -138,11 +138,11 @@ public class PublisherServiceDefault implements PublisherService { | ... | @@ -138,11 +138,11 @@ public class PublisherServiceDefault implements PublisherService { |
138 | 138 | ||
139 | @Override | 139 | @Override |
140 | public List<PublisherVersion> search(@NotNull String string) throws SearchingException { | 140 | public List<PublisherVersion> search(@NotNull String string) throws SearchingException { |
141 | - return convert(publisherSearchRepository.search(string)); | 141 | + return convertIndexedPublishersIntoPublisherVersions(publisherSearchRepository.search(string)); |
142 | } | 142 | } |
143 | 143 | ||
144 | @Override | 144 | @Override |
145 | - public List<PublisherVersion> convert(List<IndexedPublisher> indexedPublishers) { | 145 | + public List<PublisherVersion> convertIndexedPublishersIntoPublisherVersions(List<IndexedPublisher> indexedPublishers) { |
146 | List<Integer> integers = new ArrayList<>(indexedPublishers.size()); | 146 | List<Integer> integers = new ArrayList<>(indexedPublishers.size()); |
147 | indexedPublishers.forEach(indexedPublisher -> integers.add(indexedPublisher.getPublisherId())); | 147 | indexedPublishers.forEach(indexedPublisher -> integers.add(indexedPublisher.getPublisherId())); |
148 | 148 | ... | ... |
1 | +package org.legrog.web.xyz; | ||
2 | + | ||
3 | +import javax.enterprise.context.RequestScoped; | ||
4 | +import javax.inject.Named; | ||
5 | +import java.io.Serializable; | ||
6 | + | ||
7 | +/** | ||
8 | + * View for reindex.xhtml | ||
9 | + */ | ||
10 | +@Named | ||
11 | +@RequestScoped | ||
12 | +public class ReindexView implements Serializable { | ||
13 | + private int indexedAccountsNumber; | ||
14 | + private int indexedPublishersNumber; | ||
15 | + | ||
16 | + ReindexView() { | ||
17 | + //no args constructor to make it proxyable | ||
18 | + } | ||
19 | + | ||
20 | + | ||
21 | + | ||
22 | + public int getIndexedAccountsNumber() { | ||
23 | + return indexedAccountsNumber; | ||
24 | + } | ||
25 | + | ||
26 | + public void setIndexedAccountsNumber(int indexedAccountsNumber) { | ||
27 | + this.indexedAccountsNumber = indexedAccountsNumber; | ||
28 | + } | ||
29 | + | ||
30 | + public int getIndexedPublishersNumber() { | ||
31 | + return indexedPublishersNumber; | ||
32 | + } | ||
33 | + | ||
34 | + public void setIndexedPublishersNumber(int indexedPublishersNumber) { | ||
35 | + this.indexedPublishersNumber = indexedPublishersNumber; | ||
36 | + } | ||
37 | +} |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
3 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
4 | +<html xmlns="http://www.w3.org/1999/xhtml" | ||
5 | + xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
6 | + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | ||
7 | + xmlns:f="http://xmlns.jcp.org/jsf/core"> | ||
8 | +<f:view> | ||
9 | + <h:outputLabel value="Hello, world"/> | ||
10 | +</f:view> | ||
11 | +</html> |
... | @@ -40,22 +40,22 @@ public class AccountServiceDefaultTest { | ... | @@ -40,22 +40,22 @@ public class AccountServiceDefaultTest { |
40 | 40 | ||
41 | } | 41 | } |
42 | 42 | ||
43 | - @DisplayName("When getting IndexedAccounts from search, should convert them") | 43 | + @DisplayName("When getting IndexedAccounts from search, should convertIndexedAccountsIntoAccounts them") |
44 | @Test | 44 | @Test |
45 | public void testConvertReturnedIndexedAccounts(@Mock AccountSearchRepository accountSearchRepository) throws SearchingException { | 45 | public void testConvertReturnedIndexedAccounts(@Mock AccountSearchRepository accountSearchRepository) throws SearchingException { |
46 | List<IndexedAccount> indexedAccounts = new ArrayList<>(); | 46 | List<IndexedAccount> indexedAccounts = new ArrayList<>(); |
47 | 47 | ||
48 | when(accountSearchRepository.search("4")).thenReturn(indexedAccounts); | 48 | when(accountSearchRepository.search("4")).thenReturn(indexedAccounts); |
49 | accountServiceDefault.search("4"); | 49 | accountServiceDefault.search("4"); |
50 | - verify(accountServiceDefault, times(1)).convert(indexedAccounts); | 50 | + verify(accountServiceDefault, times(1)).convertIndexedAccountsIntoAccounts(indexedAccounts); |
51 | } | 51 | } |
52 | 52 | ||
53 | - @DisplayName("When called, should return the Accounts it gets from convert") | 53 | + @DisplayName("When called, should return the Accounts it gets from convertIndexedAccountsIntoAccounts") |
54 | @Test | 54 | @Test |
55 | public void testReturnFromConvert(@Mock AccountSearchRepository accountSearchRepository) throws SearchingException { | 55 | public void testReturnFromConvert(@Mock AccountSearchRepository accountSearchRepository) throws SearchingException { |
56 | List<Account> accounts = new ArrayList<>(); | 56 | List<Account> accounts = new ArrayList<>(); |
57 | List<IndexedAccount> indexedAccounts = new ArrayList<>(); | 57 | List<IndexedAccount> indexedAccounts = new ArrayList<>(); |
58 | - Mockito.doReturn(accounts).when(accountServiceDefault).convert(indexedAccounts); | 58 | + Mockito.doReturn(accounts).when(accountServiceDefault).convertIndexedAccountsIntoAccounts(indexedAccounts); |
59 | when(accountSearchRepository.search("5")).thenReturn(indexedAccounts); | 59 | when(accountSearchRepository.search("5")).thenReturn(indexedAccounts); |
60 | assertThat(accountServiceDefault.search("5")).isEqualTo(accounts); | 60 | assertThat(accountServiceDefault.search("5")).isEqualTo(accounts); |
61 | } | 61 | } |
... | @@ -63,7 +63,7 @@ public class AccountServiceDefaultTest { | ... | @@ -63,7 +63,7 @@ public class AccountServiceDefaultTest { |
63 | } | 63 | } |
64 | 64 | ||
65 | @Nested | 65 | @Nested |
66 | - @DisplayName("convert method") | 66 | + @DisplayName("convertIndexedAccountsIntoAccounts method") |
67 | class ConvertTests { | 67 | class ConvertTests { |
68 | @DisplayName("When called, should return the Accounts it gets from findByUserIdIn") | 68 | @DisplayName("When called, should return the Accounts it gets from findByUserIdIn") |
69 | @Test | 69 | @Test |
... | @@ -71,7 +71,7 @@ public class AccountServiceDefaultTest { | ... | @@ -71,7 +71,7 @@ public class AccountServiceDefaultTest { |
71 | List<Account> accounts = new ArrayList<>(); | 71 | List<Account> accounts = new ArrayList<>(); |
72 | List<IndexedAccount> indexedAccounts = new ArrayList<>(); | 72 | List<IndexedAccount> indexedAccounts = new ArrayList<>(); |
73 | when(accountRepository.findByUserIdIn(Mockito.any())).thenReturn(accounts); | 73 | when(accountRepository.findByUserIdIn(Mockito.any())).thenReturn(accounts); |
74 | - assertThat(accountServiceDefault.convert(indexedAccounts)).isEqualTo(accounts); | 74 | + assertThat(accountServiceDefault.convertIndexedAccountsIntoAccounts(indexedAccounts)).isEqualTo(accounts); |
75 | } | 75 | } |
76 | 76 | ||
77 | } | 77 | } | ... | ... |
... | @@ -170,22 +170,22 @@ public class PublisherServiceDefaultTest { | ... | @@ -170,22 +170,22 @@ public class PublisherServiceDefaultTest { |
170 | 170 | ||
171 | } | 171 | } |
172 | 172 | ||
173 | - @DisplayName("When getting IndexedPublishers from search, should convert them") | 173 | + @DisplayName("When getting IndexedPublishers from search, should convertIndexedAccountsIntoAccounts them") |
174 | @Test | 174 | @Test |
175 | public void testConvertReturnedIndexedPublishers(@Mock PublisherSearchRepository publisherSearchRepository) throws SearchingException { | 175 | public void testConvertReturnedIndexedPublishers(@Mock PublisherSearchRepository publisherSearchRepository) throws SearchingException { |
176 | List<IndexedPublisher> indexedPublishers = new ArrayList<>(); | 176 | List<IndexedPublisher> indexedPublishers = new ArrayList<>(); |
177 | 177 | ||
178 | when(publisherSearchRepository.search("4")).thenReturn(indexedPublishers); | 178 | when(publisherSearchRepository.search("4")).thenReturn(indexedPublishers); |
179 | publisherServiceDefault.search("4"); | 179 | publisherServiceDefault.search("4"); |
180 | - verify(publisherServiceDefault, times(1)).convert(indexedPublishers); | 180 | + verify(publisherServiceDefault, times(1)).convertIndexedPublishersIntoPublisherVersions(indexedPublishers); |
181 | } | 181 | } |
182 | 182 | ||
183 | - @DisplayName("When called, should return the PublisherVersions it gets from convert") | 183 | + @DisplayName("When called, should return the PublisherVersions it gets from convertIndexedAccountsIntoAccounts") |
184 | @Test | 184 | @Test |
185 | public void testReturnFromConvert(@Mock PublisherSearchRepository publisherSearchRepository) throws SearchingException { | 185 | public void testReturnFromConvert(@Mock PublisherSearchRepository publisherSearchRepository) throws SearchingException { |
186 | List<PublisherVersion> publisherVersions = new ArrayList<>(); | 186 | List<PublisherVersion> publisherVersions = new ArrayList<>(); |
187 | List<IndexedPublisher> indexedPublishers = new ArrayList<>(); | 187 | List<IndexedPublisher> indexedPublishers = new ArrayList<>(); |
188 | - Mockito.doReturn(publisherVersions).when(publisherServiceDefault).convert(indexedPublishers); | 188 | + Mockito.doReturn(publisherVersions).when(publisherServiceDefault).convertIndexedPublishersIntoPublisherVersions(indexedPublishers); |
189 | when(publisherSearchRepository.search("5")).thenReturn(indexedPublishers); | 189 | when(publisherSearchRepository.search("5")).thenReturn(indexedPublishers); |
190 | assertThat(publisherServiceDefault.search("5")).isEqualTo(publisherVersions); | 190 | assertThat(publisherServiceDefault.search("5")).isEqualTo(publisherVersions); |
191 | } | 191 | } |
... | @@ -193,7 +193,7 @@ public class PublisherServiceDefaultTest { | ... | @@ -193,7 +193,7 @@ public class PublisherServiceDefaultTest { |
193 | } | 193 | } |
194 | 194 | ||
195 | @Nested | 195 | @Nested |
196 | - @DisplayName("convert method") | 196 | + @DisplayName("convertIndexedAccountsIntoAccounts method") |
197 | class ConvertTests { | 197 | class ConvertTests { |
198 | @DisplayName("When called, should return the PublisherVersions it gets from findByPublisherVersionIdIn") | 198 | @DisplayName("When called, should return the PublisherVersions it gets from findByPublisherVersionIdIn") |
199 | @Test | 199 | @Test |
... | @@ -201,7 +201,7 @@ public class PublisherServiceDefaultTest { | ... | @@ -201,7 +201,7 @@ public class PublisherServiceDefaultTest { |
201 | List<PublisherVersion> publisherVersions = new ArrayList<>(); | 201 | List<PublisherVersion> publisherVersions = new ArrayList<>(); |
202 | List<IndexedPublisher> indexedPublishers = new ArrayList<>(); | 202 | List<IndexedPublisher> indexedPublishers = new ArrayList<>(); |
203 | when(publisherVersionRepository.findByPublisherVersionIdIn(Mockito.any())).thenReturn(publisherVersions); | 203 | when(publisherVersionRepository.findByPublisherVersionIdIn(Mockito.any())).thenReturn(publisherVersions); |
204 | - assertThat(publisherServiceDefault.convert(indexedPublishers)).isEqualTo(publisherVersions); | 204 | + assertThat(publisherServiceDefault.convertIndexedPublishersIntoPublisherVersions(indexedPublishers)).isEqualTo(publisherVersions); |
205 | } | 205 | } |
206 | 206 | ||
207 | } | 207 | } | ... | ... |
-
Please register or login to post a comment