Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/util/ObservableToFlowabeTestSync.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.internal.util;
15
16 import java.io.*;
17 import java.lang.reflect.Method;
18 import java.util.*;
19
20 /**
21 * Utility class that lists tests related to Observable that is not present in Flowable tests.
22 */
23 public final class ObservableToFlowabeTestSync {
24 private ObservableToFlowabeTestSync() {
25 throw new IllegalStateException("No instances!");
26 }
27
28 static List<String> readAllLines(File f) {
29 List<String> result = new ArrayList<>();
30 try {
31 BufferedReader in = new BufferedReader(new FileReader(f));
32 try {
33 String line;
34
35 while ((line = in.readLine()) != null) {
36 result.add(line);
37 }
38 } finally {
39 in.close();
40 }
41 } catch (IOException ex) {
42 ex.printStackTrace();
43 }
44 return result;
45 }
46
47 static void list(String basepath, String basepackage) throws Exception {
48 File[] observables = new File(basepath + "observable/").listFiles();
49
50 int count = 0;
51
52 for (File f : observables) {
53 if (!f.getName().endsWith(".java")) {
54 continue;
55 }
56 Class<?> clazz = Class.forName(basepackage + "observable." + f.getName().replace(".java", ""));
57
58 String cn = f.getName().replace(".java", "").replace("Observable", "Flowable");
59
60 File f2 = new File(basepath + "/flowable/" + cn + ".java");
61
62 if (!f2.exists()) {
63 continue;
64 }
65
66 Class<?> clazz2 = Class.forName(basepackage + "flowable." + cn);
67
68 Set<String> methods2 = new HashSet<>();
69
70 for (Method m : clazz2.getMethods()) {
71 methods2.add(m.getName());
72 }
73
74 for (Method m : clazz.getMethods()) {
75 if (!methods2.contains(m.getName()) && !methods2.contains(m.getName().replace("Observable", "Flowable"))) {
76 count++;
77 System.out.println();
78 System.out.print("java.lang.RuntimeException: missing > ");
79 System.out.println(m.getName());
80 System.out.print(" at ");
81 System.out.print(clazz.getName());
82 System.out.print(" (");
83 System.out.print(clazz.getSimpleName());
84 System.out.print(".java:");
85
86 List<String> lines = readAllLines(f);
87
88 int j = 1;
89 for (int i = 1; i <= lines.size(); i++) {
90 if (lines.get(i - 1).contains("public void " + m.getName() + "(")) {
91 j = i;
92 }
93 }
94 System.out.print(j);
95 System.out.println(")");
96
97 System.out.print(" at ");
98 System.out.print(clazz2.getName());
99 System.out.print(" (");
100 System.out.print(clazz2.getSimpleName());
101
102 lines = readAllLines(f2);
103
104 System.out.print(".java:");
105 System.out.print(lines.size() - 1);
106 System.out.println(")");
107 }
108 }
109 }
110
111 System.out.println();
112 System.out.println(count);
113 }
114
115 public static void main(String[] args) throws Exception {
116 list("src/test/java/io/reactivex/internal/operators/", "io.reactivex.internal.operators.");
117 // list("src/test/java/io/reactivex/", "io.reactivex.");
118 }
119 }