Mock Server
The MockServer is a project designed to simulate supplier responses for various use cases. It is essential for testing Connectors without requiring supplier credentials or a development environment.
Structure
MockServer Configuration
Defines the supplier's access configuration and simulates the Access object.
This structure must be added to the mock server under the config path: /Config<supplierCode>.json
.
Example Configuration
{
"Currency": "USD",
"CheckIn": "2025-01-13",
"Nationality": "ES",
"Markets": ["ES", "US"],
"Language": "en",
"Accommodations": ["737"],
"BookingFlowImplemented": true,
"Access": {
"Code": 1234,
"User": "prueba",
"Password": "Prueba123",
"ApiKey": "API_KEY_12345",
"Urls": {
"Generic": "${Mock:Url}"
},
"Parameters": {
"Timeout": 30,
"RetryPolicy": "Exponential"
}
},
"CancelPolicy": {
"OnlyReturnOnePolicy": false,
"CancelPenaltyAmountGreaterThanPrice": false
},
"CreditCard": {
"Cvc": "123",
"Expiration": {
"Month": "12",
"Year": "2025"
},
"Holder": {
"Name": "John",
"Surname": "Doe",
"PersonalTitleType": "Mr"
},
"Number": "4111111111111111",
"Type": "Visa"
},
"ClientLocator": "0123456789",
"Holder": {
"Name": "Jane",
"Surname": "Smith"
},
"Price": {
"IgnoreRoomMinimumSellingPrice": false
},
"IgnoreTests": {
"Test1": {
"Reason": "Not applicable for this configuration",
"User": "tester1"
},
"Test2": {
"Reason": "Under maintenance",
"User": "tester2"
}
}
}
Field Descriptions
- Currency: Specifies the default currency for testing scenarios.
- CheckIn: Simulates the check-in date. If omitted, defaults are used.
- Nationality: Indicates the nationality of guests for supplier-specific rules.
- Markets: Lists supported markets for testing.
- Accommodations: Specifies hotel codes to test against.
- BookingFlowImplemented: Boolean flag to indicate if booking workflows are implemented.
- Access: Mimics the supplier's access configuration. View Access Data
- CancelPolicy:
OnlyReturnOnePolicy
: Forces a single cancellation policy to be returned.CancelPenaltyAmountGreaterThanPrice
: Allows testing scenarios where penalties exceed room price.
- CreditCard: Details for test bookings requiring payment.
- Type: Specifies the credit card type (e.g., Visa, MasterCard).
- ClientLocator: Defines the client reference for booking tests.
- Price:
IgnoreRoomMinimumSellingPrice
: Enables testing of prices below minimum thresholds.
Test Cases
Provider_Errors
Simulates supplier error responses. For example:
{
"error": {
"description": "Authentication Failed - Wrong Password"
}
}
Two_Adults_Two_Days
- Purpose: Tests a standard booking scenario for two adults over two nights.
- Scenario:
- Confirms correct handling of standard occupancy configurations.
{
"Options": [
{
"Status": "Available",
"SupplierPrice": {
"Currency": "EUR",
"Net": 150.75,
"MinimumSellingPrice": 165.00
},
"SupplierPaymentType": "MerchantPay",
"Rooms": [
{
"OccupancyId": 1,
"RoomCode": "STDSUIT",
"SupplierPrice": {
"Currency": "EUR",
"Net": 75.00,
"MinimumSellingPrice": 82.50
},
"RoomDescription": "Standard Suite with city view"
},
{
"OccupancyId": 2,
"RoomCode": "DLXROOM",
"SupplierPrice": {
"Currency": "EUR",
"Net": 75.75,
"MinimumSellingPrice": 82.50
},
"RoomDescription": "Deluxe Room with king bed"
}
],
"BoardCode": "BB"
},
{
"Status": "OnRequest",
"SupplierPrice": {
"Currency": "USD",
"Net": 200.00,
"MinimumSellingPrice": 220.00
},
"SupplierPaymentType": "MerchantPay",
"Rooms": [
{
"OccupancyId": 1,
"RoomCode": "PREMSUIT",
"SupplierPrice": {
"Currency": "USD",
"Net": 200.00,
"MinimumSellingPrice": 220.00
},
"RoomDescription": "Premium Suite with ocean view"
}
],
"BoardCode": "HB"
}
],
"HotelCode": "HLC12345",
"BoardName": "Bed and Breakfast",
"HotelName": "Grand Hyatt Madrid"
}
Detailed Test Scenarios
Specific_Policies
- Purpose: Validates the Connector's ability to include exact cancellation policies in the
Quote
response. - Scenario:
- Includes three cancellation policies with deadlines 11 days, 3 days, and 2 days before check-in.
- Ensures compliance with supplier-specific requirements.
Note: This use case may present particular challenges for you as a supplier, due to the need for precise handling of cancellation policies. If you encounter difficulties, do not hesitate to reach out to Travelgate's support team for assistance.
One_Adult_One_Child_Two_Days
- Purpose: Verifies Search results for a family scenario with mixed age groups (one adult and one child) staying two nights.
- Scenario:
- Confirms correct handling of occupancy configurations.
- Ensures cancellation policies and pricing are calculated correctly for child-inclusive bookings.
Two_Adults_Seven_Days
- Purpose: Tests extended stays for two adults over seven nights.
- Scenario:
- Validates the correct application of long-stay discounts or promotions.
- Ensures the system handles extended deadlines and multi-day rate adjustments.
Two_Adults_Two_Days_Two_Rooms
- Purpose: Confirms handling of multi-room bookings for two adults staying over two nights.
- Scenario:
- Ensures cancellation policies are correctly assigned to each room.
- Validates room-specific pricing and availability logic.
Detailed Test Scenarios by Operation
Book
- Mocks:
Provider_Errors.txt
: Simulates supplier errors (e.g., authentication failure).Two_Adults_Two_Days.txt
: Covers a standard booking scenario for two adults over two nights.
- Purpose: Validates the
Book
operation, ensuring correct handling of responses and error scenarios.
Cancel
- Mocks:
Provider_Errors.txt
: Simulates supplier errors (e.g., incorrect cancellation request).Two_Adults_Two_Days.txt
: Verifies cancellation for a standard booking of two adults over two nights.
- Purpose: Tests the
Cancel
operation, including proper cancellation logic and error handling.
CheckBookings By Date
- Mocks:
Provider_Errors.txt
: Simulates supplier errors (e.g., invalid date range).Two_Adults_Two_Days.txt
: Confirms booking retrieval for two adults over two nights.Two_Adults_Two_Days_Canceled.txt
: Ensures canceled bookings are correctly identified.
- Purpose: Validates retrieval of bookings by date, including scenarios with active and canceled bookings.
CheckBookings By Reference
- Mocks:
Provider_Errors.txt
: Simulates supplier errors (e.g., invalid booking reference).Two_Adults_Two_Days.txt
: Confirms booking retrieval using client and supplier locators.Two_Adults_Two_Days_Canceled.txt
: Verifies handling of canceled bookings.
- Purpose: Tests retrieval of booking details by reference, including error handling and status verification.
Quote
- Mocks:
Two_Adults_Two_Days.txt
: Validates a Quote for a standard booking of two adults over two nights.Specific_Policies.txt
: Ensures exact cancellation policies are specified in theQuote
response.Provider_Errors.txt
: Simulates supplier errors (e.g., invalid request format).
- Purpose: Tests the
Quote
operation to ensure accurate and compliant responses with supplier-specific requirements.
Search
- Mocks:
One_Adult_One_Child_Two_Days.txt
: Verifies Search results for one adult and one child over two nights.Two_Adults_Two_Days.txt
: Confirms availability for two adults over two nights.Two_Adults_Seven_Days.txt
: Validates Search for extended stays of two adults over seven nights.Two_Adults_Two_Days_Two_Rooms.txt
: Ensures correct handling of multi-room bookings for two adults.Provider_Errors.txt
: Simulates supplier errors (e.g., authentication failure).
- Purpose: Tests the
Search
operation, including handling of various guest configurations, multi-room bookings, and extended stays.
PreOperations Mock
To add a PreOperations mock, you need to create a mock file with the following naming convention:
<use_case>_PreOperation_<preoperation_number>.txt
. Preoperation numbers start at 0.
Example:
`Provider_Errors_PreOperation_0.txt
Dynamic Replacements
Replacement Definition
public class DateReplacements : IReplacement<HotelTestData>
{
public string Replace(string response, HotelTestData testData)
{
response = response.Replace("{DEADLINE-264}", testData.CheckIn.AddHours(-264).ToString("yyyy-MM-dd"));
response = response.Replace("{DEADLINE-72}", testData.CheckIn.AddHours(-72).ToString("yyyy-MM-dd"));
response = response.Replace("{DEADLINE-48}", testData.CheckIn.AddHours(-48).ToString("yyyy-MM-dd"));
return response;
}
}
Example Mock Response to be Replaced
<politicas>
<politica date="{DEADLINE-264}" precio="100.22" moneda="USD"/>
<politica date="{DEADLINE-72}" precio="150.22" moneda="USD"/>
<politica date="{DEADLINE-48}" precio="200.22" moneda="USD"/>
</politicas>
Explanation: The
{DEADLINE-XXX}
placeholders are replaced with actual dates based on theCheckIn
value during runtime.