MCPcopy Create free account
hub / github.com/cedar-policy/cedar-java / map_put_tests

Function map_put_tests

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

Source from the content-addressed store, hash-verified

1607
1608 #[test]
1609 fn map_put_tests() {
1610 let mut env = JVM.attach_current_thread().unwrap();
1611 let mut java_hash_map = Map::<JString, JString>::new(&mut env).unwrap();
1612
1613 let key = env.new_string("test_key").unwrap();
1614 let value = env.new_string("test_value").unwrap();
1615
1616 let result = java_hash_map.put(&mut env, key, value);
1617
1618 assert!(result.is_ok(), "Map put should succeed.");
1619
1620 let new_key = env.new_string("test_key").unwrap();
1621 let new_value = env.new_string("updated_value").unwrap();
1622
1623 let update_result = java_hash_map.put(&mut env, new_key, new_value);
1624
1625 assert!(result.is_ok(), "Map put should succeed.");
1626
1627 let update_result_jstr = JString::cast(&mut env, update_result.unwrap()).unwrap();
1628 let update_result_str = String::from(env.get_string(&update_result_jstr).unwrap());
1629
1630 assert_eq!(
1631 update_result_str, "test_value",
1632 "Value returned from map update should match the original value of test_key."
1633 )
1634 }
1635
1636 #[test]
1637 fn map_get_tests() {

Callers

nothing calls this directly

Calls 1

putMethod · 0.45

Tested by

no test coverage detected