hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PocoJSONReducingInputMessageConvertorTest.cpp
Go to the documentation of this file.
1 /*
2  * PocoJSONReducingInputMessageConvertorTest.cpp
3  *
4  * Created on: May 28, 2013
5  * Author: igor
6  */
7 
8 #include <gtest/gtest.h>
10 #include "Exceptions.hpp"
11 #include "TestUtils.hpp"
12 
13 using namespace HCE;
14 using namespace HCE::reduce_types;
15 using namespace HCE::reduce_convertors;
16 using namespace HCE::reduce;
17 using namespace Poco;
18 using namespace std;
19 
20 
21 TEST(PocoJSONReducingInputMessageConvertor, convertMessageInBothDirections)
22 {
23  types::MessageType processingType = types::MessageType::mtSphinx;
24  int ttl = 12;
25  string body = "msg body";
26 
27  SharedPtr<ReducingInputMessage> reducingInputMessage(new ReducingInputMessage
28  (processingType, ttl, body));
29 
30  PocoJSONReducingInputMessageConvertor pocoJSONReducingInputMessageConvertor;
31  string json = pocoJSONReducingInputMessageConvertor.convertToJSONFrom(reducingInputMessage);
32  SharedPtr<ReducingInputMessage> restoredReducingInputMessage =
33  pocoJSONReducingInputMessageConvertor.convertToReducingInputMessageFrom(json);
34 
35  ASSERT_TRUE(isEqualReducingInputMessage(*reducingInputMessage.get(),
36  *restoredReducingInputMessage.get()));
37 }
38 
39 
40 TEST(PocoJSONReducingInputMessageConvertor, throwExceptionWhenEncounterWrongJSONStructure)
41 {
42  string json = "wrong json structure";
43 
44  PocoJSONReducingInputMessageConvertor pocoJSONReducingInputMessageConvertor;
45 
46  ASSERT_THROW(pocoJSONReducingInputMessageConvertor.convertToReducingInputMessageFrom(json),
48 }