-- Reduced test data set for RateController Integration Tests
-- (RateControllerIntegrationTest.java)

-- Insert test countries
INSERT INTO country (id, iso_code, region_code, is_deprecated) VALUES
                                                                   (1, 'DE', 'EMEA', FALSE),
                                                                   (2, 'FR', 'EMEA', FALSE),
                                                                   (3, 'IT', 'EMEA', FALSE),
                                                                   (4, 'ES', 'EMEA', FALSE),
                                                                   (5, 'CZ', 'EMEA', FALSE),
                                                                   (6, 'PL', 'EMEA', FALSE),
                                                                   (7, 'NL', 'EMEA', FALSE),
                                                                   (8, 'BE', 'EMEA', FALSE);

-- Insert test nodes
INSERT INTO node (id, country_id, name, address, external_mapping_id, predecessor_required, is_destination, is_source, is_intermediate, geo_lat, geo_lng, is_deprecated) VALUES
                                                                                                                                                                             (1, 1, 'Hamburg Port', 'Port of Hamburg, Germany', 'HAM001', FALSE, TRUE, TRUE, FALSE, 53.5511, 9.9937, FALSE),
                                                                                                                                                                             (2, 1, 'Munich Terminal', 'Munich Rail Terminal, Germany', 'MUC001', FALSE, TRUE, TRUE, TRUE, 48.1351, 11.5820, FALSE),
                                                                                                                                                                             (3, 1, 'Berlin Hub', 'Berlin Central Hub, Germany', 'BER001', FALSE, TRUE, TRUE, TRUE, 52.5200, 13.4050, FALSE),
                                                                                                                                                                             (4, 2, 'Paris Terminal', 'Paris Logistics Center, France', 'PAR001', FALSE, TRUE, TRUE, TRUE, 48.8566, 2.3522, FALSE),
                                                                                                                                                                             (5, 3, 'Milan Hub', 'Milan Distribution Center, Italy', 'MIL001', FALSE, TRUE, TRUE, TRUE, 45.4642, 9.1900, FALSE),
                                                                                                                                                                             (6, 4, 'Barcelona Port', 'Port of Barcelona, Spain', 'BCN001', FALSE, TRUE, TRUE, FALSE, 41.3851, 2.1734, FALSE),
                                                                                                                                                                             (7, 5, 'Prague Hub', 'Prague Distribution Center, Czech Republic', 'PRG001', FALSE, TRUE, TRUE, TRUE, 50.0755, 14.4378, FALSE),
                                                                                                                                                                             (8, 6, 'Warsaw Terminal', 'Warsaw Logistics Terminal, Poland', 'WAW001', FALSE, TRUE, TRUE, TRUE, 52.2297, 21.0122, FALSE);

-- Insert validity periods
INSERT INTO validity_period (id, start_date, end_date, state) VALUES
                                                                  (1, DATE_SUB(NOW(), INTERVAL 1 MONTH), DATE_ADD(NOW(), INTERVAL 11 MONTH), 'VALID'),
                                                                  (2, DATE_ADD(NOW(), INTERVAL 1 DAY), NULL, 'DRAFT'),
                                                                  (3, DATE_SUB(NOW(), INTERVAL 2 YEAR), DATE_SUB(NOW(), INTERVAL 1 YEAR), 'EXPIRED'),
                                                                  (4, DATE_SUB(NOW(), INTERVAL 6 MONTH), DATE_SUB(NOW(), INTERVAL 1 DAY), 'INVALID');

-- Insert container rates for VALID period
INSERT INTO container_rate (id, from_node_id, to_node_id, container_rate_type, rate_teu, rate_feu, rate_hc, lead_time, validity_period_id) VALUES
-- Rail connections
(1, 1, 2, 'RAIL', 1000.00, 1800.00, 2000.00, 3, 1),
(2, 1, 3, 'RAIL', 800.00, 1500.00, 1700.00, 2, 1),
(3, 3, 4, 'RAIL', 1200.00, 2200.00, 2400.00, 4, 1),
(4, 3, 7, 'RAIL', 900.00, 1700.00, 1900.00, 3, 1),
(5, 2, 5, 'RAIL', 1500.00, 2800.00, 3000.00, 5, 1),

