1
1
package org .commcare .formplayer .web .client ;
2
2
3
- import static org .springframework .test .web .client .match .MockRestRequestMatchers .method ;
4
- import static org .springframework .test .web .client .match .MockRestRequestMatchers .requestTo ;
5
- import static org .springframework .test .web .client .response .MockRestResponseCreators .withStatus ;
6
-
3
+ import org .commcare .formplayer .utils .MockRestTemplateBuilder ;
7
4
import org .junit .jupiter .api .BeforeEach ;
8
5
import org .junit .jupiter .api .Test ;
9
- import org .springframework .boot .web .client .RestTemplateBuilder ;
6
+ import org .junit .jupiter .api .extension .ExtendWith ;
7
+ import org .mockito .Mock ;
8
+ import org .mockito .junit .jupiter .MockitoExtension ;
9
+ import org .springframework .data .redis .core .ValueOperations ;
10
10
import org .springframework .http .HttpMethod ;
11
11
import org .springframework .http .HttpStatus ;
12
12
import org .springframework .http .MediaType ;
17
17
import java .net .URI ;
18
18
import java .net .URISyntaxException ;
19
19
20
+ import static org .springframework .test .web .client .match .MockRestRequestMatchers .method ;
21
+ import static org .springframework .test .web .client .match .MockRestRequestMatchers .requestTo ;
22
+ import static org .springframework .test .web .client .response .MockRestResponseCreators .withStatus ;
23
+
24
+ @ ExtendWith (MockitoExtension .class )
20
25
class RestTemplateConfigTest_noCustomization {
21
26
22
27
private RestTemplate restTemplate ;
23
28
24
29
private MockRestServiceServer mockServer ;
25
30
31
+ @ Mock
32
+ ValueOperations <String , String > originTokens ;
33
+
26
34
@ BeforeEach
27
35
public void init () throws URISyntaxException {
28
- restTemplate = getRestTemplate ("https://web" , "" );
36
+ restTemplate = getRestTemplate ("https://web" );
29
37
mockServer = MockRestServiceServer .createServer (restTemplate );
30
38
}
31
39
32
- protected RestTemplate getRestTemplate (String commcareHost , String mode )
40
+ protected RestTemplate getRestTemplate (String commcareHost )
33
41
throws URISyntaxException {
34
- return new RestTemplateConfig (commcareHost , "authKey" , mode )
35
- .restTemplate (new RestTemplateBuilder ());
42
+ return new MockRestTemplateBuilder ().withCommcareHost ("https://web" ).getRestTemplate ();
36
43
}
37
44
38
45
protected String getExpectedUrl () {
@@ -57,9 +64,12 @@ public void testRestTemplate() throws URISyntaxException {
57
64
58
65
class RestTemplateConfigTest_replaceHost extends RestTemplateConfigTest_noCustomization {
59
66
@ Override
60
- public RestTemplate getRestTemplate (String commcareHost , String mode )
67
+ public RestTemplate getRestTemplate (String commcareHost )
61
68
throws URISyntaxException {
62
- return super .getRestTemplate (commcareHost , RestTemplateConfig .MODE_REPLACE_HOST );
69
+ return new MockRestTemplateBuilder ()
70
+ .withCommcareHost ("https://web" )
71
+ .withExternalRequestMode (RestTemplateConfig .MODE_REPLACE_HOST )
72
+ .getRestTemplate ();
63
73
}
64
74
65
75
@ Override
0 commit comments