hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ScheduleStrategySingleTest.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 #include <gmock/gmock.h>
3 #include "ReduceTaskCore.hpp"
4 #include "CoreMocks.hpp"
6 
7 using namespace HCE::reduce::core;
8 using namespace Poco;
9 using namespace std;
10 
11 using ::testing::_;
12 using ::testing::InSequence;
13 using ::testing::Return;
14 using ::testing::ReturnPointee;
15 using ::testing::SetArgReferee;
16 
17 TEST(scheduleStrategySingle, sequenceCallEmptyObjects)
18 {
19  ScheduleStrategySingle scheduleStrategySingle;
20 
21  SharedPtr<IterableMock>reduceStorageMock(new IterableMock());
22  SharedPtr<ReduceResultMock>reduceResultMock(new ReduceResultMock());
23  SharedPtr<ReduceTaskMock>reduceTaskMock(new ReduceTaskMock());
24  SharedPtr<ReduceJobMock>reduceJobMock(new ReduceJobMock());
25 
26  InSequence s;
27 
28  EXPECT_CALL(*reduceJobMock.get(), getDataStorage())
29  .WillOnce(ReturnPointee(&reduceStorageMock));
30  EXPECT_CALL(*reduceJobMock.get(), getReduceTask())
31  .WillOnce(ReturnPointee(&reduceTaskMock));
32  EXPECT_CALL(*reduceStorageMock.get(), reset())
33  .Times(1);
34  EXPECT_CALL(*reduceStorageMock.get(), hasNext())
35  .WillOnce(Return(false));
36  EXPECT_CALL(*reduceJobMock.get(), getReduceResult())
37  .WillOnce(ReturnPointee(&reduceResultMock));
38 
39  EXPECT_CALL(*reduceJobMock.get(), getReduceTask())
40  .WillOnce(ReturnPointee(&reduceTaskMock));
41 
42  EXPECT_CALL(*reduceTaskMock.get(), fillReduceResult(_))
43  .Times(1);
44 
45  scheduleStrategySingle.executeJob(reduceJobMock);
46 }
47 
48 
49 TEST(scheduleStrategySingle, sequenceCallProcessSomeData)
50 {
51  ScheduleStrategySingle scheduleStrategySingle;
52 
53  SharedPtr<IterableMock>reduceStorageMock(new IterableMock());
54  SharedPtr<ReduceResultMock>reduceResultMock(new ReduceResultMock());
55  SharedPtr<ReduceTaskMock>reduceTaskMock(new ReduceTaskMock());
56  SharedPtr<ReduceJobMock>reduceJobMock(new ReduceJobMock());
57 
58  string val = "";
59 
60  InSequence s;
61 
62  EXPECT_CALL(*reduceJobMock.get(), getDataStorage())
63  .WillOnce(ReturnPointee(&reduceStorageMock));
64  EXPECT_CALL(*reduceJobMock.get(), getReduceTask())
65  .WillOnce(ReturnPointee(&reduceTaskMock));
66  EXPECT_CALL(*reduceStorageMock.get(), reset())
67  .Times(1);
68  EXPECT_CALL(*reduceStorageMock.get(), hasNext())
69  .WillOnce(Return(true));
70  //data fill loop
71  EXPECT_CALL(*reduceStorageMock.get(), getNext(_, _))
72  .WillOnce(DoAll(SetArgReferee<0>(val), SetArgReferee<1>(val)));
73 
74  EXPECT_CALL(*reduceTaskMock.get(), addKeyValue(_, _))
75  .Times(1);
76  EXPECT_CALL(*reduceStorageMock.get(), hasNext())
77  .WillOnce(Return(false));
78 
79  EXPECT_CALL(*reduceJobMock.get(), getReduceResult())
80  .WillOnce(ReturnPointee(&reduceResultMock));
81  EXPECT_CALL(*reduceJobMock.get(), getReduceTask())
82  .WillOnce(ReturnPointee(&reduceTaskMock));
83  EXPECT_CALL(*reduceTaskMock.get(), fillReduceResult(_))
84  .Times(1);
85 
86  scheduleStrategySingle.executeJob(reduceJobMock);
87 }