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 #if defined(BOOST_VERSION) && BOOST_VERSION >= 105900 44 boost_utf::unit_test_log.set_format (boost_utf::OF_XML);
45 #else // BOOST_VERSION 46 boost_utf::unit_test_log.set_format (boost_utf::XML);
47 #endif // BOOST_VERSION 48 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
61 const 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;
240 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
243 BOOST_AUTO_TEST_SUITE (master_test_suite)
248 BOOST_AUTO_TEST_CASE (simcrs_simple_simulation_test) {
252 "/rds01/schedule.csv");
263 "/ffDisutility.csv");
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 STDAIR_LOG_DEBUG (oMessageSell.str());
304 BOOST_CHECK_EQUAL (isSellSuccessful,
true);
306 BOOST_CHECK_MESSAGE (isSellSuccessful ==
true, oMessageSell.str());
315 BOOST_AUTO_TEST_CASE (simcrs_simple_default_bom_simulation_test) {
318 const bool isBuiltin =
true;
325 const unsigned int lExpectedPrice = 900;
326 const unsigned int lExpectedNbOfTravelSolutions = 1;
328 bool isSellSuccessful =
false;
330 BOOST_CHECK_NO_THROW (isSellSuccessful =
332 " ",
" ",
" ",
" ",
" ",
" ",
334 lExpectedNbOfTravelSolutions,
338 std::ostringstream oMessageSell;
339 const std::string isSellSuccessfulStr = (isSellSuccessful ==
true)?
"Yes":
"No";
340 oMessageSell <<
"Was the sell successful? Answer: " << isSellSuccessfulStr;
341 STDAIR_LOG_DEBUG (oMessageSell.str());
343 BOOST_CHECK_EQUAL (isSellSuccessful,
true);
345 BOOST_CHECK_MESSAGE (isSellSuccessful ==
true, oMessageSell.str());
351 BOOST_AUTO_TEST_SUITE_END()
#define STDAIR_SAMPLE_DIR