hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ReduceAdditionsStorageTests.cpp
Go to the documentation of this file.
1 /*
2  * SphinxTaskReducersStorageTest.cpp
3  *
4  * Created on: May 20, 2013
5  * Author: igor
6  */
7 
8 #include <gtest/gtest.h>
10 #include "Exceptions.hpp"
11 
12 using namespace HCE::reduce;
13 using namespace Poco;
14 
15 TEST(ReduceAdditionsStorage, returnReducerByValidKey)
16 {
17  ReduceAdditionsStorage reduceAdditionsStorage;
18  SharedPtr<additions::TaskReducersManagerIf>taskReducersManager;
19  unsigned int taskId = 1;
20 
21  reduceAdditionsStorage.addWith(taskId, taskReducersManager);
22 
23  ASSERT_EQ(taskReducersManager, reduceAdditionsStorage.findBy(taskId));
24 }
25 
26 TEST(ReduceAdditionsStorage, returnReducerByValidSecondKey)
27 {
28  ReduceAdditionsStorage reduceAdditionsStorage;
29  SharedPtr<additions::TaskReducersManagerIf>taskReducersManager;
30  unsigned long long secondKey = 1;
31 
32  reduceAdditionsStorage.addWith(secondKey, taskReducersManager);
33 
34  ASSERT_EQ(taskReducersManager, reduceAdditionsStorage.findBy(secondKey));
35 }
36 
37 
38 TEST(ReduceAdditionsStorage, throwNotFoundSphinxTaskReducerExceptionWhileDeleteByInvalidKey)
39 {
40  ReduceAdditionsStorage reduceAdditionsStorage;
41  int invalidTaskId = 8;
42 
43  ASSERT_THROW(reduceAdditionsStorage.deleteBy(invalidTaskId), NotFoundByKeyException);
44 }
45 
46 
47 TEST(ReduceAdditionsStorage, throwNotFoundSphinxTaskReducerExceptionWhileSearchByInvalidSecondKey)
48 {
49  ReduceAdditionsStorage reduceAdditionsStorage;
50  unsigned long long invalidTaskId = 8;
51 
52  ASSERT_THROW(reduceAdditionsStorage.findBy(invalidTaskId), NotFoundByKeyException);
53 }
54 
55 
56 TEST(ReduceAdditionsStorage, correctDeleteSphinxTaskReducerByValidSecondKey)
57 {
58  ReduceAdditionsStorage reduceAdditionsStorage;
59  SharedPtr<additions::TaskReducersManagerIf>taskReducersManager;
60 
61  unsigned long long secondKey = 1;
62  reduceAdditionsStorage.addWith(secondKey, taskReducersManager);
63  reduceAdditionsStorage.deleteBy(secondKey);
64 
65  ASSERT_THROW(reduceAdditionsStorage.findBy(secondKey), NotFoundByKeyException);
66 }