| 958 | |
| 959 | #[test] |
| 960 | fn test_extract_generic_class() { |
| 961 | let mut parser = JavaParser::new(); |
| 962 | let source = r#" |
| 963 | public class Cache<K, V> { |
| 964 | private Map<K, V> data; |
| 965 | |
| 966 | public V get(K key) { |
| 967 | return data.get(key); |
| 968 | } |
| 969 | |
| 970 | public void put(K key, V value) { |
| 971 | data.put(key, value); |
| 972 | } |
| 973 | } |
| 974 | "#; |
| 975 | let entities = parser.extract(source, "Cache.java"); |
| 976 | |
| 977 | let cache = entities |
| 978 | .iter() |
| 979 | .find(|e| e.name == "Cache" && e.kind == EntityKind::Class); |
| 980 | assert!(cache.is_some(), "Should find Cache class"); |
| 981 | |
| 982 | assert!( |
| 983 | entities.iter().any(|e| e.name == "get"), |
| 984 | "Should find get method" |
| 985 | ); |
| 986 | assert!( |
| 987 | entities.iter().any(|e| e.name == "put"), |
| 988 | "Should find put method" |
| 989 | ); |
| 990 | } |
| 991 | |
| 992 | #[test] |
| 993 | fn test_empty_source() { |