7 #include <gtest/gtest.h>
12 #include <Poco/SharedPtr.h>
20 using namespace HCE::sphinx;
21 using namespace HCE::sphinx::reduce_task;
22 using namespace HCE::reduce::core;
27 using ::testing::InSequence;
28 using ::testing::SetArgReferee;
29 using ::testing::Return;
30 using ::testing::ReturnPointee;
31 using ::testing::ReturnRef;
35 TEST(SphinxReducerTestMock, fillDataStorage)
39 SharedPtr<SphinxResultDataAccumulatorMock>sphinxResultDataAccumulator(
46 SharedPtr<ReduceJobMock> sphinxReduceJobMock(
new ReduceJobMock());
48 SharedPtr<SphinxResultData> sphinxResultAfterReducing;
52 EXPECT_CALL(sphinxReduceJobBuilder, build())
53 .WillOnce(ReturnPointee(&sphinxReduceJobMock));
55 EXPECT_CALL(*sphinxReduceJobMock.get(), getDataStorage())
56 .WillOnce(ReturnPointee(&sphinxReduceDataStorage));
58 EXPECT_CALL(sphinxResultDataAccumulatorFactory, build(_))
59 .WillOnce(ReturnPointee(&sphinxResultDataAccumulator));
61 EXPECT_CALL(*sphinxResultDataAccumulator.get(), accumulate(_))
63 EXPECT_CALL(scheduleStrategy, executeJob(_))
66 EXPECT_CALL(*sphinxReduceJobMock.get(), getReduceResult())
67 .WillOnce(ReturnPointee(&sphinxReduceResult));
68 EXPECT_CALL(*sphinxResultDataAccumulator.get(), getSphinxDataStorage())
69 .WillOnce(ReturnPointee(&sphinxReduceDataStorage));
70 EXPECT_CALL(*sphinxResultDataAccumulator.get(), getAllSphinxRequestInfo())
71 .WillOnce(ReturnRef(requestInfo));
72 EXPECT_CALL(sphinxResultBuilder, build(_, _,_))
73 .WillOnce(ReturnPointee(&sphinxResultAfterReducing));
76 sphinxResultDataAccumulatorFactory);
81 sphinxReducer.
addData(sphinxResultData1);
82 sphinxReducer.
addData(sphinxResultData2);
83 sphinxReducer.
reduce(scheduleStrategy);
84 sphinxResultAfterReducing = sphinxReducer.
getResult();