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>
29#include <simcrs/config/simcrs-paths.hpp>
31namespace boost_utf = boost::unit_test;
34std::ofstream utfReportStream (
"CRSTestSuite_utfresults.xml");
39struct UnitTestConfig {
42 boost_utf::unit_test_log.set_stream (utfReportStream);
43#if BOOST_VERSION_MACRO >= 105900
44 boost_utf::unit_test_log.set_format (boost_utf::OF_XML);
46 boost_utf::unit_test_log.set_format (boost_utf::XML);
48 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
61const unsigned int testSimCRSHelper (
const unsigned short iTestFlag,
62 const stdair::Filename_T& iScheduleInputFilename,
63 const stdair::Filename_T& iOnDInputFilename,
64 const stdair::Filename_T& iFRAT5InputFilename,
65 const stdair::Filename_T& iFFDisutilityInputFilename,
66 const stdair::Filename_T& iYieldInputFilename,
67 const stdair::Filename_T& iFareInputFilename,
69 const unsigned int iExpectedNbOfTravelSolutions,
70 const unsigned int iExpectedPrice) {
76 std::ostringstream oStr;
77 oStr <<
"CRSTestSuite_" << iTestFlag <<
".log";
78 const stdair::Filename_T lLogFilename (oStr.str());
81 std::ofstream logOutputFile;
83 logOutputFile.open (lLogFilename.c_str());
84 logOutputFile.clear();
87 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
90 stdair::Date_T lPreferredDepartureDate;;
91 stdair::Date_T lRequestDate;
92 stdair::TripType_T lTripType;
95 if (isBuiltin ==
true) {
98 simcrsService.buildSampleBom();
100 lPreferredDepartureDate = boost::gregorian::from_string (
"2010/02/08");
101 lRequestDate = boost::gregorian::from_string (
"2010/01/21");
107 stdair::ScheduleFilePath lScheduleFilePath (iScheduleInputFilename);
108 stdair::ODFilePath lODFilePath (iOnDInputFilename);
109 stdair::FRAT5FilePath lFRAT5FilePath (iFRAT5InputFilename);
110 stdair::FFDisutilityFilePath lFFDisutilityFilePath (iFFDisutilityInputFilename);
111 const SIMFQT::FareFilePath lFareFilePath (iFareInputFilename);
112 const AIRRAC::YieldFilePath lYieldFilePath (iYieldInputFilename);
113 simcrsService.parseAndLoad (lScheduleFilePath, lODFilePath,
114 lFRAT5FilePath, lFFDisutilityFilePath,
115 lYieldFilePath, lFareFilePath);
117 lPreferredDepartureDate = boost::gregorian::from_string (
"2011/01/31");
118 lRequestDate = boost::gregorian::from_string (
"2011/01/22");
123 const stdair::AirportCode_T lOrigin (
"SIN");
124 const stdair::AirportCode_T lDestination (
"BKK");
125 const stdair::AirportCode_T lPOS (
"SIN");
126 const stdair::Duration_T lRequestTime (boost::posix_time::hours(10));
127 const stdair::DateTime_T lRequestDateTime (lRequestDate, lRequestTime);
128 const stdair::CabinCode_T lPreferredCabin (
"Eco");
129 const stdair::PartySize_T lPartySize (3);
130 const stdair::ChannelLabel_T lChannel (
"IN");
131 const stdair::DayDuration_T lStayDuration (7);
132 const stdair::FrequentFlyer_T lFrequentFlyerType (
"M");
133 const stdair::Duration_T lPreferredDepartureTime (boost::posix_time::hours(10));
134 const stdair::WTP_T lWTP (1000.0);
135 const stdair::PriceValue_T lValueOfTime (100.0);
136 const stdair::ChangeFees_T lChangeFees (
true);
137 const stdair::Disutility_T lChangeFeeDisutility (50);
138 const stdair::NonRefundable_T lNonRefundable (
true);
139 const stdair::Disutility_T lNonRefundableDisutility (50);
140 const stdair::BookingRequestStruct lBookingRequest (lOrigin, lDestination,
142 lPreferredDepartureDate,
145 lPartySize, lChannel,
146 lTripType, lStayDuration,
148 lPreferredDepartureTime,
151 lChangeFeeDisutility,
153 lNonRefundableDisutility);
154 stdair::TravelSolutionList_T lTravelSolutionList =
155 simcrsService.calculateSegmentPathList (lBookingRequest);
158 simcrsService.fareQuote (lBookingRequest, lTravelSolutionList);
161 const unsigned int lNbOfTravelSolutions = lTravelSolutionList.size();
164 std::ostringstream oMessageKeptTS;
165 oMessageKeptTS <<
"The number of travel solutions for the booking request '"
166 << lBookingRequest.describe() <<
"' is actually "
167 << lNbOfTravelSolutions <<
". That number is expected to be "
168 << iExpectedNbOfTravelSolutions <<
".";
169 STDAIR_LOG_DEBUG (oMessageKeptTS.str());
171 BOOST_CHECK_EQUAL (lNbOfTravelSolutions, iExpectedNbOfTravelSolutions);
173 BOOST_CHECK_MESSAGE (lNbOfTravelSolutions == iExpectedNbOfTravelSolutions,
174 oMessageKeptTS.str());
180 stdair::TravelSolutionStruct& lTravelSolution = lTravelSolutionList.front();
186 const stdair::FareOptionList_T& lFareOptionList =
187 lTravelSolution.getFareOptionList();
197 stdair::FareOptionStruct lFareOption = lFareOptionList.front();
198 lTravelSolution.setChosenFareOption (lFareOption);
201 std::ostringstream oMessageKeptFare;
203 <<
"The price given by the fare quoter for the booking request: '"
204 << lBookingRequest.describe() <<
"' and travel solution: '"
205 << lTravelSolution.describe() <<
"' is actually " << lFareOption.getFare()
206 <<
" Euros. It is expected to be " << iExpectedPrice <<
" Euros.";
207 STDAIR_LOG_DEBUG (oMessageKeptFare.str());
209 BOOST_CHECK_EQUAL (std::floor (lFareOption.getFare() + 0.5), iExpectedPrice);
211 BOOST_CHECK_MESSAGE (std::floor (lFareOption.getFare() + 0.5)
212 == iExpectedPrice, oMessageKeptFare.str());
222 STDAIR_LOG_DEBUG (
"A booking will now (attempted to) be made on the "
223 "travel solution '" << lTravelSolution.describe()
224 <<
"', for a party size of " << lPartySize <<
".");
226 const bool isSellSuccessful =
227 simcrsService.sell (lTravelSolution, lPartySize);
230 logOutputFile.close();
232 return isSellSuccessful;
240BOOST_GLOBAL_FIXTURE (UnitTestConfig);
243BOOST_AUTO_TEST_SUITE (master_test_suite)
248BOOST_AUTO_TEST_CASE (simcrs_simple_simulation_test) {
251 const stdair::Filename_T lScheduleInputFilename (STDAIR_SAMPLE_DIR
252 "/rds01/schedule.csv");
255 const stdair::Filename_T lOnDInputFilename (STDAIR_SAMPLE_DIR
"/ond01.csv");
258 const stdair::Filename_T lFRAT5InputFilename (STDAIR_SAMPLE_DIR
262 const stdair::Filename_T lFFDisutilityInputFilename (STDAIR_SAMPLE_DIR
263 "/ffDisutility.csv");
266 const stdair::Filename_T lYieldInputFilename (STDAIR_SAMPLE_DIR
270 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR
274 const bool isBuiltin =
false;
281 const unsigned int lExpectedPrice = 400;
282 const unsigned int lExpectedNbOfTravelSolutions = 1;
284 bool isSellSuccessful =
false;
286 BOOST_CHECK_NO_THROW (isSellSuccessful =
288 lScheduleInputFilename,
291 lFFDisutilityInputFilename,
295 lExpectedNbOfTravelSolutions,
299 std::ostringstream oMessageSell;
300 const std::string isSellSuccessfulStr = (isSellSuccessful ==
true)?
"Yes":
"No";
301 oMessageSell <<
"Was the sell successful? Answer: " << isSellSuccessfulStr;
302 std::cout << oMessageSell.str() << std::endl;
304 BOOST_CHECK_EQUAL (isSellSuccessful,
true);
306 BOOST_CHECK_MESSAGE (isSellSuccessful ==
true, oMessageSell.str());
313BOOST_AUTO_TEST_CASE (simcrs_simple_default_bom_simulation_test) {
316 const bool isBuiltin =
true;
323 const unsigned int lExpectedPrice = 900;
324 const unsigned int lExpectedNbOfTravelSolutions = 1;
326 bool isSellSuccessful =
false;
328 BOOST_CHECK_NO_THROW (isSellSuccessful =
330 " ",
" ",
" ",
" ",
" ",
" ",
332 lExpectedNbOfTravelSolutions,
336 std::ostringstream oMessageSell;
337 const std::string isSellSuccessfulStr = (isSellSuccessful ==
true)?
"Yes":
"No";
338 oMessageSell <<
"Was the sell successful? Answer: " << isSellSuccessfulStr;
339 std::cout << oMessageSell.str() << std::endl;
341 BOOST_CHECK_EQUAL (isSellSuccessful,
true);
343 BOOST_CHECK_MESSAGE (isSellSuccessful ==
true, oMessageSell.str());
347BOOST_AUTO_TEST_SUITE_END()