14
14
15
15
package com .google .api .generator .gapic .composer .rest ;
16
16
17
- import com .google .api .generator .engine .ast .TypeNode ;
18
17
import com .google .api .generator .engine .writer .JavaWriterVisitor ;
19
- import com .google .api .generator .gapic .model .Field ;
20
18
import com .google .api .generator .gapic .model .GapicClass ;
21
19
import com .google .api .generator .gapic .model .GapicContext ;
22
- import com .google .api .generator .gapic .model .HttpBindings .HttpBinding ;
23
20
import com .google .api .generator .gapic .model .Service ;
24
21
import com .google .api .generator .test .framework .Assert ;
25
22
import com .google .api .generator .test .framework .Utils ;
26
- import com .google .common .truth .Truth ;
27
23
import java .nio .file .Path ;
28
24
import java .nio .file .Paths ;
29
- import org .junit .Before ;
30
25
import org .junit .Test ;
31
26
32
27
public class HttpJsonServiceStubClassComposerTest {
33
-
34
- private HttpJsonServiceStubClassComposer composer ;
35
-
36
- @ Before
37
- public void setUp () throws Exception {
38
- composer = HttpJsonServiceStubClassComposer .instance ();
39
- }
40
-
41
28
@ Test
42
29
public void generateServiceClasses () {
43
30
GapicContext context = RestTestProtoLoader .instance ().parseCompliance ();
44
31
Service echoProtoService = context .services ().get (0 );
45
- GapicClass clazz = composer .generate (context , echoProtoService );
32
+ GapicClass clazz =
33
+ HttpJsonServiceStubClassComposer .instance ().generate (context , echoProtoService );
46
34
47
35
JavaWriterVisitor visitor = new JavaWriterVisitor ();
48
36
clazz .classDefinition ().accept (visitor );
@@ -51,49 +39,4 @@ public void generateServiceClasses() {
51
39
Paths .get (Utils .getGoldenDir (this .getClass ()), "HttpJsonComplianceStub.golden" );
52
40
Assert .assertCodeEquals (goldenFilePath , visitor .write ());
53
41
}
54
-
55
- @ Test
56
- public void
57
- getBindingFieldMethodName_shouldReturnGetFieldListIfTheFieldIsInLastPositionAndIsRepeated () {
58
- Field field =
59
- Field .builder ()
60
- .setIsRepeated (true )
61
- .setName ("doesNotMatter" )
62
- .setType (TypeNode .OBJECT )
63
- .build ();
64
- HttpBinding httpBinding =
65
- HttpBinding .builder ().setField (field ).setName ("doesNotMatter" ).build ();
66
- String actual = composer .getBindingFieldMethodName (httpBinding , 4 , 3 , "Values" );
67
- Truth .assertThat (actual ).isEqualTo ("getValuesList" );
68
- }
69
-
70
- @ Test
71
- public void
72
- getBindingFieldMethodName_shouldReturnGetFieldValueIfTheFieldIsInLastPositionAndIsEnum () {
73
- Field field =
74
- Field .builder ().setIsEnum (true ).setName ("doesNotMatter" ).setType (TypeNode .OBJECT ).build ();
75
- HttpBinding httpBinding =
76
- HttpBinding .builder ().setField (field ).setName ("doesNotMatter" ).build ();
77
- String actual = composer .getBindingFieldMethodName (httpBinding , 4 , 3 , "Enums" );
78
- Truth .assertThat (actual ).isEqualTo ("getEnumsValue" );
79
- }
80
-
81
- @ Test
82
- public void
83
- getBindingFieldMethodName_shouldReturnGetFieldIfTheFieldIsInLastPositionAndNotRepeatedOrEnum () {
84
- Field field = Field .builder ().setName ("doesNotMatter" ).setType (TypeNode .OBJECT ).build ();
85
- HttpBinding httpBinding =
86
- HttpBinding .builder ().setField (field ).setName ("doesNotMatter" ).build ();
87
- String actual = composer .getBindingFieldMethodName (httpBinding , 4 , 3 , "Value" );
88
- Truth .assertThat (actual ).isEqualTo ("getValue" );
89
- }
90
-
91
- @ Test
92
- public void getBindingFieldMethodName_shouldReturnGetFieldIfTheFieldIsNotInLastPosition () {
93
- Field field = Field .builder ().setName ("doesNotMatter" ).setType (TypeNode .OBJECT ).build ();
94
- HttpBinding httpBinding =
95
- HttpBinding .builder ().setField (field ).setName ("doesNotMatter" ).build ();
96
- String actual = composer .getBindingFieldMethodName (httpBinding , 4 , 1 , "Value" );
97
- Truth .assertThat (actual ).isEqualTo ("getValue" );
98
- }
99
42
}
0 commit comments