Debian Codegraph @

src/test/java/io/reactivex/rxjava3/validators/MaybeNo2Dot0Since.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.validators;
15
16 import static org.junit.Assert.fail;
17
18 import java.io.*;
19
20 import org.junit.Test;
21
22 import io.reactivex.rxjava3.core.Maybe;
23 import io.reactivex.rxjava3.testsupport.TestHelper;
24
25 /**
26 * Checks the source code of Maybe and finds unnecessary since 2.0 annotations in the
27 * method's javadocs.
28 */
29 public class MaybeNo2Dot0Since {
30
31 @Test
32 public void noSince20InMaybe() throws Exception {
33
34 File f = TestHelper.findSource(Maybe.class.getSimpleName());
35
36 String line;
37
38 StringBuilder b = new StringBuilder();
39
40 boolean classDefPassed = false;
41
42 BufferedReader in = new BufferedReader(new FileReader(f));
43 try {
44 int ln = 1;
45 while (true) {
46 line = in.readLine();
47
48 if (line == null) {
49 break;
50 }
51
52 if (line.startsWith("public abstract class Maybe<")) {
53 classDefPassed = true;
54 }
55
56 if (classDefPassed) {
57 if (line.contains("@since") && line.contains("2.0") && !line.contains("2.0.")) {
58 b.append("java.lang.RuntimeException: @since 2.0 found").append("\r\n")
59 .append(" at io.reactivex.Maybe (Maybe.java:").append(ln).append(")\r\n\r\n");
60 ;
61 }
62 }
63
64 ln++;
65 }
66 } finally {
67 in.close();
68 }
69
70 if (b.length() != 0) {
71 System.out.println(b);
72
73 fail(b.toString());
74 }
75 }
76 }