use wasm4pm_compat::ocel::{
OCELAttributeValue, OCELEvent, OCELEventAttribute, OCELObject, OCELRelationship, OCEL,
};
#[test]
fn complete_ocel_log_queries_compose() {
let mut e1 = OCELEvent::new("e1".to_string(), "place_order")
.with_attribute(OCELEventAttribute::integer("amount", 100));
e1.relationships
.push(OCELRelationship::new("e1".to_string(), "ord-1".to_string()));
e1.relationships
.push(OCELRelationship::new("e1".to_string(), "itm-1".to_string()));
let e2 = OCELEvent::new("e2".to_string(), "ship");
let objects = vec![
OCELObject::new("ord-1".to_string(), "order"),
OCELObject::new("itm-1".to_string(), "item"),
OCELObject::new("itm-2".to_string(), "item"),
];
let log = OCEL::new(vec![e1, e2], objects);
assert_eq!(log.event_set().len(), 2, "two events");
assert_eq!(log.object_set().len(), 3, "three objects");
assert_eq!(log.count_objects_of_type("item"), 2, "two items");
assert_eq!(log.count_objects_of_type("order"), 1, "one order");
let links = log.e2o("e1");
assert_eq!(links.len(), 2, "e1 links to two objects");
assert!(links.iter().any(|(oid, _)| *oid == "ord-1"));
assert!(links.iter().any(|(oid, _)| *oid == "itm-1"));
assert!(log.e2o("e2").is_empty(), "e2 has no object links");
let val = log.eval("e1").expect("e1 has attributes");
match val.get("amount") {
Some(OCELAttributeValue::Integer(n)) => assert_eq!(*n, 100),
other => panic!("amount should be Integer(100); got {other:?}"),
}
}