| 864 | |
| 865 | #[test] |
| 866 | fn test_extract_fields() { |
| 867 | let mut parser = JavaParser::new(); |
| 868 | let source = r#" |
| 869 | public class Config { |
| 870 | public static final int MAX_RETRIES = 3; |
| 871 | public static final String API_URL = "https://api.example.com"; |
| 872 | private int timeout; |
| 873 | protected String host; |
| 874 | } |
| 875 | "#; |
| 876 | let entities = parser.extract(source, "Config.java"); |
| 877 | |
| 878 | let max = entities.iter().find(|e| e.name == "MAX_RETRIES"); |
| 879 | assert!(max.is_some(), "Should find MAX_RETRIES"); |
| 880 | assert_eq!( |
| 881 | max.unwrap().kind, |
| 882 | EntityKind::Const, |
| 883 | "static final should be Const" |
| 884 | ); |
| 885 | assert!(max.unwrap().exported); |
| 886 | |
| 887 | let timeout = entities.iter().find(|e| e.name == "timeout"); |
| 888 | assert!(timeout.is_some(), "Should find timeout field"); |
| 889 | assert_eq!( |
| 890 | timeout.unwrap().kind, |
| 891 | EntityKind::Variable, |
| 892 | "non-static field should be Variable" |
| 893 | ); |
| 894 | assert!( |
| 895 | !timeout.unwrap().exported, |
| 896 | "private field should not be exported" |
| 897 | ); |
| 898 | } |
| 899 | |
| 900 | #[test] |
| 901 | fn test_extract_imports() { |