|
23 | 23 | import com.google.api.generator.test.protoloader.RestTestProtoLoader; |
24 | 24 | import java.nio.file.Path; |
25 | 25 | import java.nio.file.Paths; |
| 26 | +import java.util.Arrays; |
| 27 | +import java.util.Collection; |
26 | 28 | import org.junit.Test; |
| 29 | +import org.junit.runner.RunWith; |
| 30 | +import org.junit.runners.Parameterized; |
27 | 31 |
|
| 32 | +@RunWith(Parameterized.class) |
28 | 33 | public class ServiceStubSettingsClassComposerTest { |
| 34 | + |
| 35 | + @Parameterized.Parameters |
| 36 | + public static Collection<Object[]> data() { |
| 37 | + return Arrays.asList( |
| 38 | + new Object[][] { |
| 39 | + { |
| 40 | + "ComplianceStubSettings.golden", |
| 41 | + RestTestProtoLoader.instance().parseCompliance() |
| 42 | + }, |
| 43 | + { |
| 44 | + "HttpJsonEchoStubSettings.golden", |
| 45 | + RestTestProtoLoader.instance().parseEcho() |
| 46 | + } |
| 47 | + }); |
| 48 | + } |
| 49 | + @Parameterized.Parameter public String goldenFileName; |
| 50 | + |
| 51 | + @Parameterized.Parameter(1) |
| 52 | + public GapicContext context; |
29 | 53 | @Test |
30 | 54 | public void generateServiceClasses() { |
31 | | - GapicContext context = RestTestProtoLoader.instance().parseCompliance(); |
32 | | - Service echoProtoService = context.services().get(0); |
| 55 | + Service protoService = context.services().get(0); |
33 | 56 | GapicClass clazz = |
34 | | - ServiceStubSettingsClassComposer.instance().generate(context, echoProtoService); |
| 57 | + ServiceStubSettingsClassComposer.instance().generate(context, protoService); |
35 | 58 |
|
36 | 59 | JavaWriterVisitor visitor = new JavaWriterVisitor(); |
37 | 60 | clazz.classDefinition().accept(visitor); |
38 | 61 | GoldenFileWriter.saveCodegenToFile( |
39 | | - this.getClass(), "ComplianceStubSettings.golden", visitor.write()); |
| 62 | + this.getClass(), goldenFileName, visitor.write()); |
40 | 63 | Path goldenFilePath = |
41 | | - Paths.get(GoldenFileWriter.getGoldenDir(this.getClass()), "ComplianceStubSettings.golden"); |
| 64 | + Paths.get(GoldenFileWriter.getGoldenDir(this.getClass()), goldenFileName); |
42 | 65 | Assert.assertCodeEquals(goldenFilePath, visitor.write()); |
43 | 66 | } |
44 | 67 | } |
0 commit comments