| 981 | |
| 982 | #[test] |
| 983 | fn test_extract_generic_class() { |
| 984 | let mut parser = JavaParser::new(); |
| 985 | let source = r#" |
| 986 | public class Cache<K, V> { |
| 987 | private Map<K, V> data; |
| 988 | |
| 989 | public V get(K key) { |
| 990 | return data.get(key); |
| 991 | } |
| 992 | |
| 993 | public void put(K key, V value) { |
| 994 | data.put(key, value); |
| 995 | } |
| 996 | } |
| 997 | "#; |
| 998 | let entities = parser.extract(source, "Cache.java"); |
| 999 | |
| 1000 | let cache = entities |
| 1001 | .iter() |
| 1002 | .find(|e| e.name == "Cache" && e.kind == EntityKind::Class); |
| 1003 | assert!(cache.is_some(), "Should find Cache class"); |
| 1004 | |
| 1005 | assert!( |
| 1006 | entities.iter().any(|e| e.name == "get"), |
| 1007 | "Should find get method" |
| 1008 | ); |
| 1009 | assert!( |
| 1010 | entities.iter().any(|e| e.name == "put"), |
| 1011 | "Should find put method" |
| 1012 | ); |
| 1013 | } |
| 1014 | |
| 1015 | #[test] |
| 1016 | fn test_empty_source() { |