alexeyinkin commented on code in PR #24588: URL: https://github.com/apache/beam/pull/24588#discussion_r1050387684
########## .gitignore: ########## @@ -135,4 +135,7 @@ playground/frontend/playground_components/pubspec.lock **/*.tfvars # Ignore Katas auto-generated files -**/*-remote-info.yaml \ No newline at end of file +**/*-remote-info.yaml + +# Ignore files generated by playground components tests +playground/frontend/playground_components/test/tools/extract_symbols_java/temp Review Comment: Let's name it `dependencies` and put into `Dart/Flutter` section above. ########## playground/frontend/playground_components/test/tools/extract_symbols_java/extract_symbols_java_test.dart: ########## @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +import '../common.dart'; + +const _lang = 'java'; +const _tempDir = 'test/tools/extract_symbols_java/temp'; Review Comment: ```suggestion const _tempDir = 'test/tools/extract_symbols_$_lang/dependencies'; ``` ########## playground/frontend/playground_components/test/tools/extract_symbols_java/extract_symbols_java_test.dart: ########## @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +import '../common.dart'; + +const _lang = 'java'; +const _tempDir = 'test/tools/extract_symbols_java/temp'; + +void main() { + test('Extract SDK Symbols. $_lang', () async { + await testExtractSymbols( + language: _lang, + executables: ['java'], + arguments: [ + '-classpath', + await _buildClassPath(), + 'com.playground.extract_symbols.Main', + '../../test/tools/extract_symbols_$_lang/sdk_mock', + ], + ); + }); +} + +Future<String> _buildClassPath() async { + const dependencies = [ + 'https://repo1.maven.org/maven2/com/github/javaparser/javaparser-core/3.24.9/javaparser-core-3.24.9.jar', + 'https://repo1.maven.org/maven2/com/esotericsoftware/yamlbeans/yamlbeans/1.15/yamlbeans-1.15.jar', + ]; + + await _loadFilesIfNotExist(dependencies); + + final workingDirectory = Directory.current.path; + + return [ + '$workingDirectory/tools/extract_symbols_java/build/classes/java/main', Review Comment: ```suggestion '$workingDirectory/tools/extract_symbols_$_lang/build/classes/java/main', ``` ########## playground/frontend/playground_components/test/tools/extract_symbols_java/extract_symbols_java_test.dart: ########## @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +import '../common.dart'; + +const _lang = 'java'; +const _tempDir = 'test/tools/extract_symbols_java/temp'; + +void main() { + test('Extract SDK Symbols. $_lang', () async { + await testExtractSymbols( + language: _lang, + executables: ['java'], + arguments: [ + '-classpath', + await _buildClassPath(), + 'com.playground.extract_symbols.Main', + '../../test/tools/extract_symbols_$_lang/sdk_mock', + ], + ); + }); +} + +Future<String> _buildClassPath() async { + const dependencies = [ + 'https://repo1.maven.org/maven2/com/github/javaparser/javaparser-core/3.24.9/javaparser-core-3.24.9.jar', + 'https://repo1.maven.org/maven2/com/esotericsoftware/yamlbeans/yamlbeans/1.15/yamlbeans-1.15.jar', + ]; + + await _loadFilesIfNotExist(dependencies); Review Comment: ```suggestion await _downloadDependenciesIfNeed(dependencies); ``` ########## playground/frontend/playground_components/tools/extract_symbols_java/src/main/java/com/playground/extract_symbols/Main.java: ########## @@ -61,6 +63,10 @@ private static HashMap<String, ClassInfo> getDirSymbols(String sdkPathString) th return classInfoMap; } + static boolean isJavaNonTestFile(String stringPath) { + return stringPath.endsWith(".java") && !stringPath.contains("/test/"); Review Comment: 1. Add a non-`.java` file with a public class and a public member to make sure it is ignored. 2. Add `test` folder with a public class and a public member to make sure it is ignored. ########## playground/frontend/playground_components/test/tools/extract_symbols_java/sdk_mock/Class1.java: ########## @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package sdk_mock; + +public class Class1 { + public int field11; + public String field12; + private int field13; + + public void method11() { + System.out.println("method1"); + } + + public void method12() { + System.out.println("method2"); + } + + private void method13() { + System.out.println("method3"); + } Review Comment: ```suggestion void defaultMethod() {} public void publicMethod() {} protected void protectedMethod() {} private void privateMethod() {} ``` ########## playground/frontend/playground_components/test/tools/extract_symbols_java/sdk_mock/Class1.java: ########## @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package sdk_mock; + +public class Class1 { Review Comment: Please test classes with all 4 visibilities. They are better named after their visibility. ```suggestion public class PublicClass { ``` ########## playground/frontend/playground_components/test/tools/extract_symbols_java/sdk_mock/Class1.java: ########## @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package sdk_mock; + +public class Class1 { + public int field11; + public String field12; + private int field13; Review Comment: It's easier to read the test expectation if field names reflect visibility. Please test all 4 visibilities: ```suggestion int defaultField; public int publicField; protected int protectedField; private int privateField; ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
