diff --git a/editoast/editoast_schemas/src/rolling_stock/mod.rs b/editoast/editoast_schemas/src/rolling_stock.rs similarity index 86% rename from editoast/editoast_schemas/src/rolling_stock/mod.rs rename to editoast/editoast_schemas/src/rolling_stock.rs index b69ceb9dfd7..30d77d9429b 100644 --- a/editoast/editoast_schemas/src/rolling_stock/mod.rs +++ b/editoast/editoast_schemas/src/rolling_stock.rs @@ -38,23 +38,14 @@ use utoipa::ToSchema; editoast_common::schemas! { RollingStock, - Gamma, - ConditionalEffortCurve, - EffortCurve, - EffortCurves, - EffortCurveConditions, - ModeEffortCurves, - RollingStockComfortType, - RollingResistance, - EnergySource, - EnergyStorage, - RefillLaw, - SpeedDependantPower, - RollingStockSupportedSignalingSystems, - RollingStockMetadata, - LoadingGaugeType, - RollingStockLivery, - RollingStockLiveryMetadata, + gamma::schemas(), + effort_curves::schemas(), + energy_source::schemas(), + rolling_stock_livery::schemas(), + rolling_resistance::schemas(), + supported_signaling_systems::schemas(), + rolling_stock_metadata::schemas(), + loading_gauge_type::schemas(), } pub const ROLLING_STOCK_RAILJSON_VERSION: &str = "3.2"; diff --git a/editoast/editoast_schemas/src/rolling_stock/effort_curves.rs b/editoast/editoast_schemas/src/rolling_stock/effort_curves.rs index d3955199252..f7ae502cd05 100644 --- a/editoast/editoast_schemas/src/rolling_stock/effort_curves.rs +++ b/editoast/editoast_schemas/src/rolling_stock/effort_curves.rs @@ -7,6 +7,15 @@ use strum::Display; use strum::EnumString; use utoipa::ToSchema; +editoast_common::schemas! { + ConditionalEffortCurve, + EffortCurve, + EffortCurves, + EffortCurveConditions, + ModeEffortCurves, + RollingStockComfortType, +} + #[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, ToSchema, Hash)] #[serde(deny_unknown_fields)] pub struct EffortCurves { diff --git a/editoast/editoast_schemas/src/rolling_stock/energy_source.rs b/editoast/editoast_schemas/src/rolling_stock/energy_source.rs index 01d9bd14a05..d7e980dd9bd 100644 --- a/editoast/editoast_schemas/src/rolling_stock/energy_source.rs +++ b/editoast/editoast_schemas/src/rolling_stock/energy_source.rs @@ -2,6 +2,13 @@ use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; +editoast_common::schemas! { + EnergySource, + EnergyStorage, + RefillLaw, + SpeedDependantPower, +} + // Energy sources schema /// energy source of a rolling stock diff --git a/editoast/editoast_schemas/src/rolling_stock/gamma.rs b/editoast/editoast_schemas/src/rolling_stock/gamma.rs index c1752265fc8..c5e3e393997 100644 --- a/editoast/editoast_schemas/src/rolling_stock/gamma.rs +++ b/editoast/editoast_schemas/src/rolling_stock/gamma.rs @@ -3,6 +3,10 @@ use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; +editoast_common::schemas! { + Gamma, +} + #[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, ToSchema, Derivative)] #[serde(deny_unknown_fields)] #[derivative(Hash)] diff --git a/editoast/editoast_schemas/src/rolling_stock/loading_gauge_type.rs b/editoast/editoast_schemas/src/rolling_stock/loading_gauge_type.rs index 53bfbcb8dd2..6cd1840e83b 100644 --- a/editoast/editoast_schemas/src/rolling_stock/loading_gauge_type.rs +++ b/editoast/editoast_schemas/src/rolling_stock/loading_gauge_type.rs @@ -3,6 +3,10 @@ use serde::Serialize; use strum::FromRepr; use utoipa::ToSchema; +editoast_common::schemas! { + LoadingGaugeType, +} + #[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, ToSchema, Hash, FromRepr)] pub enum LoadingGaugeType { G1, diff --git a/editoast/editoast_schemas/src/rolling_stock/rolling_resistance.rs b/editoast/editoast_schemas/src/rolling_stock/rolling_resistance.rs index dac24f7d3d3..9f7d81c0935 100644 --- a/editoast/editoast_schemas/src/rolling_stock/rolling_resistance.rs +++ b/editoast/editoast_schemas/src/rolling_stock/rolling_resistance.rs @@ -3,6 +3,10 @@ use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; +editoast_common::schemas! { + RollingResistance, +} + #[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, ToSchema, Derivative)] #[derivative(Hash)] #[serde(deny_unknown_fields)] diff --git a/editoast/editoast_schemas/src/rolling_stock/rolling_stock_livery.rs b/editoast/editoast_schemas/src/rolling_stock/rolling_stock_livery.rs index d7a25a86988..5b6a179307d 100644 --- a/editoast/editoast_schemas/src/rolling_stock/rolling_stock_livery.rs +++ b/editoast/editoast_schemas/src/rolling_stock/rolling_stock_livery.rs @@ -2,6 +2,11 @@ use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; +editoast_common::schemas! { + RollingStockLivery, + RollingStockLiveryMetadata, +} + #[derive(Debug, Deserialize, Serialize, ToSchema)] pub struct RollingStockLivery { pub id: i64, diff --git a/editoast/editoast_schemas/src/rolling_stock/rolling_stock_metadata.rs b/editoast/editoast_schemas/src/rolling_stock/rolling_stock_metadata.rs index b474064f61d..cbb02706d27 100644 --- a/editoast/editoast_schemas/src/rolling_stock/rolling_stock_metadata.rs +++ b/editoast/editoast_schemas/src/rolling_stock/rolling_stock_metadata.rs @@ -2,6 +2,10 @@ use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; +editoast_common::schemas! { + RollingStockMetadata, +} + #[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, ToSchema)] #[serde(deny_unknown_fields)] pub struct RollingStockMetadata { diff --git a/editoast/editoast_schemas/src/rolling_stock/supported_signaling_systems.rs b/editoast/editoast_schemas/src/rolling_stock/supported_signaling_systems.rs index 056953d620f..fd54c473006 100644 --- a/editoast/editoast_schemas/src/rolling_stock/supported_signaling_systems.rs +++ b/editoast/editoast_schemas/src/rolling_stock/supported_signaling_systems.rs @@ -2,6 +2,10 @@ use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; +editoast_common::schemas! { + RollingStockSupportedSignalingSystems, +} + #[derive(Clone, Debug, PartialEq, Deserialize, Serialize, ToSchema)] pub struct RollingStockSupportedSignalingSystems(pub Vec); diff --git a/editoast/src/views/rolling_stocks/mod.rs b/editoast/src/views/rolling_stocks/mod.rs index 12e7e14d722..fbbdea29007 100644 --- a/editoast/src/views/rolling_stocks/mod.rs +++ b/editoast/src/views/rolling_stocks/mod.rs @@ -588,7 +588,6 @@ pub mod tests { use crate::fixtures::tests::train_schedule_with_scenario; use crate::models::rolling_stock::tests::get_invalid_effort_curves; use crate::modelsv2::rolling_stock_model::RollingStockModel; - use crate::modelsv2::Model; use crate::views::rolling_stocks::rolling_stock_form::RollingStockForm; use crate::views::tests::create_test_service; use crate::DbPool; @@ -642,29 +641,7 @@ pub mod tests { let response_body: RollingStock = assert_status_and_read!(post_response, StatusCode::OK); let rolling_stock_id: i64 = response_body.id; - let response_body = RollingStockModel::changeset() - .railjson_version(response_body.railjson_version) - .name(response_body.name) - .effort_curves(response_body.effort_curves) - .metadata(response_body.metadata) - .length(response_body.length) - .max_speed(response_body.max_speed) - .startup_time(response_body.startup_time) - .startup_acceleration(response_body.startup_acceleration) - .comfort_acceleration(response_body.comfort_acceleration) - .gamma(response_body.gamma) - .inertia_coefficient(response_body.inertia_coefficient) - .base_power_class(response_body.base_power_class) - .mass(response_body.mass) - .rolling_resistance(response_body.rolling_resistance) - .loading_gauge(response_body.loading_gauge) - .power_restrictions(response_body.power_restrictions) - .energy_sources(response_body.energy_sources) - .electrical_power_startup_time(response_body.electrical_power_startup_time) - .raise_pantograph_time(response_body.raise_pantograph_time) - .supported_signaling_systems(response_body.supported_signaling_systems); - - assert_eq!(response_body.name, Some(rolling_stock_form.name)); + assert_eq!(Some(response_body.name), Some(rolling_stock_form.name)); // Check rolling_stock deletion let delete_request = rolling_stock_delete_request(rolling_stock_id);