diff --git a/crates/fkl_parser/src/tests.rs b/crates/fkl_parser/src/tests.rs index c884706..a5a0127 100644 --- a/crates/fkl_parser/src/tests.rs +++ b/crates/fkl_parser/src/tests.rs @@ -199,7 +199,7 @@ ValueObject Notifications { } initializer: None, type_type: "".to_string(), }, - fields: vec![] + fields: vec![], }, Entity { name: "Reservation".to_string(), @@ -210,7 +210,19 @@ ValueObject Notifications { } initializer: None, type_type: "".to_string(), }, - fields: vec![], + fields: vec![ + Field { name: "id".to_string(), initializer: None, type_type: "String".to_string() }, + Field { name: "token".to_string(), initializer: None, type_type: "UUID".to_string() }, + Field { name: "status".to_string(), initializer: Some("ReservationStatus.OPEN".to_string()), type_type: "ReservationStatus".to_string() }, + Field { name: "expiresAt".to_string(), initializer: None, type_type: "LocalDateTime".to_string() }, + Field { name: "createdAt".to_string(), initializer: None, type_type: "LocalDateTime".to_string() }, + Field { name: "screeningId".to_string(), initializer: None, type_type: "String".to_string() }, + Field { name: "screeningStartTime".to_string(), initializer: None, type_type: "LocalDateTime".to_string() }, + Field { name: "name".to_string(), initializer: None, type_type: "String".to_string() }, + Field { name: "surname".to_string(), initializer: None, type_type: "String".to_string() }, + Field { name: "tickets".to_string(), initializer: None, type_type: "Set".to_string() }, + Field { name: "totalPrice".to_string(), initializer: None, type_type: "BigDecimal".to_string() }, + ], }, ], } @@ -232,7 +244,14 @@ ValueObject Notifications { } initializer: None, type_type: "".to_string(), }, - fields: vec![], + fields: vec![ + Field { name: "id".to_string(), initializer: None, type_type: "UUID".to_string() }, + Field { name: "mobile".to_string(), initializer: None, type_type: "String".to_string() }, + Field { name: "email".to_string(), initializer: None, type_type: "String".to_string() }, + Field { name: "username".to_string(), initializer: None, type_type: "String".to_string() }, + Field { name: "password".to_string(), initializer: None, type_type: "String".to_string() }, + Field { name: "address".to_string(), initializer: None, type_type: "String".to_string() }, + ], } ], } diff --git a/crates/fkl_parser/src/transform.rs b/crates/fkl_parser/src/transform.rs index 391ef3d..77edf60 100644 --- a/crates/fkl_parser/src/transform.rs +++ b/crates/fkl_parser/src/transform.rs @@ -47,9 +47,19 @@ impl MirTransform { }) } - fn update_aggregates(&self) -> Vec { + fn update_aggregates(&mut self) -> Vec { let mut contexts = vec![]; + self.aggregates.clone().iter().for_each(|(name, aggregate)| { + aggregate.entities.iter().for_each(|entity| { + if let Some(exist_entity) = self.entities.get(&entity.name) { + let aggregate = self.aggregates.get_mut(name).unwrap(); + aggregate.entities.remove(aggregate.entities.iter().position(|e| e.name == entity.name).unwrap()); + aggregate.entities.push(exist_entity.clone()); + } + }); + }); + self.contexts.values().for_each(|origin| { let mut context: BoundedContext = BoundedContext::new(&origin.name); @@ -267,7 +277,9 @@ Entity Shopping { initializer: None, type_type: "".to_string(), }, - fields: vec![], + fields: vec![ + Field { name: "id".to_string(), initializer: None, type_type: "String".to_string() } + ], } ], }],