3939})
4040public abstract class BaseProcessor extends AbstractProcessor {
4141
42- private static final String HTTP_CONTROLLERS_TXT = "controllers.txt" ;
43-
42+ private static final String HTTP_CONTROLLERS_TXT = "testAPI/controllers.txt" ;
4443 protected String contextPathString ;
4544
4645 protected Map <String , String > packagePaths = new HashMap <>();
4746
48- private final Set <String > controllerFQNs = new HashSet <>();
47+ private final Set <String > clientFQNs = new HashSet <>();
4948
5049 @ Override
5150 public SourceVersion getSupportedSourceVersion () {
@@ -68,10 +67,12 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
6867 var txtFilePath = APContext .getBuildResource (HTTP_CONTROLLERS_TXT );
6968
7069 if (txtFilePath .toFile ().exists ()) {
71- Files .lines (txtFilePath ).forEach (controllerFQNs ::add );
70+ Files .lines (txtFilePath ).forEach (clientFQNs ::add );
7271 }
7372 if (APContext .isTestCompilation ()) {
74- controllerFQNs .stream ().map (APContext ::typeElement ).forEach (this ::writeClientAdapter );
73+ for (var path : clientFQNs ) {
74+ TestClientWriter .writeActual (path );
75+ }
7576 }
7677 } catch (IOException e ) {
7778 e .printStackTrace ();
@@ -124,7 +125,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
124125 try {
125126 Files .write (
126127 APContext .getBuildResource (HTTP_CONTROLLERS_TXT ),
127- controllerFQNs ,
128+ clientFQNs ,
128129 StandardOpenOption .CREATE ,
129130 StandardOpenOption .WRITE );
130131 } catch (IOException e ) {
@@ -175,26 +176,22 @@ private void writeAdapter(TypeElement controller) {
175176 try {
176177
177178 writeControllerAdapter (reader );
178- controllerFQNs . add ( controller . getQualifiedName (). toString () );
179+ writeClientAdapter ( reader );
179180
180181 } catch (final Throwable e ) {
181182 logError (reader .beanType (), "Failed to write $Route class " + e );
182183 }
183184 }
184185
185- private void writeClientAdapter (TypeElement controller ) {
186- final var packageFQN = elements ().getPackageOf (controller ).getQualifiedName ().toString ();
187- final var contextPath = Util .combinePath (contextPathString , packagePath (packageFQN ));
188- final var reader = new ControllerReader (controller , contextPath );
189- reader .read (true );
186+ private void writeClientAdapter (ControllerReader reader ) {
187+
190188 try {
191- if (controller .getInterfaces ().isEmpty ()
192- && "java.lang.Object" .equals (controller .getSuperclass ().toString ())) {
189+ if (reader . beanType () .getInterfaces ().isEmpty ()
190+ && "java.lang.Object" .equals (reader . beanType () .getSuperclass ().toString ())) {
193191 new TestClientWriter (reader ).write ();
192+ clientFQNs .add (reader .beanType ().getQualifiedName ().toString () + "$TestAPI" );
194193 }
195- writeControllerAdapter (reader );
196-
197- } catch (final Throwable e ) {
194+ } catch (final IOException e ) {
198195 logError (reader .beanType (), "Failed to write $Route class " + e );
199196 }
200197 }
0 commit comments