| 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") |
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,33 |
|
| 24 |
|
public class AccountRepository { |
| 25 |
|
@Autowired |
| 26 |
|
private FirstAccountRepository firstAccountRepository; |
| 27 |
|
|
| 28 |
|
@Autowired |
| 29 |
|
private SecondAccountRepository secondAccountRepository; |
| 30 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
| 31 |
1 |
@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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 39 |
|
public class Accounts extends ResourceSupport { |
| 40 |
|
|
| 41 |
|
private final Iterable<Account> content; |
| 42 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 43 |
1 |
@JsonCreator... |
| 44 |
|
public Accounts(@JsonProperty("content") Iterable<Account> content) { |
| 45 |
1 |
this.content = content; |
| 46 |
|
} |
| 47 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 48 |
1 |
public Iterable<Account> getContent() {... |
| 49 |
1 |
return content; |
| 50 |
|
} |
| 51 |
|
} |
| 52 |
|
} |