14 #define BOOST_TEST_DYN_LINK
15 #define BOOST_TEST_MAIN
16 #define BOOST_TEST_MODULE CRSTestSuite
17 #include <boost/test/unit_test.hpp>
19 #include <stdair/basic/BasLogParams.hpp>
20 #include <stdair/basic/BasDBParams.hpp>
21 #include <stdair/basic/BasFileMgr.hpp>
22 #include <stdair/bom/TravelSolutionStruct.hpp>
23 #include <stdair/bom/BookingRequestStruct.hpp>
24 #include <stdair/service/Logger.hpp>
26 #include <simfqt/SIMFQT_Types.hpp>
31 namespace boost_utf = boost::unit_test;
34 std::ofstream utfReportStream (
"CRSTestSuite_utfresults.xml");
39 struct UnitTestConfig {
42 boost_utf::unit_test_log.set_stream (utfReportStream);
43 boost_utf::unit_test_log.set_format (boost_utf::XML);
44 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
57 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
60 BOOST_AUTO_TEST_SUITE (master_test_suite)
65 BOOST_AUTO_TEST_CASE (simcrs_simple_simulation_test) {
72 "/rds01/schedule.csv");
86 bool doesExistAndIsReadable =
87 stdair::BasFileMgr::doesExistAndIsReadable (lScheduleInputFilename);
88 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
89 "The '" << lScheduleInputFilename
90 <<
"' input file can not be open and read");
93 doesExistAndIsReadable =
94 stdair::BasFileMgr::doesExistAndIsReadable (lOnDInputFilename);
95 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
96 "The '" << lOnDInputFilename
97 <<
"' input file can not be open and read");
100 doesExistAndIsReadable =
101 stdair::BasFileMgr::doesExistAndIsReadable (lYieldInputFilename);
102 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
103 "The '" << lYieldInputFilename
104 <<
"' input file can not be open and read");
107 doesExistAndIsReadable =
108 stdair::BasFileMgr::doesExistAndIsReadable (lFareInputFilename);
109 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
110 "The '" << lFareInputFilename
111 <<
"' input file can not be open and read");
114 const stdair::Filename_T lLogFilename (
"CRSTestSuite.log");
117 std::ofstream logOutputFile;
119 logOutputFile.open (lLogFilename.c_str());
120 logOutputFile.clear();
123 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
127 const SIMFQT::FareFilePath lFareFilePath (lFareInputFilename);
128 const AIRRAC::YieldFilePath lYieldFilePath (lYieldInputFilename);
129 simcrsService.parseAndLoad (lScheduleInputFilename, lOnDInputFilename,
130 lYieldFilePath, lFareFilePath);
134 const stdair::AirportCode_T lOrigin (
"SIN");
135 const stdair::AirportCode_T lDestination (
"BKK");
136 const stdair::AirportCode_T lPOS (
"SIN");
137 const stdair::Date_T lPreferredDepartureDate(2011, boost::gregorian::Jan, 31);
138 const stdair::Date_T lRequestDate (2011, boost::gregorian::Jan, 22);
139 const stdair::Duration_T lRequestTime (boost::posix_time::hours(10));
140 const stdair::DateTime_T lRequestDateTime (lRequestDate, lRequestTime);
141 const stdair::CabinCode_T lPreferredCabin (
"Eco");
142 const stdair::PartySize_T lPartySize (3);
143 const stdair::ChannelLabel_T lChannel (
"IN");
144 const stdair::TripType_T lTripType (
"RI");
145 const stdair::DayDuration_T lStayDuration (7);
146 const stdair::FrequentFlyer_T lFrequentFlyerType (
"M");
147 const stdair::Duration_T lPreferredDepartureTime (boost::posix_time::hours(10));
148 const stdair::WTP_T lWTP (1000.0);
149 const stdair::PriceValue_T lValueOfTime (100.0);
150 const stdair::BookingRequestStruct lBookingRequest (lOrigin, lDestination,
152 lPreferredDepartureDate,
155 lPartySize, lChannel,
156 lTripType, lStayDuration,
158 lPreferredDepartureTime,
160 stdair::TravelSolutionList_T lTravelSolutionList =
161 simcrsService.calculateSegmentPathList (lBookingRequest);
164 simcrsService.fareQuote (lBookingRequest, lTravelSolutionList);
167 const unsigned int lNbOfTravelSolutions = lTravelSolutionList.size();
170 const unsigned int lExpectedNbOfTravelSolutions = 1;
173 std::ostringstream oMessageKeptTS;
174 oMessageKeptTS <<
"The number of travel solutions for the booking request '"
175 << lBookingRequest.describe() <<
"' is actually "
176 << lNbOfTravelSolutions <<
". That number is expected to be "
177 << lExpectedNbOfTravelSolutions <<
".";
178 STDAIR_LOG_DEBUG (oMessageKeptTS.str());
180 BOOST_CHECK_EQUAL (lNbOfTravelSolutions, lExpectedNbOfTravelSolutions);
182 BOOST_CHECK_MESSAGE (lNbOfTravelSolutions == lExpectedNbOfTravelSolutions,
183 oMessageKeptTS.str());
189 stdair::TravelSolutionStruct& lTravelSolution = lTravelSolutionList.front();
195 const stdair::FareOptionList_T& lFareOptionList =
196 lTravelSolution.getFareOptionList();
206 stdair::FareOptionStruct lFareOption = lFareOptionList.front();
207 lTravelSolution.setChosenFareOption (lFareOption);
214 const unsigned int lExpectedPrice = 400;
217 std::ostringstream oMessageKeptFare;
219 <<
"The price given by the fare quoter for the booking request: '"
220 << lBookingRequest.describe() <<
"' and travel solution: '"
221 << lTravelSolution.describe() <<
"' is actually " << lFareOption.getFare()
222 <<
" Euros. It is expected to be " << lExpectedPrice <<
" Euros.";
223 STDAIR_LOG_DEBUG (oMessageKeptFare.str());
225 BOOST_CHECK_EQUAL (std::floor (lFareOption.getFare() + 0.5), lExpectedPrice);
227 BOOST_CHECK_MESSAGE (std::floor (lFareOption.getFare() + 0.5)
228 == lExpectedPrice, oMessageKeptFare.str());
238 STDAIR_LOG_DEBUG (
"A booking will now (attempted to) be made on the "
239 "travel solution '" << lTravelSolution.describe()
240 <<
"', for a party size of " << lPartySize <<
".");
242 const bool isSellSuccessful =
243 simcrsService.sell (lTravelSolution, lPartySize);
247 std::ostringstream oMessageSell;
248 const std::string isSellSuccessfulStr = (isSellSuccessful ==
true)?
"Yes":
"No";
249 oMessageSell <<
"Was the sell successful? Answer: " << isSellSuccessfulStr;
250 STDAIR_LOG_DEBUG (oMessageSell.str());
252 BOOST_CHECK_EQUAL (isSellSuccessful,
true);
254 BOOST_CHECK_MESSAGE (isSellSuccessful ==
true, oMessageSell.str());
257 logOutputFile.close();
261 BOOST_AUTO_TEST_SUITE_END()