1. Project Clover database Dom fev 10 2019 22:52:55 BRST
  2. Package rest

File AccountRepository.java

 

Coverage histogram

../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
5
3
2
52
41
3
0,6
1,67
1,5
1

Classes

Class Line # Actions
AccountRepository 24 3 0% 1 0
1.0100%
AccountRepository.Accounts 39 2 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    package rest;
2   
3    import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
4    import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
5   
6    import org.springframework.beans.factory.annotation.Autowired;
7    import org.springframework.hateoas.ResourceSupport;
8    import org.springframework.http.HttpEntity;
9    import org.springframework.http.HttpStatus;
10    import org.springframework.http.ResponseEntity;
11    import org.springframework.web.bind.annotation.RequestMapping;
12    import org.springframework.web.bind.annotation.RequestMethod;
13    import org.springframework.web.bind.annotation.RestController;
14   
15    import com.fasterxml.jackson.annotation.JsonCreator;
16    import com.fasterxml.jackson.annotation.JsonProperty;
17    import com.google.common.collect.Iterables;
18   
19    import rest.db1.FirstAccountRepository;
20    import rest.db2.SecondAccountRepository;
21   
22    @RestController
23    @RequestMapping(path = "/account")
 
24    public class AccountRepository {
25    @Autowired
26    private FirstAccountRepository firstAccountRepository;
27   
28    @Autowired
29    private SecondAccountRepository secondAccountRepository;
30   
 
31  1 toggle @RequestMapping(method = RequestMethod.GET)
32    public HttpEntity<Accounts> get() {
33  1 Accounts accounts = new Accounts(
34    Iterables.concat(firstAccountRepository.findAll(), secondAccountRepository.findAll()));
35  1 accounts.add(linkTo(methodOn(AccountRepository.class).get()).withSelfRel());
36  1 return new ResponseEntity<>(accounts, HttpStatus.OK);
37    }
38   
 
39    public class Accounts extends ResourceSupport {
40   
41    private final Iterable<Account> content;
42   
 
43  1 toggle @JsonCreator
44    public Accounts(@JsonProperty("content") Iterable<Account> content) {
45  1 this.content = content;
46    }
47   
 
48  1 toggle public Iterable<Account> getContent() {
49  1 return content;
50    }
51    }
52    }