14 #define BOOST_TEST_DYN_LINK 15 #define BOOST_TEST_MAIN 16 #define BOOST_TEST_MODULE CRSTestSuite 17 #include <boost/test/unit_test.hpp> 18 #include <boost/version.hpp> 20 #include <stdair/basic/BasLogParams.hpp> 21 #include <stdair/basic/BasDBParams.hpp> 22 #include <stdair/basic/BasFileMgr.hpp> 23 #include <stdair/bom/TravelSolutionStruct.hpp> 24 #include <stdair/bom/BookingRequestStruct.hpp> 25 #include <stdair/service/Logger.hpp> 27 #include <simfqt/SIMFQT_Types.hpp> 32 namespace boost_utf = boost::unit_test;
35 std::ofstream utfReportStream (
"CRSTestSuite_utfresults.xml");
40 struct UnitTestConfig {
43 boost_utf::unit_test_log.set_stream (utfReportStream);
44 #if BOOST_VERSION >= 105900 45 boost_utf::unit_test_log.set_format (boost_utf::OF_XML);
47 boost_utf::unit_test_log.set_format (boost_utf::XML);
49 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
62 const unsigned int testSimCRSHelper (
const unsigned short iTestFlag,
63 const stdair::Filename_T& iScheduleInputFilename,
64 const stdair::Filename_T& iOnDInputFilename,
65 const stdair::Filename_T& iFRAT5InputFilename,
66 const stdair::Filename_T& iFFDisutilityInputFilename,
67 const stdair::Filename_T& iYieldInputFilename,
68 const stdair::Filename_T& iFareInputFilename,
70 const unsigned int iExpectedNbOfTravelSolutions,
71 const unsigned int iExpectedPrice) {
77 std::ostringstream oStr;
78 oStr <<
"CRSTestSuite_" << iTestFlag <<
".log";
79 const stdair::Filename_T lLogFilename (oStr.str());
82 std::ofstream logOutputFile;
84 logOutputFile.open (lLogFilename.c_str());
85 logOutputFile.clear();
88 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
91 stdair::Date_T lPreferredDepartureDate;;
92 stdair::Date_T lRequestDate;
93 stdair::TripType_T lTripType;
96 if (isBuiltin ==
true) {
99 simcrsService.buildSampleBom();
101 lPreferredDepartureDate = boost::gregorian::from_string (
"2010/02/08");
102 lRequestDate = boost::gregorian::from_string (
"2010/01/21");
108 stdair::ScheduleFilePath lScheduleFilePath (iScheduleInputFilename);
109 stdair::ODFilePath lODFilePath (iOnDInputFilename);
110 stdair::FRAT5FilePath lFRAT5FilePath (iFRAT5InputFilename);
111 stdair::FFDisutilityFilePath lFFDisutilityFilePath (iFFDisutilityInputFilename);
112 const SIMFQT::FareFilePath lFareFilePath (iFareInputFilename);
113 const AIRRAC::YieldFilePath lYieldFilePath (iYieldInputFilename);
114 simcrsService.parseAndLoad (lScheduleFilePath, lODFilePath,
115 lFRAT5FilePath, lFFDisutilityFilePath,
116 lYieldFilePath, lFareFilePath);
118 lPreferredDepartureDate = boost::gregorian::from_string (
"2011/01/31");
119 lRequestDate = boost::gregorian::from_string (
"2011/01/22");
124 const stdair::AirportCode_T lOrigin (
"SIN");
125 const stdair::AirportCode_T lDestination (
"BKK");
126 const stdair::AirportCode_T lPOS (
"SIN");
127 const stdair::Duration_T lRequestTime (boost::posix_time::hours(10));
128 const stdair::DateTime_T lRequestDateTime (lRequestDate, lRequestTime);
129 const stdair::CabinCode_T lPreferredCabin (
"Eco");
130 const stdair::PartySize_T lPartySize (3);
131 const stdair::ChannelLabel_T lChannel (
"IN");
132 const stdair::DayDuration_T lStayDuration (7);
133 const stdair::FrequentFlyer_T lFrequentFlyerType (
"M");
134 const stdair::Duration_T lPreferredDepartureTime (boost::posix_time::hours(10));
135 const stdair::WTP_T lWTP (1000.0);
136 const stdair::PriceValue_T lValueOfTime (100.0);
137 const stdair::ChangeFees_T lChangeFees (
true);
138 const stdair::Disutility_T lChangeFeeDisutility (50);
139 const stdair::NonRefundable_T lNonRefundable (
true);
140 const stdair::Disutility_T lNonRefundableDisutility (50);
141 const stdair::BookingRequestStruct lBookingRequest (lOrigin, lDestination,
143 lPreferredDepartureDate,
146 lPartySize, lChannel,
147 lTripType, lStayDuration,
149 lPreferredDepartureTime,
152 lChangeFeeDisutility,
154 lNonRefundableDisutility);
155 stdair::TravelSolutionList_T lTravelSolutionList =
156 simcrsService.calculateSegmentPathList (lBookingRequest);
159 simcrsService.fareQuote (lBookingRequest, lTravelSolutionList);
162 const unsigned int lNbOfTravelSolutions = lTravelSolutionList.size();
165 std::ostringstream oMessageKeptTS;
166 oMessageKeptTS <<
"The number of travel solutions for the booking request '" 167 << lBookingRequest.describe() <<
"' is actually " 168 << lNbOfTravelSolutions <<
". That number is expected to be " 169 << iExpectedNbOfTravelSolutions <<
".";
170 STDAIR_LOG_DEBUG (oMessageKeptTS.str());
172 BOOST_CHECK_EQUAL (lNbOfTravelSolutions, iExpectedNbOfTravelSolutions);
174 BOOST_CHECK_MESSAGE (lNbOfTravelSolutions == iExpectedNbOfTravelSolutions,
175 oMessageKeptTS.str());
181 stdair::TravelSolutionStruct& lTravelSolution = lTravelSolutionList.front();
187 const stdair::FareOptionList_T& lFareOptionList =
188 lTravelSolution.getFareOptionList();
198 stdair::FareOptionStruct lFareOption = lFareOptionList.front();
199 lTravelSolution.setChosenFareOption (lFareOption);
202 std::ostringstream oMessageKeptFare;
204 <<
"The price given by the fare quoter for the booking request: '" 205 << lBookingRequest.describe() <<
"' and travel solution: '" 206 << lTravelSolution.describe() <<
"' is actually " << lFareOption.getFare()
207 <<
" Euros. It is expected to be " << iExpectedPrice <<
" Euros.";
208 STDAIR_LOG_DEBUG (oMessageKeptFare.str());
210 BOOST_CHECK_EQUAL (std::floor (lFareOption.getFare() + 0.5), iExpectedPrice);
212 BOOST_CHECK_MESSAGE (std::floor (lFareOption.getFare() + 0.5)
213 == iExpectedPrice, oMessageKeptFare.str());
223 STDAIR_LOG_DEBUG (
"A booking will now (attempted to) be made on the " 224 "travel solution '" << lTravelSolution.describe()
225 <<
"', for a party size of " << lPartySize <<
".");
227 const bool isSellSuccessful =
228 simcrsService.sell (lTravelSolution, lPartySize);
231 logOutputFile.close();
233 return isSellSuccessful;
241 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
244 BOOST_AUTO_TEST_SUITE (master_test_suite)
249 BOOST_AUTO_TEST_CASE (simcrs_simple_simulation_test) {
253 "/rds01/schedule.csv");
264 "/ffDisutility.csv");
275 const bool isBuiltin =
false;
282 const unsigned int lExpectedPrice = 400;
283 const unsigned int lExpectedNbOfTravelSolutions = 1;
285 bool isSellSuccessful =
false;
287 BOOST_CHECK_NO_THROW (isSellSuccessful =
289 lScheduleInputFilename,
292 lFFDisutilityInputFilename,
296 lExpectedNbOfTravelSolutions,
300 std::ostringstream oMessageSell;
301 const std::string isSellSuccessfulStr = (isSellSuccessful ==
true)?
"Yes":
"No";
302 oMessageSell <<
"Was the sell successful? Answer: " << isSellSuccessfulStr;
303 STDAIR_LOG_DEBUG (oMessageSell.str());
305 BOOST_CHECK_EQUAL (isSellSuccessful,
true);
307 BOOST_CHECK_MESSAGE (isSellSuccessful ==
true, oMessageSell.str());
316 BOOST_AUTO_TEST_CASE (simcrs_simple_default_bom_simulation_test) {
319 const bool isBuiltin =
true;
326 const unsigned int lExpectedPrice = 900;
327 const unsigned int lExpectedNbOfTravelSolutions = 1;
329 bool isSellSuccessful =
false;
331 BOOST_CHECK_NO_THROW (isSellSuccessful =
333 " ",
" ",
" ",
" ",
" ",
" ",
335 lExpectedNbOfTravelSolutions,
339 std::ostringstream oMessageSell;
340 const std::string isSellSuccessfulStr = (isSellSuccessful ==
true)?
"Yes":
"No";
341 oMessageSell <<
"Was the sell successful? Answer: " << isSellSuccessfulStr;
342 STDAIR_LOG_DEBUG (oMessageSell.str());
344 BOOST_CHECK_EQUAL (isSellSuccessful,
true);
346 BOOST_CHECK_MESSAGE (isSellSuccessful ==
true, oMessageSell.str());
352 BOOST_AUTO_TEST_SUITE_END()
#define STDAIR_SAMPLE_DIR