1515 */
1616package com .google .auto .factory .processor ;
1717
18- import static com .google .common .truth .Truth .assert_ ;
18+ import static com .google .common .truth .Truth .assertAbout ;
1919import static com .google .testing .compile .JavaSourceSubjectFactory .javaSource ;
2020import static com .google .testing .compile .JavaSourcesSubjectFactory .javaSources ;
2121
3434@ RunWith (JUnit4 .class )
3535public class AutoFactoryProcessorTest {
3636 @ Test public void simpleClass () {
37- assert_ (). about (javaSource ())
37+ assertAbout (javaSource ())
3838 .that (JavaFileObjects .forResource ("good/SimpleClass.java" ))
3939 .processedWith (new AutoFactoryProcessor ())
4040 .compilesWithoutError ()
4141 .and ().generatesSources (JavaFileObjects .forResource ("expected/SimpleClassFactory.java" ));
4242 }
4343
4444 @ Test public void simpleClassNonFinal () {
45- assert_ (). about (javaSource ())
45+ assertAbout (javaSource ())
4646 .that (JavaFileObjects .forResource ("good/SimpleClassNonFinal.java" ))
4747 .processedWith (new AutoFactoryProcessor ())
4848 .compilesWithoutError ()
@@ -51,23 +51,23 @@ public class AutoFactoryProcessorTest {
5151 }
5252
5353 @ Test public void publicClass () {
54- assert_ (). about (javaSource ())
54+ assertAbout (javaSource ())
5555 .that (JavaFileObjects .forResource ("good/PublicClass.java" ))
5656 .processedWith (new AutoFactoryProcessor ())
5757 .compilesWithoutError ()
5858 .and ().generatesSources (JavaFileObjects .forResource ("expected/PublicClassFactory.java" ));
5959 }
6060
6161 @ Test public void simpleClassCustomName () {
62- assert_ (). about (javaSource ())
62+ assertAbout (javaSource ())
6363 .that (JavaFileObjects .forResource ("good/SimpleClassCustomName.java" ))
6464 .processedWith (new AutoFactoryProcessor ())
6565 .compilesWithoutError ()
6666 .and ().generatesSources (JavaFileObjects .forResource ("expected/CustomNamedFactory.java" ));
6767 }
6868
6969 @ Test public void simpleClassMixedDeps () {
70- assert_ (). about (javaSources ())
70+ assertAbout (javaSources ())
7171 .that (ImmutableSet .of (
7272 JavaFileObjects .forResource ("good/SimpleClassMixedDeps.java" ),
7373 JavaFileObjects .forResource ("support/AQualifier.java" )))
@@ -78,7 +78,7 @@ public class AutoFactoryProcessorTest {
7878 }
7979
8080 @ Test public void simpleClassPassedDeps () {
81- assert_ (). about (javaSource ())
81+ assertAbout (javaSource ())
8282 .that (JavaFileObjects .forResource ("good/SimpleClassPassedDeps.java" ))
8383 .processedWith (new AutoFactoryProcessor ())
8484 .compilesWithoutError ()
@@ -87,7 +87,7 @@ public class AutoFactoryProcessorTest {
8787 }
8888
8989 @ Test public void simpleClassProvidedDeps () {
90- assert_ (). about (javaSources ())
90+ assertAbout (javaSources ())
9191 .that (ImmutableSet .of (
9292 JavaFileObjects .forResource ("support/AQualifier.java" ),
9393 JavaFileObjects .forResource ("support/BQualifier.java" ),
@@ -99,7 +99,7 @@ public class AutoFactoryProcessorTest {
9999 }
100100
101101 @ Test public void constructorAnnotated () {
102- assert_ (). about (javaSource ())
102+ assertAbout (javaSource ())
103103 .that (JavaFileObjects .forResource ("good/ConstructorAnnotated.java" ))
104104 .processedWith (new AutoFactoryProcessor ())
105105 .compilesWithoutError ()
@@ -108,7 +108,7 @@ public class AutoFactoryProcessorTest {
108108 }
109109
110110 @ Test public void constructorAnnotatedNonFinal () {
111- assert_ (). about (javaSource ())
111+ assertAbout (javaSource ())
112112 .that (JavaFileObjects .forResource ("good/ConstructorAnnotatedNonFinal.java" ))
113113 .processedWith (new AutoFactoryProcessor ())
114114 .compilesWithoutError ()
@@ -117,7 +117,7 @@ public class AutoFactoryProcessorTest {
117117 }
118118
119119 @ Test public void simpleClassImplementingMarker () {
120- assert_ (). about (javaSource ())
120+ assertAbout (javaSource ())
121121 .that (JavaFileObjects .forResource ("good/SimpleClassImplementingMarker.java" ))
122122 .processedWith (new AutoFactoryProcessor ())
123123 .compilesWithoutError ()
@@ -126,7 +126,7 @@ public class AutoFactoryProcessorTest {
126126 }
127127
128128 @ Test public void simpleClassImplementingSimpleInterface () {
129- assert_ (). about (javaSource ())
129+ assertAbout (javaSource ())
130130 .that (JavaFileObjects .forResource ("good/SimpleClassImplementingSimpleInterface.java" ))
131131 .processedWith (new AutoFactoryProcessor ())
132132 .compilesWithoutError ()
@@ -135,7 +135,7 @@ public class AutoFactoryProcessorTest {
135135 }
136136
137137 @ Test public void mixedDepsImplementingInterfaces () {
138- assert_ (). about (javaSource ())
138+ assertAbout (javaSource ())
139139 .that (JavaFileObjects .forResource ("good/MixedDepsImplementingInterfaces.java" ))
140140 .processedWith (new AutoFactoryProcessor ())
141141 .compilesWithoutError ()
@@ -145,31 +145,31 @@ public class AutoFactoryProcessorTest {
145145
146146 @ Test public void failsWithMixedFinals () {
147147 JavaFileObject file = JavaFileObjects .forResource ("bad/MixedFinals.java" );
148- assert_ (). about (javaSource ())
149- .that (file )
150- .processedWith (new AutoFactoryProcessor ())
151- .failsToCompile ()
152- .withErrorContaining (
153- "Cannot mix allowSubclasses=true and allowSubclasses=false in one factory." )
154- .in (file ).onLine (25 ).atColumn (3 )
155- .and ().withErrorContaining (
156- "Cannot mix allowSubclasses=true and allowSubclasses=false in one factory." )
157- .in (file ).onLine (26 ).atColumn (3 );
148+ assertAbout (javaSource ())
149+ .that (file )
150+ .processedWith (new AutoFactoryProcessor ())
151+ .failsToCompile ()
152+ .withErrorContaining (
153+ "Cannot mix allowSubclasses=true and allowSubclasses=false in one factory." )
154+ .in (file ).onLine (25 ).atColumn (3 )
155+ .and ().withErrorContaining (
156+ "Cannot mix allowSubclasses=true and allowSubclasses=false in one factory." )
157+ .in (file ).onLine (26 ).atColumn (3 );
158158 }
159159
160160 @ Test public void failsOnGenericClass () {
161161 JavaFileObject file = JavaFileObjects .forResource ("bad/GenericClass.java" );
162- assert_ (). about (javaSource ())
163- .that (file )
164- .processedWith (new AutoFactoryProcessor ())
165- .failsToCompile ()
166- .withErrorContaining ("AutoFactory does not support generic types" )
167- .in (file ).onLine (21 ).atColumn (14 );
162+ assertAbout (javaSource ())
163+ .that (file )
164+ .processedWith (new AutoFactoryProcessor ())
165+ .failsToCompile ()
166+ .withErrorContaining ("AutoFactory does not support generic types" )
167+ .in (file ).onLine (21 ).atColumn (14 );
168168 }
169169
170170 @ Test public void providedButNoAutoFactory () {
171171 JavaFileObject file = JavaFileObjects .forResource ("bad/ProvidedButNoAutoFactory.java" );
172- assert_ (). about (javaSource ())
172+ assertAbout (javaSource ())
173173 .that (file )
174174 .processedWith (new AutoFactoryProcessor ())
175175 .failsToCompile ()
@@ -180,7 +180,7 @@ public class AutoFactoryProcessorTest {
180180
181181 @ Test public void providedOnMethodParameter () {
182182 JavaFileObject file = JavaFileObjects .forResource ("bad/ProvidedOnMethodParameter.java" );
183- assert_ (). about (javaSource ())
183+ assertAbout (javaSource ())
184184 .that (file )
185185 .processedWith (new AutoFactoryProcessor ())
186186 .failsToCompile ()
@@ -191,7 +191,7 @@ public class AutoFactoryProcessorTest {
191191
192192 @ Test public void invalidCustomName () {
193193 JavaFileObject file = JavaFileObjects .forResource ("bad/InvalidCustomName.java" );
194- assert_ (). about (javaSource ())
194+ assertAbout (javaSource ())
195195 .that (file )
196196 .processedWith (new AutoFactoryProcessor ())
197197 .failsToCompile ()
@@ -200,7 +200,7 @@ public class AutoFactoryProcessorTest {
200200 }
201201
202202 @ Test public void factoryExtendingAbstractClass () {
203- assert_ (). about (javaSource ())
203+ assertAbout (javaSource ())
204204 .that (JavaFileObjects .forResource ("good/FactoryExtendingAbstractClass.java" ))
205205 .processedWith (new AutoFactoryProcessor ())
206206 .compilesWithoutError ()
@@ -211,7 +211,7 @@ public class AutoFactoryProcessorTest {
211211 @ Test public void factoryExtendingAbstractClass_withConstructorParams () {
212212 JavaFileObject file =
213213 JavaFileObjects .forResource ("good/FactoryExtendingAbstractClassWithConstructorParams.java" );
214- assert_ (). about (javaSource ())
214+ assertAbout (javaSource ())
215215 .that (file )
216216 .processedWith (new AutoFactoryProcessor ())
217217 .failsToCompile ()
@@ -225,15 +225,15 @@ public class AutoFactoryProcessorTest {
225225 @ Test public void factoryExtendingAbstractClass_multipleConstructors () {
226226 JavaFileObject file = JavaFileObjects .forResource (
227227 "good/FactoryExtendingAbstractClassWithMultipleConstructors.java" );
228- assert_ (). about (javaSource ())
228+ assertAbout (javaSource ())
229229 .that (file )
230230 .processedWith (new AutoFactoryProcessor ())
231231 .compilesWithoutError ();
232232 }
233233
234234 @ Test public void factoryExtendingInterface () {
235235 JavaFileObject file = JavaFileObjects .forResource ("bad/InterfaceSupertype.java" );
236- assert_ (). about (javaSource ())
236+ assertAbout (javaSource ())
237237 .that (file )
238238 .processedWith (new AutoFactoryProcessor ())
239239 .failsToCompile ()
@@ -244,7 +244,7 @@ public class AutoFactoryProcessorTest {
244244
245245 @ Test public void factoryExtendingEnum () {
246246 JavaFileObject file = JavaFileObjects .forResource ("bad/EnumSupertype.java" );
247- assert_ (). about (javaSource ())
247+ assertAbout (javaSource ())
248248 .that (file )
249249 .processedWith (new AutoFactoryProcessor ())
250250 .failsToCompile ()
@@ -256,7 +256,7 @@ public class AutoFactoryProcessorTest {
256256
257257 @ Test public void factoryExtendingFinalClass () {
258258 JavaFileObject file = JavaFileObjects .forResource ("bad/FinalSupertype.java" );
259- assert_ (). about (javaSource ())
259+ assertAbout (javaSource ())
260260 .that (file )
261261 .processedWith (new AutoFactoryProcessor ())
262262 .failsToCompile ()
@@ -268,11 +268,25 @@ public class AutoFactoryProcessorTest {
268268 @ Test public void factoryImplementingGenericInterfaceExtension () {
269269 JavaFileObject file =
270270 JavaFileObjects .forResource ("good/FactoryImplementingGenericInterfaceExtension.java" );
271- assert_ (). about (javaSource ())
271+ assertAbout (javaSource ())
272272 .that (file )
273273 .processedWith (new AutoFactoryProcessor ())
274274 .compilesWithoutError ()
275275 .and ().generatesSources (JavaFileObjects .forResource (
276276 "expected/FactoryImplementingGenericInterfaceExtension.java" ));
277277 }
278+
279+ @ Test public void multipleFactoriesImpementingInterface () {
280+ JavaFileObject file =
281+ JavaFileObjects .forResource ("good/MultipleFactoriesImplementingInterface.java" );
282+ assertAbout (javaSource ())
283+ .that (file )
284+ .processedWith (new AutoFactoryProcessor ())
285+ .compilesWithoutError ()
286+ .and ().generatesSources (
287+ JavaFileObjects .forResource (
288+ "expected/MultipleFactoriesImplementingInterfaceAFactory.java" ),
289+ JavaFileObjects .forResource (
290+ "expected/MultipleFactoriesImplementingInterfaceBFactory.java" ));
291+ }
278292}
0 commit comments