hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ReducingPartsCountersStorageTest.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
3 #include "Exceptions.hpp"
4 
5 using namespace HCE::reduce;
6 
7 TEST(ReducingPartsCountersStorage, corectProcessFindRequests)
8 {
9  int validKey = 2442352714LLU;
10  int invalidKey = 7;
11 
12  ReducingPartsCountersStorage reducingPartsCountersStorage;
13 
14  reducingPartsCountersStorage.addReducingPartsCounterWithKey(validKey);
15 
16  EXPECT_TRUE(reducingPartsCountersStorage.findBy(validKey) == true);
17  EXPECT_TRUE(reducingPartsCountersStorage.findBy(invalidKey) == false);
18 }
19 
20 
21 TEST(ReducingPartsCountersStorage, correctAccumulateReducingPartsNumber)
22 {
23  int key = 2442352714LLU;
24 
25  ReducingPartsCountersStorage reducingPartsCountersStorage;
26 
27  reducingPartsCountersStorage.addReducingPartsCounterWithKey(key);
28  reducingPartsCountersStorage.incrementBy(key);
29 
30  ASSERT_EQ(reducingPartsCountersStorage.getAccumulateReducingParts(key), 1);
31 }
32 
33 
34 TEST(ReducingPartsCountersStorage, throwExceptionWhileTryIncrementByInvalidKey)
35 {
36  int invalidKey = 1;
37 
38  ReducingPartsCountersStorage reducingPartsCountersStorage;
39 
40  ASSERT_THROW(reducingPartsCountersStorage.incrementBy(invalidKey),
42 }
43 
44 
45 TEST(ReducingPartsCountersStorage, correctDeleteCountersByKey)
46 {
47  int key = 3;
48 
49  ReducingPartsCountersStorage reducingPartsCountersStorage;
50 
51  reducingPartsCountersStorage.addReducingPartsCounterWithKey(key);
52  reducingPartsCountersStorage.deleteBy(key);
53 
54  ASSERT_TRUE(reducingPartsCountersStorage.findBy(key) == false);
55 }
56 
57 
58 TEST(ReducingPartsCountersStorage, calculateNumbersOfTasksProcessingAtTheMoment)
59 {
60  int key1 = 4;
61  int key2 = 2;
62  unsigned int taskNumbers = 2;
63 
64  ReducingPartsCountersStorage reducingPartsCountersStorage;
65 
66  reducingPartsCountersStorage.addReducingPartsCounterWithKey(key1);
67  reducingPartsCountersStorage.addReducingPartsCounterWithKey(key2);
68 
69  ASSERT_EQ(reducingPartsCountersStorage.getTotalTasksNumber(), taskNumbers);
70 }