Skip to content

Commit

Permalink
fix: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Oct 9, 2022
1 parent d6e9300 commit 5e9bdcf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 173 deletions.
10 changes: 1 addition & 9 deletions fkl_parser/src/mir/strategy/context_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ pub struct ContextMap {
pub state: ContextState,
pub contexts: Vec<BoundedContext>,
pub relations: Vec<ContextRelation>,

pub implementations: Vec<Implementation>,
// todo: add rest in the future
// some entities no in map
// pub rest_entities: Vec<Entity>,
// some value objects no in map
// pub rest_value_objects: Vec<ValueObject>,
pub layered: Option<LayeredArchitecture>,
}

Expand Down Expand Up @@ -105,11 +99,10 @@ impl Display for ContextMap {
self.layered.as_ref().map(|layered| {
writeln!(f, " LayeredArchitecture({})", layered.name).unwrap();
for layer in &layered.layers {
writeln!(f, " Layer {} ({})", layer.name, layer.package).unwrap();
writeln!(f, " Layer {} (\"{}\")", layer.name, layer.package).unwrap();
}
});

writeln!(f, "")?;
Ok(())
}
}
Expand Down Expand Up @@ -149,7 +142,6 @@ mod tests {
BoundedContext(TicketContext)
Aggregate(TicketAggregate)
Entity(TicketEntity)
"#);
}
}
2 changes: 1 addition & 1 deletion fkl_parser/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn do_parse_test(test_name: &str) -> bool {

let input = fs::read_to_string(input_path).unwrap();
let result = parse(&input).unwrap();
let result = format!("{:#?}", result);
let result = format!("{}", result);

if !output_path.exists() {
fs::write(&output_path, result).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion fkl_parser/test_data/parse/impl.fkl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ impl UserCreated {
flow {
via UserRepository::getUserById receive user: User
via UserRepository::save(user: User) receive user: User;
via Kafak send User to "user.create";
via Kafka send User to "user.create";
}
}
122 changes: 13 additions & 109 deletions fkl_parser/test_data/parse/impl.txt
Original file line number Diff line number Diff line change
@@ -1,109 +1,13 @@
ContextMap {
name: "TicketBooking",
state: ToBe,
contexts: [
BoundedContext {
name: "Reservation",
aggregates: [],
},
BoundedContext {
name: "TicketContext",
aggregates: [
Aggregate {
name: "Ticket",
description: "",
entities: [],
},
Aggregate {
name: "Reservation",
description: "",
entities: [],
},
],
},
],
relations: [
ContextRelation {
source: "Reservation",
target: "TicketContext",
connection_type: BiDirected,
source_type: [],
target_type: [],
},
],
implementations: [
PublishHttpApi(
HttpApiImpl {
name: "UserCreated",
target_aggregate: "",
target_entity: "",
qualified: "",
endpoint: HttpEndpoint {
name: "",
description: "",
path: "/user/{id}",
method: "POST",
request: None,
response: Some(
Response {
name: "User",
post_validate: None,
},
),
},
flow: Some(
Flow {
inline_doc: "",
steps: [
MethodCall(
MethodCall {
name: "",
object: "UserRepository",
method: "getUserById",
parameters: [],
return_type: Some(
VariableDefinition {
name: "user",
type_type: "User",
initializer: None,
},
),
},
),
MethodCall(
MethodCall {
name: "",
object: "UserRepository",
method: "save",
parameters: [
VariableDefinition {
name: "user",
type_type: "User",
initializer: None,
},
],
return_type: Some(
VariableDefinition {
name: "user",
type_type: "User",
initializer: None,
},
),
},
),
Message(
Message {
from: "Kafak",
to: "",
topic: "\"user.create\"",
message: "User",
},
),
],
},
),
},
),
],
layered: None,
}
ContextMap(TicketBooking)
Relation(Reservation <-> TicketContext)
BoundedContext(Reservation)
BoundedContext(TicketContext)
Aggregate(Ticket)
Aggregate(Reservation)
PublishHttpApi(UserCreated)
POST Path(/user/{id})
Response: User
Flow
MethodCall()
MethodCall()
Message(Kafka)
59 changes: 6 additions & 53 deletions fkl_parser/test_data/parse/layered.txt
Original file line number Diff line number Diff line change
@@ -1,53 +1,6 @@
ContextMap {
name: "",
state: ToBe,
contexts: [],
relations: [],
implementations: [],
layered: Some(
LayeredArchitecture {
name: "DDD",
description: "",
dependencies: [
Dependency {
source: "interface",
target: "application",
},
Dependency {
source: "interface",
target: "domain",
},
Dependency {
source: "domain",
target: "application",
},
Dependency {
source: "application",
target: "infrastructure",
},
Dependency {
source: "interface",
target: "infrastructure",
},
],
layers: [
Layer {
name: "interface",
package: "com.example.book",
},
Layer {
name: "domain",
package: "com.example.domain",
},
Layer {
name: "application",
package: "com.example.application",
},
Layer {
name: "infrastructure",
package: "com.example.infrastructure",
},
],
},
),
}
ContextMap()
LayeredArchitecture(DDD)
Layer interface ("com.example.book")
Layer domain ("com.example.domain")
Layer application ("com.example.application")
Layer infrastructure ("com.example.infrastructure")

0 comments on commit 5e9bdcf

Please sign in to comment.