-- Sea connections
(6, 1, 6, 'SEA', 2000.00, 3800.00, 4200.00, 14, 1),
(7, 6, 5, 'SEA', 1800.00, 3400.00, 3800.00, 10, 1),

-- Road connections
(8, 2, 3, 'ROAD', 600.00, 1100.00, 1300.00, 1, 1),
(9, 4, 5, 'ROAD', 1400.00, 2600.00, 2900.00, 2, 1),
(10, 7, 8, 'ROAD', 700.00, 1300.00, 1500.00, 1, 1),

-- Post-run connections
(11, 3, 2, 'POST_RUN', 400.00, 750.00, 850.00, 1, 1),
(12, 5, 4, 'POST_RUN', 500.00, 950.00, 1050.00, 1, 1);

-- Insert container rates for DRAFT period
INSERT INTO container_rate (from_node_id, to_node_id, container_rate_type, rate_teu, rate_feu, rate_hc, lead_time, validity_period_id) VALUES
                                                                                                                                           (1, 2, 'RAIL', 1100.00, 2000.00, 2200.00, 3, 2),
                                                                                                                                           (1, 3, 'RAIL', 900.00, 1700.00, 1900.00, 2, 2),
                                                                                                                                           (3, 4, 'RAIL', 1300.00, 2400.00, 2600.00, 4, 2);

-- Insert country matrix rates for VALID period
INSERT INTO country_matrix_rate (id, from_country_id, to_country_id, rate, validity_period_id) VALUES
                                                                                                   (1, 1, 2, 2.50, 1),  -- Germany to France
                                                                                                   (2, 1, 3, 3.20, 1),  -- Germany to Italy
                                                                                                   (3, 1, 4, 3.80, 1),  -- Germany to Spain
                                                                                                   (4, 1, 5, 2.20, 1),  -- Germany to Czech Republic
                                                                                                   (5, 2, 3, 2.90, 1),  -- France to Italy
                                                                                                   (6, 2, 4, 2.40, 1),  -- France to Spain
                                                                                                   (7, 3, 4, 3.50, 1),  -- Italy to Spain
                                                                                                   (8, 5, 6, 1.80, 1),  -- Czech Republic to Poland
                                                                                                   (9, 1, 7, 2.00, 1),  -- Germany to Netherlands
                                                                                                   (10, 1, 8, 2.30, 1); -- Germany to Belgium

-- Insert country matrix rates for DRAFT period
INSERT INTO country_matrix_rate (from_country_id, to_country_id, rate, validity_period_id) VALUES
                                                                                               (1, 2, 2.70, 2),  -- Germany to France (increased rate)
                                                                                               (1, 3, 3.40, 2),  -- Germany to Italy (increased rate)
                                                                                               (1, 4, 4.00, 2);  -- Germany to Spain (increased rate)

-- Insert property sets for testing
INSERT INTO property_set (id, start_date, end_date, state) VALUES
                                                               (1, DATE_SUB(NOW(), INTERVAL 1 MONTH), DATE_ADD(NOW(), INTERVAL 11 MONTH), 'VALID'),
                                                               (2, DATE_ADD(NOW(), INTERVAL 1 DAY), NULL, 'DRAFT');

-- Insert system property types
INSERT INTO system_property_type (id, name, external_mapping_id, data_type, validation_rule) VALUES
                                                                                                 (1, 'Default Lead Time Buffer', 'LEAD_TIME_BUF', 'INT', 'MIN:0,MAX:30'),
                                                                                                 (2, 'Container Loading Factor', 'CONT_LOAD_FAC', 'PERCENTAGE', 'MIN:0,MAX:100'),
                                                                                                 (3, 'Enable Rate Approval', 'RATE_APPROVAL', 'BOOLEAN', NULL);

-- Insert system properties
INSERT INTO system_property (property_set_id, system_property_type_id, property_value) VALUES
                                                                                           (1, 1, '2'),
                                                                                           (1, 2, '85'),
                                                                                           (1, 3, 'true');