Bonjour,
J'ai un controller ou j apelle un service.
Voici le code:
Ma question est la suivante comment pour appeller le service implementé l appel réel (RestSimpleServiceImpl) et appeler avec l appeler stuber.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public interface RestSimpleService { Client getClient(final String reference); } public class RestSimpleServiceSub implements RestSimpleService { public Client getClient(final String reference) { final Client client = new ClientImpl(); client.setReference(reference); client.setNom("Nom"); client.setPrenom("Prénom"); client.setSociete("Société"); client.setDateCreation(new LocalDate()); return client; } public class RestSimpleServiceImpl implements RestSimpleService { @Autowired private clientRepo; public RestSimpleServiceImpl(){ } public Client getClient(final String reference) { return clientRepo.findByRef(reference); } @Controller public class RestSimpleControleur { public RestSimpleControleur(){ } @Autowried private RestSimpleService service @ResponseBody @RequestMapping(value = "/client/{reference}", method = RequestMethod.GET) public Client getClient(@PathVariable final String reference) { return service().getClient(reference); } }
Je voudrais pouvoir switcher facilement pour faire des appell réel et des appel stuber.
Je vous remercie
Partager