MCPcopy Index your code
hub / github.com/cedar-policy/cedar-java / to_json_internal_test

Function to_json_internal_test

CedarJavaFFI/src/interface.rs:1500–1520  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1498
1499 #[test]
1500 fn to_json_internal_test() {
1501 let mut env = JVM.attach_current_thread().unwrap();
1502 let input = r#"permit(principal, action, resource);"#;
1503 let jstr = env.new_string(input).unwrap();
1504 let result = to_json_internal(&mut env, jstr);
1505
1506 assert!(result.is_ok(), "Expected to_json to succeed");
1507
1508 let jval = result.unwrap();
1509 let obj = jval.l().unwrap();
1510 let actual_json_str: String = env.get_string(&obj.into()).unwrap().into();
1511
1512 let expected_policy = cedar_policy::Policy::from_str(input).unwrap();
1513 let expected_json_str =
1514 serde_json::to_string(&expected_policy.to_json().unwrap()).unwrap();
1515
1516 assert_eq!(
1517 actual_json_str, expected_json_str,
1518 "Generated JSON should match expected policy JSON format"
1519 );
1520 }
1521
1522 #[test]
1523 fn to_json_internal_invalid() {

Callers

nothing calls this directly

Calls 1

to_json_internalFunction · 0.85

Tested by

no test coverage detected