7 #include <gtest/gtest.h>
19 using namespace HCE::types;
20 using namespace HCE::reduce;
21 using namespace HCE::reduce_types;
22 using namespace HCE::sphinx;
23 using namespace HCE::sphinx::reduce_task;
30 itemId = 2442352714LLU;
40 reducingHandler.assign(
new ReducingHandler(reducingPartsCountersStorage,
41 reduceAdditionsStorage,
42 taskReducersManagerFactory,
43 reducingOutputMessageBuilder,
48 void buildSphinxResults()
65 sphinxRequestInfo1.setMaxResultsNumber(5);
66 sphinxRequestInfo1.setNodeName(
"nodeName1");
67 sphinxRequestInfo1.setQuery(
"query");
68 sphinxRequestInfo1.setTotal(10);
69 sphinxRequestInfo1.setTotalFound(150);
70 sphinxRequestInfo1.setTimeMsec(200);
71 sphinxRequestInfo1.addWordInfo(word1);
72 sphinxRequestInfo1.addWordInfo(word2);
74 sphinxRequestInfo2.setMaxResultsNumber(5);
75 sphinxRequestInfo2.setNodeName(
"nodeName2");
76 sphinxRequestInfo2.addWordInfo(word1);
77 sphinxRequestInfo2.addWordInfo(word2);
79 sphinxResultData1.addMatchInfo(matchInfo1);
80 sphinxResultData1.addMatchInfo(matchInfo2);
82 sphinxResultData2.addMatchInfo(matchInfo3);
83 sphinxResultData2.addMatchInfo(matchInfo4);
85 expectedSphinxResultData12.addMatchInfo(matchInfo3);
86 expectedSphinxResultData12.addMatchInfo(matchInfo1);
87 expectedSphinxResultData12.addMatchInfo(matchInfo4);
89 expectedSphinxResultData12.addRequestInfo(sphinxRequestInfo1);
90 expectedSphinxResultData12.addRequestInfo(sphinxRequestInfo2);
92 sphinxRequestInfo1.setMaxResultsNumber(2);
95 sphinxRequestInfo2.setMaxResultsNumber(2);
99 expectedSphinxResultData12DescSort.addMatchInfo(matchInfo3);
100 expectedSphinxResultData12DescSort.addMatchInfo(matchInfo4);
102 expectedSphinxResultData12DescSort.addRequestInfo(sphinxRequestInfo1);
103 expectedSphinxResultData12DescSort.addRequestInfo(sphinxRequestInfo2);
132 string errMsg =
"ReduceAdditionsStorage - not found key " + std::to_string(itemId);
137 reducingOutputMessage = reducingHandler->makeReducing(itemId);
139 *etalonOutputMessage.get()));
145 ASSERT_NO_THROW(reducingHandler->deleteReducingTaskBy(itemId));
151 ASSERT_THROW(reducingHandler->getAccumulateReducingPartsNumberBy(itemId),
158 sphinxRequestInfo1.setMaxResultsNumber(5);
159 sphinxRequestInfo1.setOrderBy(
NULL_SORT);
160 sphinxRequestInfo2.setMaxResultsNumber(5);
161 sphinxRequestInfo2.setOrderBy(
NULL_SORT);
163 sphinxResultData1.addRequestInfo(sphinxRequestInfo1);
164 sphinxResultData2.addRequestInfo(sphinxRequestInfo2);
169 etalonOutputMessage =
buildEtalonFrom(MessageType::mtSphinx, reducingInputMessage->getTTL(), json_output);
171 reducingHandler->accumulateReducingData(itemId, reducingInputMessage);
172 reducingOutputMessage = reducingHandler->makeReducing(itemId);
174 *etalonOutputMessage.get()));
180 sphinxRequestInfo1.setMaxResultsNumber(5);
181 sphinxRequestInfo1.setOrderBy(
NULL_SORT);
182 sphinxRequestInfo2.setMaxResultsNumber(5);
183 sphinxRequestInfo2.setOrderBy(
NULL_SORT);
185 sphinxResultData1.addRequestInfo(sphinxRequestInfo1);
186 sphinxResultData2.addRequestInfo(sphinxRequestInfo2);
193 etalonOutputMessage =
buildEtalonFrom(MessageType::mtSphinx, reducingInputMessage->getTTL(), expectedJSON);
195 reducingHandler->accumulateReducingData(itemId, reducingInputMessage);
196 reducingHandler->accumulateReducingData(itemId, reducingInputMessage2);
197 reducingOutputMessage = reducingHandler->makeReducing(itemId);
200 *etalonOutputMessage.get()));
206 sphinxResultData1.addRequestInfo(sphinxRequestInfo1);
207 sphinxResultData2.addRequestInfo(sphinxRequestInfo2);
214 etalonOutputMessage =
buildEtalonFrom(MessageType::mtSphinx, reducingInputMessage->getTTL(), expectedJSON);
216 reducingHandler->accumulateReducingData(itemId, reducingInputMessage);
217 reducingHandler->accumulateReducingData(itemId, reducingInputMessage2);
218 reducingOutputMessage = reducingHandler->makeReducing(itemId);
221 *etalonOutputMessage.get()));