hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PocoJSONReducingOutputMessageConvertorTest.cpp
Go to the documentation of this file.
1 /*
2  * PocoJSONReducingOutputMessageConvertor.cpp
3  *
4  * Created on: May 29, 2013
5  * Author: igor
6  */
7 
8 #include <gtest/gtest.h>
9 #include <Poco/SharedPtr.h>
12 #include "TestUtils.hpp"
13 
14 using namespace HCE;
15 using namespace HCE::reduce_types;
16 using namespace HCE::reduce_convertors;
17 using namespace Poco;
18 using namespace std;
19 
20 
21 class PocoJSONReducingOutputMessageConvertorTest: public ::testing::Test{
22 protected:
23  virtual void SetUp(){
24  types::MessageType processingType = types::MessageType::mtSphinx;
25  int ttl = 7;
26  string body = "test body";
27  int processingErrorCode = 0;
28  string processingErrorMsg = "OK";
29  int processingElapsedTime = 120;
30 
31  reducingOutputMessage.assign(new ReducingOutputMessage(processingType, ttl, body,
32  processingErrorCode, processingErrorMsg, processingElapsedTime));
33  }
34 
35  virtual void TearDown(){
36  reducingOutputMessage.assign(NULL);
37  }
38 
39  static SharedPtr<ReducingOutputMessage> reducingOutputMessage;
40 };
41 SharedPtr<ReducingOutputMessage>PocoJSONReducingOutputMessageConvertorTest::
43 
44 
45 TEST_F(PocoJSONReducingOutputMessageConvertorTest, convertMessageInBothDirections)
46 {
47  PocoJSONReducingOutputMessageConvertor pocoJSONReducingOutputMessageConvertor;
48  string json = pocoJSONReducingOutputMessageConvertor.convertToJSONFrom(reducingOutputMessage);
49 
50  SharedPtr<ReducingOutputMessage> restoredReducingOutputMessage =
51  pocoJSONReducingOutputMessageConvertor.convertToReducingOutputMessageFrom(json);
52 
53  ASSERT_TRUE(isEqualReducingOutputMessage(*reducingOutputMessage.get(),
54  *restoredReducingOutputMessage.get()));
55 }