Cognitive Complexity, explained

Where every point of the entry point complexity score comes from. Cognitive Complexity charges +1 for each break in the linear reading order and +1 more per level of nesting it sits in; shorthand a reader takes in at a glance is free — a switch costs 1 however many cases it has, and else costs 1 with no nesting penalty. Add the annotations down the right-hand gutter and you get the number in the header.

+1 · nesting 0a break in the flow, at the top level of the method +3 · nesting 2the same break, two levels deep — 1 + 2 +1 · flatno nesting penalty: else, else if, &&/||, recursion, break to a label

HTTP / REST APIs

GET /api/owners 16 methods cost something, out of 71 in the flow 22

OwnerMapperImpl.toOwnerDtoCollection(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/OwnerMapperImpl.java:60

60 public List<OwnerDto> toOwnerDtoCollection(List<Owner> ownerCollection) {
61 if ( ownerCollection == null ) {if +11
62 return null;
63 }
64
65 List<OwnerDto> list = new ArrayList<OwnerDto>( ownerCollection.size() );
66 for ( Owner owner : ownerCollection ) {for-each +12
67 list.add( toOwnerDto( owner ) );
68 }
69
70 return list;
71 }

PetMapperImpl.toPetsDto(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:49

49 public List<PetDto> toPetsDto(List<Pet> pets) {
50 if ( pets == null ) {if +13
51 return null;
52 }
53
54 List<PetDto> list = new ArrayList<PetDto>( pets.size() );
55 for ( Pet pet : pets ) {for-each +14
56 list.add( toPetDto( pet ) );
57 }
58
59 return list;
60 }

VisitMapperImpl.toVisitsDto(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:76

76 public List<VisitDto> toVisitsDto(List<Visit> visits) {
77 if ( visits == null ) {if +15
78 return null;
79 }
80
81 List<VisitDto> list = new ArrayList<VisitDto>( visits.size() );
82 for ( Visit visit : visits ) {for-each +16
83 list.add( toVisitDto( visit ) );
84 }
85
86 return list;
87 }

VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:129

129 private String visitPetOwnerFirstName(Visit visit) {
130 Pet pet = visit.getPet();
131 if ( pet == null ) {if +17
132 return null;
133 }
134 Owner owner = pet.getOwner();
135 if ( owner == null ) {if +18
136 return null;
137 }
138 return owner.getFirstName();
139 }

VisitMapperImpl.visitPetOwnerId(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:117

117 private Integer visitPetOwnerId(Visit visit) {
118 Pet pet = visit.getPet();
119 if ( pet == null ) {if +19
120 return null;
121 }
122 Owner owner = pet.getOwner();
123 if ( owner == null ) {if +110
124 return null;
125 }
126 return owner.getId();
127 }

VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:141

141 private String visitPetOwnerLastName(Visit visit) {
142 Pet pet = visit.getPet();
143 if ( pet == null ) {if +111
144 return null;
145 }
146 Owner owner = pet.getOwner();
147 if ( owner == null ) {if +112
148 return null;
149 }
150 return owner.getLastName();
151 }

OwnerMapperImpl.toOwnerDto(Owner) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/OwnerMapperImpl.java:24

24 public OwnerDto toOwnerDto(Owner owner) {
25 if ( owner == null ) {if +113
26 return null;
27 }
28
29 OwnerDto ownerDto = new OwnerDto();
30
31 ownerDto.setId( owner.getId() );
32 ownerDto.setFirstName( owner.getFirstName() );
33 ownerDto.setLastName( owner.getLastName() );
34 ownerDto.setAddress( owner.getAddress() );
35 ownerDto.setCity( owner.getCity() );
36 ownerDto.setTelephone( owner.getTelephone() );
37 ownerDto.setPets( petMapper.toPetsDto( owner.getPets() ) );
38
39 return ownerDto;
40 }

PetMapperImpl.petOwnerId(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:151

151 private Integer petOwnerId(Pet pet) {
152 Owner owner = pet.getOwner();
153 if ( owner == null ) {if +114
154 return null;
155 }
156 return owner.getId();
157 }

PetMapperImpl.toPetDto(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:31

31 public PetDto toPetDto(Pet pet) {
32 if ( pet == null ) {if +115
33 return null;
34 }
35
36 PetDto petDto = new PetDto();
37
38 petDto.setOwnerId( petOwnerId( pet ) );
39 petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) );
40 petDto.setName( pet.getName() );
41 petDto.setBirthDate( pet.getBirthDate() );
42 petDto.setType( toPetTypeDto( pet.getType() ) );
43 petDto.setId( pet.getId() );
44
45 return petDto;
46 }

PetMapperImpl.toPetTypeDto(PetType) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:110

110 public PetTypeDto toPetTypeDto(PetType petType) {
111 if ( petType == null ) {if +116
112 return null;
113 }
114
115 PetTypeDto petTypeDto = new PetTypeDto();
116
117 petTypeDto.setName( petType.getName() );
118 petTypeDto.setId( petType.getId() );
119
120 return petTypeDto;
121 }

VisitMapperImpl.toVisitDto(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:53

53 public VisitDto toVisitDto(Visit visit) {
54 if ( visit == null ) {if +117
55 return null;
56 }
57
58 VisitDto visitDto = new VisitDto();
59
60 visitDto.setPetId( visitPetId( visit ) );
61 visitDto.setPetName( visitPetName( visit ) );
62 visitDto.setOwnerId( visitPetOwnerId( visit ) );
63 visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) );
64 visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) );
65 visitDto.setVetId( visitVetId( visit ) );
66 visitDto.setVetFirstName( visitVetFirstName( visit ) );
67 visitDto.setVetLastName( visitVetLastName( visit ) );
68 visitDto.setDate( visit.getDate() );
69 visitDto.setDescription( visit.getDescription() );
70 visitDto.setId( visit.getId() );
71
72 return visitDto;
73 }

VisitMapperImpl.visitPetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:101

101 private Integer visitPetId(Visit visit) {
102 Pet pet = visit.getPet();
103 if ( pet == null ) {if +118
104 return null;
105 }
106 return pet.getId();
107 }

VisitMapperImpl.visitPetName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:109

109 private String visitPetName(Visit visit) {
110 Pet pet = visit.getPet();
111 if ( pet == null ) {if +119
112 return null;
113 }
114 return pet.getName();
115 }

VisitMapperImpl.visitVetFirstName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:161

161 private String visitVetFirstName(Visit visit) {
162 Vet vet = visit.getVet();
163 if ( vet == null ) {if +120
164 return null;
165 }
166 return vet.getFirstName();
167 }

VisitMapperImpl.visitVetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:153

153 private Integer visitVetId(Visit visit) {
154 Vet vet = visit.getVet();
155 if ( vet == null ) {if +121
156 return null;
157 }
158 return vet.getId();
159 }

VisitMapperImpl.visitVetLastName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:169

169 private String visitVetLastName(Visit visit) {
170 Vet vet = visit.getVet();
171 if ( vet == null ) {if +122
172 return null;
173 }
174 return vet.getLastName();
175 }

Total for OwnerRestController.listOwners(String) = 22

GET /api/owners/{ownerId} 15 methods cost something, out of 70 in the flow 20

PetMapperImpl.toPetsDto(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:49

49 public List<PetDto> toPetsDto(List<Pet> pets) {
50 if ( pets == null ) {if +11
51 return null;
52 }
53
54 List<PetDto> list = new ArrayList<PetDto>( pets.size() );
55 for ( Pet pet : pets ) {for-each +12
56 list.add( toPetDto( pet ) );
57 }
58
59 return list;
60 }

VisitMapperImpl.toVisitsDto(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:76

76 public List<VisitDto> toVisitsDto(List<Visit> visits) {
77 if ( visits == null ) {if +13
78 return null;
79 }
80
81 List<VisitDto> list = new ArrayList<VisitDto>( visits.size() );
82 for ( Visit visit : visits ) {for-each +14
83 list.add( toVisitDto( visit ) );
84 }
85
86 return list;
87 }

VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:129

129 private String visitPetOwnerFirstName(Visit visit) {
130 Pet pet = visit.getPet();
131 if ( pet == null ) {if +15
132 return null;
133 }
134 Owner owner = pet.getOwner();
135 if ( owner == null ) {if +16
136 return null;
137 }
138 return owner.getFirstName();
139 }

VisitMapperImpl.visitPetOwnerId(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:117

117 private Integer visitPetOwnerId(Visit visit) {
118 Pet pet = visit.getPet();
119 if ( pet == null ) {if +17
120 return null;
121 }
122 Owner owner = pet.getOwner();
123 if ( owner == null ) {if +18
124 return null;
125 }
126 return owner.getId();
127 }

VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:141

141 private String visitPetOwnerLastName(Visit visit) {
142 Pet pet = visit.getPet();
143 if ( pet == null ) {if +19
144 return null;
145 }
146 Owner owner = pet.getOwner();
147 if ( owner == null ) {if +110
148 return null;
149 }
150 return owner.getLastName();
151 }

OwnerMapperImpl.toOwnerDto(Owner) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/OwnerMapperImpl.java:24

24 public OwnerDto toOwnerDto(Owner owner) {
25 if ( owner == null ) {if +111
26 return null;
27 }
28
29 OwnerDto ownerDto = new OwnerDto();
30
31 ownerDto.setId( owner.getId() );
32 ownerDto.setFirstName( owner.getFirstName() );
33 ownerDto.setLastName( owner.getLastName() );
34 ownerDto.setAddress( owner.getAddress() );
35 ownerDto.setCity( owner.getCity() );
36 ownerDto.setTelephone( owner.getTelephone() );
37 ownerDto.setPets( petMapper.toPetsDto( owner.getPets() ) );
38
39 return ownerDto;
40 }

PetMapperImpl.petOwnerId(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:151

151 private Integer petOwnerId(Pet pet) {
152 Owner owner = pet.getOwner();
153 if ( owner == null ) {if +112
154 return null;
155 }
156 return owner.getId();
157 }

PetMapperImpl.toPetDto(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:31

31 public PetDto toPetDto(Pet pet) {
32 if ( pet == null ) {if +113
33 return null;
34 }
35
36 PetDto petDto = new PetDto();
37
38 petDto.setOwnerId( petOwnerId( pet ) );
39 petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) );
40 petDto.setName( pet.getName() );
41 petDto.setBirthDate( pet.getBirthDate() );
42 petDto.setType( toPetTypeDto( pet.getType() ) );
43 petDto.setId( pet.getId() );
44
45 return petDto;
46 }

PetMapperImpl.toPetTypeDto(PetType) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:110

110 public PetTypeDto toPetTypeDto(PetType petType) {
111 if ( petType == null ) {if +114
112 return null;
113 }
114
115 PetTypeDto petTypeDto = new PetTypeDto();
116
117 petTypeDto.setName( petType.getName() );
118 petTypeDto.setId( petType.getId() );
119
120 return petTypeDto;
121 }

VisitMapperImpl.toVisitDto(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:53

53 public VisitDto toVisitDto(Visit visit) {
54 if ( visit == null ) {if +115
55 return null;
56 }
57
58 VisitDto visitDto = new VisitDto();
59
60 visitDto.setPetId( visitPetId( visit ) );
61 visitDto.setPetName( visitPetName( visit ) );
62 visitDto.setOwnerId( visitPetOwnerId( visit ) );
63 visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) );
64 visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) );
65 visitDto.setVetId( visitVetId( visit ) );
66 visitDto.setVetFirstName( visitVetFirstName( visit ) );
67 visitDto.setVetLastName( visitVetLastName( visit ) );
68 visitDto.setDate( visit.getDate() );
69 visitDto.setDescription( visit.getDescription() );
70 visitDto.setId( visit.getId() );
71
72 return visitDto;
73 }

VisitMapperImpl.visitPetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:101

101 private Integer visitPetId(Visit visit) {
102 Pet pet = visit.getPet();
103 if ( pet == null ) {if +116
104 return null;
105 }
106 return pet.getId();
107 }

VisitMapperImpl.visitPetName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:109

109 private String visitPetName(Visit visit) {
110 Pet pet = visit.getPet();
111 if ( pet == null ) {if +117
112 return null;
113 }
114 return pet.getName();
115 }

VisitMapperImpl.visitVetFirstName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:161

161 private String visitVetFirstName(Visit visit) {
162 Vet vet = visit.getVet();
163 if ( vet == null ) {if +118
164 return null;
165 }
166 return vet.getFirstName();
167 }

VisitMapperImpl.visitVetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:153

153 private Integer visitVetId(Visit visit) {
154 Vet vet = visit.getVet();
155 if ( vet == null ) {if +119
156 return null;
157 }
158 return vet.getId();
159 }

VisitMapperImpl.visitVetLastName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:169

169 private String visitVetLastName(Visit visit) {
170 Vet vet = visit.getVet();
171 if ( vet == null ) {if +120
172 return null;
173 }
174 return vet.getLastName();
175 }

Total for OwnerRestController.getOwner(int) = 20

GET /api/pets 14 methods cost something, out of 57 in the flow 19

PetMapperImpl.toPetsDto(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:49

49 public List<PetDto> toPetsDto(List<Pet> pets) {
50 if ( pets == null ) {if +11
51 return null;
52 }
53
54 List<PetDto> list = new ArrayList<PetDto>( pets.size() );
55 for ( Pet pet : pets ) {for-each +12
56 list.add( toPetDto( pet ) );
57 }
58
59 return list;
60 }

VisitMapperImpl.toVisitsDto(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:76

76 public List<VisitDto> toVisitsDto(List<Visit> visits) {
77 if ( visits == null ) {if +13
78 return null;
79 }
80
81 List<VisitDto> list = new ArrayList<VisitDto>( visits.size() );
82 for ( Visit visit : visits ) {for-each +14
83 list.add( toVisitDto( visit ) );
84 }
85
86 return list;
87 }

VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:129

129 private String visitPetOwnerFirstName(Visit visit) {
130 Pet pet = visit.getPet();
131 if ( pet == null ) {if +15
132 return null;
133 }
134 Owner owner = pet.getOwner();
135 if ( owner == null ) {if +16
136 return null;
137 }
138 return owner.getFirstName();
139 }

VisitMapperImpl.visitPetOwnerId(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:117

117 private Integer visitPetOwnerId(Visit visit) {
118 Pet pet = visit.getPet();
119 if ( pet == null ) {if +17
120 return null;
121 }
122 Owner owner = pet.getOwner();
123 if ( owner == null ) {if +18
124 return null;
125 }
126 return owner.getId();
127 }

VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:141

141 private String visitPetOwnerLastName(Visit visit) {
142 Pet pet = visit.getPet();
143 if ( pet == null ) {if +19
144 return null;
145 }
146 Owner owner = pet.getOwner();
147 if ( owner == null ) {if +110
148 return null;
149 }
150 return owner.getLastName();
151 }

PetMapperImpl.petOwnerId(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:151

151 private Integer petOwnerId(Pet pet) {
152 Owner owner = pet.getOwner();
153 if ( owner == null ) {if +111
154 return null;
155 }
156 return owner.getId();
157 }

PetMapperImpl.toPetDto(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:31

31 public PetDto toPetDto(Pet pet) {
32 if ( pet == null ) {if +112
33 return null;
34 }
35
36 PetDto petDto = new PetDto();
37
38 petDto.setOwnerId( petOwnerId( pet ) );
39 petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) );
40 petDto.setName( pet.getName() );
41 petDto.setBirthDate( pet.getBirthDate() );
42 petDto.setType( toPetTypeDto( pet.getType() ) );
43 petDto.setId( pet.getId() );
44
45 return petDto;
46 }

PetMapperImpl.toPetTypeDto(PetType) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:110

110 public PetTypeDto toPetTypeDto(PetType petType) {
111 if ( petType == null ) {if +113
112 return null;
113 }
114
115 PetTypeDto petTypeDto = new PetTypeDto();
116
117 petTypeDto.setName( petType.getName() );
118 petTypeDto.setId( petType.getId() );
119
120 return petTypeDto;
121 }

VisitMapperImpl.toVisitDto(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:53

53 public VisitDto toVisitDto(Visit visit) {
54 if ( visit == null ) {if +114
55 return null;
56 }
57
58 VisitDto visitDto = new VisitDto();
59
60 visitDto.setPetId( visitPetId( visit ) );
61 visitDto.setPetName( visitPetName( visit ) );
62 visitDto.setOwnerId( visitPetOwnerId( visit ) );
63 visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) );
64 visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) );
65 visitDto.setVetId( visitVetId( visit ) );
66 visitDto.setVetFirstName( visitVetFirstName( visit ) );
67 visitDto.setVetLastName( visitVetLastName( visit ) );
68 visitDto.setDate( visit.getDate() );
69 visitDto.setDescription( visit.getDescription() );
70 visitDto.setId( visit.getId() );
71
72 return visitDto;
73 }

VisitMapperImpl.visitPetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:101

101 private Integer visitPetId(Visit visit) {
102 Pet pet = visit.getPet();
103 if ( pet == null ) {if +115
104 return null;
105 }
106 return pet.getId();
107 }

VisitMapperImpl.visitPetName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:109

109 private String visitPetName(Visit visit) {
110 Pet pet = visit.getPet();
111 if ( pet == null ) {if +116
112 return null;
113 }
114 return pet.getName();
115 }

VisitMapperImpl.visitVetFirstName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:161

161 private String visitVetFirstName(Visit visit) {
162 Vet vet = visit.getVet();
163 if ( vet == null ) {if +117
164 return null;
165 }
166 return vet.getFirstName();
167 }

VisitMapperImpl.visitVetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:153

153 private Integer visitVetId(Visit visit) {
154 Vet vet = visit.getVet();
155 if ( vet == null ) {if +118
156 return null;
157 }
158 return vet.getId();
159 }

VisitMapperImpl.visitVetLastName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:169

169 private String visitVetLastName(Visit visit) {
170 Vet vet = visit.getVet();
171 if ( vet == null ) {if +119
172 return null;
173 }
174 return vet.getLastName();
175 }

Total for PetRestController.listPets() = 19

GET /api/owners/{ownerId}/pets/{petId} 13 methods cost something, out of 58 in the flow 17

VisitMapperImpl.toVisitsDto(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:76

76 public List<VisitDto> toVisitsDto(List<Visit> visits) {
77 if ( visits == null ) {if +11
78 return null;
79 }
80
81 List<VisitDto> list = new ArrayList<VisitDto>( visits.size() );
82 for ( Visit visit : visits ) {for-each +12
83 list.add( toVisitDto( visit ) );
84 }
85
86 return list;
87 }

VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:129

129 private String visitPetOwnerFirstName(Visit visit) {
130 Pet pet = visit.getPet();
131 if ( pet == null ) {if +13
132 return null;
133 }
134 Owner owner = pet.getOwner();
135 if ( owner == null ) {if +14
136 return null;
137 }
138 return owner.getFirstName();
139 }

VisitMapperImpl.visitPetOwnerId(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:117

117 private Integer visitPetOwnerId(Visit visit) {
118 Pet pet = visit.getPet();
119 if ( pet == null ) {if +15
120 return null;
121 }
122 Owner owner = pet.getOwner();
123 if ( owner == null ) {if +16
124 return null;
125 }
126 return owner.getId();
127 }

VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:141

141 private String visitPetOwnerLastName(Visit visit) {
142 Pet pet = visit.getPet();
143 if ( pet == null ) {if +17
144 return null;
145 }
146 Owner owner = pet.getOwner();
147 if ( owner == null ) {if +18
148 return null;
149 }
150 return owner.getLastName();
151 }

PetMapperImpl.petOwnerId(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:151

151 private Integer petOwnerId(Pet pet) {
152 Owner owner = pet.getOwner();
153 if ( owner == null ) {if +19
154 return null;
155 }
156 return owner.getId();
157 }

PetMapperImpl.toPetDto(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:31

31 public PetDto toPetDto(Pet pet) {
32 if ( pet == null ) {if +110
33 return null;
34 }
35
36 PetDto petDto = new PetDto();
37
38 petDto.setOwnerId( petOwnerId( pet ) );
39 petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) );
40 petDto.setName( pet.getName() );
41 petDto.setBirthDate( pet.getBirthDate() );
42 petDto.setType( toPetTypeDto( pet.getType() ) );
43 petDto.setId( pet.getId() );
44
45 return petDto;
46 }

PetMapperImpl.toPetTypeDto(PetType) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:110

110 public PetTypeDto toPetTypeDto(PetType petType) {
111 if ( petType == null ) {if +111
112 return null;
113 }
114
115 PetTypeDto petTypeDto = new PetTypeDto();
116
117 petTypeDto.setName( petType.getName() );
118 petTypeDto.setId( petType.getId() );
119
120 return petTypeDto;
121 }

VisitMapperImpl.toVisitDto(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:53

53 public VisitDto toVisitDto(Visit visit) {
54 if ( visit == null ) {if +112
55 return null;
56 }
57
58 VisitDto visitDto = new VisitDto();
59
60 visitDto.setPetId( visitPetId( visit ) );
61 visitDto.setPetName( visitPetName( visit ) );
62 visitDto.setOwnerId( visitPetOwnerId( visit ) );
63 visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) );
64 visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) );
65 visitDto.setVetId( visitVetId( visit ) );
66 visitDto.setVetFirstName( visitVetFirstName( visit ) );
67 visitDto.setVetLastName( visitVetLastName( visit ) );
68 visitDto.setDate( visit.getDate() );
69 visitDto.setDescription( visit.getDescription() );
70 visitDto.setId( visit.getId() );
71
72 return visitDto;
73 }

VisitMapperImpl.visitPetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:101

101 private Integer visitPetId(Visit visit) {
102 Pet pet = visit.getPet();
103 if ( pet == null ) {if +113
104 return null;
105 }
106 return pet.getId();
107 }

VisitMapperImpl.visitPetName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:109

109 private String visitPetName(Visit visit) {
110 Pet pet = visit.getPet();
111 if ( pet == null ) {if +114
112 return null;
113 }
114 return pet.getName();
115 }

VisitMapperImpl.visitVetFirstName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:161

161 private String visitVetFirstName(Visit visit) {
162 Vet vet = visit.getVet();
163 if ( vet == null ) {if +115
164 return null;
165 }
166 return vet.getFirstName();
167 }

VisitMapperImpl.visitVetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:153

153 private Integer visitVetId(Visit visit) {
154 Vet vet = visit.getVet();
155 if ( vet == null ) {if +116
156 return null;
157 }
158 return vet.getId();
159 }

VisitMapperImpl.visitVetLastName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:169

169 private String visitVetLastName(Visit visit) {
170 Vet vet = visit.getVet();
171 if ( vet == null ) {if +117
172 return null;
173 }
174 return vet.getLastName();
175 }

Total for OwnerRestController.getOwnersPet(int, int) = 17

GET /api/pets/{petId} 13 methods cost something, out of 56 in the flow 17

VisitMapperImpl.toVisitsDto(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:76

76 public List<VisitDto> toVisitsDto(List<Visit> visits) {
77 if ( visits == null ) {if +11
78 return null;
79 }
80
81 List<VisitDto> list = new ArrayList<VisitDto>( visits.size() );
82 for ( Visit visit : visits ) {for-each +12
83 list.add( toVisitDto( visit ) );
84 }
85
86 return list;
87 }

VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:129

129 private String visitPetOwnerFirstName(Visit visit) {
130 Pet pet = visit.getPet();
131 if ( pet == null ) {if +13
132 return null;
133 }
134 Owner owner = pet.getOwner();
135 if ( owner == null ) {if +14
136 return null;
137 }
138 return owner.getFirstName();
139 }

VisitMapperImpl.visitPetOwnerId(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:117

117 private Integer visitPetOwnerId(Visit visit) {
118 Pet pet = visit.getPet();
119 if ( pet == null ) {if +15
120 return null;
121 }
122 Owner owner = pet.getOwner();
123 if ( owner == null ) {if +16
124 return null;
125 }
126 return owner.getId();
127 }

VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:141

141 private String visitPetOwnerLastName(Visit visit) {
142 Pet pet = visit.getPet();
143 if ( pet == null ) {if +17
144 return null;
145 }
146 Owner owner = pet.getOwner();
147 if ( owner == null ) {if +18
148 return null;
149 }
150 return owner.getLastName();
151 }

PetMapperImpl.petOwnerId(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:151

151 private Integer petOwnerId(Pet pet) {
152 Owner owner = pet.getOwner();
153 if ( owner == null ) {if +19
154 return null;
155 }
156 return owner.getId();
157 }

PetMapperImpl.toPetDto(Pet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:31

31 public PetDto toPetDto(Pet pet) {
32 if ( pet == null ) {if +110
33 return null;
34 }
35
36 PetDto petDto = new PetDto();
37
38 petDto.setOwnerId( petOwnerId( pet ) );
39 petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) );
40 petDto.setName( pet.getName() );
41 petDto.setBirthDate( pet.getBirthDate() );
42 petDto.setType( toPetTypeDto( pet.getType() ) );
43 petDto.setId( pet.getId() );
44
45 return petDto;
46 }

PetMapperImpl.toPetTypeDto(PetType) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:110

110 public PetTypeDto toPetTypeDto(PetType petType) {
111 if ( petType == null ) {if +111
112 return null;
113 }
114
115 PetTypeDto petTypeDto = new PetTypeDto();
116
117 petTypeDto.setName( petType.getName() );
118 petTypeDto.setId( petType.getId() );
119
120 return petTypeDto;
121 }

VisitMapperImpl.toVisitDto(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:53

53 public VisitDto toVisitDto(Visit visit) {
54 if ( visit == null ) {if +112
55 return null;
56 }
57
58 VisitDto visitDto = new VisitDto();
59
60 visitDto.setPetId( visitPetId( visit ) );
61 visitDto.setPetName( visitPetName( visit ) );
62 visitDto.setOwnerId( visitPetOwnerId( visit ) );
63 visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) );
64 visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) );
65 visitDto.setVetId( visitVetId( visit ) );
66 visitDto.setVetFirstName( visitVetFirstName( visit ) );
67 visitDto.setVetLastName( visitVetLastName( visit ) );
68 visitDto.setDate( visit.getDate() );
69 visitDto.setDescription( visit.getDescription() );
70 visitDto.setId( visit.getId() );
71
72 return visitDto;
73 }

VisitMapperImpl.visitPetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:101

101 private Integer visitPetId(Visit visit) {
102 Pet pet = visit.getPet();
103 if ( pet == null ) {if +113
104 return null;
105 }
106 return pet.getId();
107 }

VisitMapperImpl.visitPetName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:109

109 private String visitPetName(Visit visit) {
110 Pet pet = visit.getPet();
111 if ( pet == null ) {if +114
112 return null;
113 }
114 return pet.getName();
115 }

VisitMapperImpl.visitVetFirstName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:161

161 private String visitVetFirstName(Visit visit) {
162 Vet vet = visit.getVet();
163 if ( vet == null ) {if +115
164 return null;
165 }
166 return vet.getFirstName();
167 }

VisitMapperImpl.visitVetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:153

153 private Integer visitVetId(Visit visit) {
154 Vet vet = visit.getVet();
155 if ( vet == null ) {if +116
156 return null;
157 }
158 return vet.getId();
159 }

VisitMapperImpl.visitVetLastName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:169

169 private String visitVetLastName(Visit visit) {
170 Vet vet = visit.getVet();
171 if ( vet == null ) {if +117
172 return null;
173 }
174 return vet.getLastName();
175 }

Total for PetRestController.getPet(int) = 17

POST /api/users 7 methods cost something, out of 34 in the flow 15

UserRestController.addUser(UserDto)+7

src/main/java/victor/training/petclinic/rest/UserRestController.java:27

27 public ResponseEntity<UserDto> addUser(@RequestBody @Validated UserDto userDto) {
28 User user = userMapper.toUser(userDto);
29
30 if (user.getRoles() == null || user.getRoles().isEmpty()) {if +1|| +12
31 throw new IllegalArgumentException("User must have at least a role set!");
32 }
33
34 for (Role role : user.getRoles()) {for-each +13
35 if (!role.getName().startsWith("ROLE_")) {if +2 · nesting 15
36 role.setName("ROLE_" + role.getName());
37 }
38
39 if (role.getUser() == null) {if +2 · nesting 17
40 role.setUser(user);
41 }
42 }
43
44 userRepository.save(user);
45 return ResponseEntity.created(UriComponentsBuilder.fromPath("/api/users/{username}")
46 .buildAndExpand(user.getUsername()).toUri())
47 .body(userMapper.toUserDto(user));
48 }

UserMapperImpl.roleDtoListToRoleSet(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/UserMapperImpl.java:66

66 protected Set<Role> roleDtoListToRoleSet(List<RoleDto> list) {
67 if ( list == null ) {if +18
68 return null;
69 }
70
71 Set<Role> set = LinkedHashSet.newLinkedHashSet( list.size() );
72 for ( RoleDto roleDto : list ) {for-each +19
73 set.add( roleDtoToRole( roleDto ) );
74 }
75
76 return set;
77 }

UserMapperImpl.roleSetToRoleDtoList(Set) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/UserMapperImpl.java:91

91 protected List<RoleDto> roleSetToRoleDtoList(Set<Role> set) {
92 if ( set == null ) {if +110
93 return null;
94 }
95
96 List<RoleDto> list = new ArrayList<RoleDto>( set.size() );
97 for ( Role role : set ) {for-each +111
98 list.add( roleToRoleDto( role ) );
99 }
100
101 return list;
102 }

UserMapperImpl.roleDtoToRole(RoleDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/UserMapperImpl.java:54

54 protected Role roleDtoToRole(RoleDto roleDto) {
55 if ( roleDto == null ) {if +112
56 return null;
57 }
58
59 Role role = new Role();
60
61 role.setName( roleDto.getName() );
62
63 return role;
64 }

UserMapperImpl.roleToRoleDto(Role) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/UserMapperImpl.java:79

79 protected RoleDto roleToRoleDto(Role role) {
80 if ( role == null ) {if +113
81 return null;
82 }
83
84 RoleDto roleDto = new RoleDto();
85
86 roleDto.setName( role.getName() );
87
88 return roleDto;
89 }

UserMapperImpl.toUser(UserDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/UserMapperImpl.java:23

23 public User toUser(UserDto userDto) {
24 if ( userDto == null ) {if +114
25 return null;
26 }
27
28 User user = new User();
29
30 user.setUsername( userDto.getUsername() );
31 user.setPassword( userDto.getPassword() );
32 user.setEnabled( userDto.getEnabled() );
33 user.setRoles( roleDtoListToRoleSet( userDto.getRoles() ) );
34
35 return user;
36 }

UserMapperImpl.toUserDto(User) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/UserMapperImpl.java:39

39 public UserDto toUserDto(User user) {
40 if ( user == null ) {if +115
41 return null;
42 }
43
44 UserDto userDto = new UserDto();
45
46 userDto.setUsername( user.getUsername() );
47 userDto.setPassword( user.getPassword() );
48 userDto.setEnabled( user.getEnabled() );
49 userDto.setRoles( roleSetToRoleDtoList( user.getRoles() ) );
50
51 return userDto;
52 }

Total for UserRestController.addUser(UserDto) = 15

GET /api/visits 10 methods cost something, out of 38 in the flow 14

VisitMapperImpl.toVisitsDto(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:76

76 public List<VisitDto> toVisitsDto(List<Visit> visits) {
77 if ( visits == null ) {if +11
78 return null;
79 }
80
81 List<VisitDto> list = new ArrayList<VisitDto>( visits.size() );
82 for ( Visit visit : visits ) {for-each +12
83 list.add( toVisitDto( visit ) );
84 }
85
86 return list;
87 }

VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:129

129 private String visitPetOwnerFirstName(Visit visit) {
130 Pet pet = visit.getPet();
131 if ( pet == null ) {if +13
132 return null;
133 }
134 Owner owner = pet.getOwner();
135 if ( owner == null ) {if +14
136 return null;
137 }
138 return owner.getFirstName();
139 }

VisitMapperImpl.visitPetOwnerId(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:117

117 private Integer visitPetOwnerId(Visit visit) {
118 Pet pet = visit.getPet();
119 if ( pet == null ) {if +15
120 return null;
121 }
122 Owner owner = pet.getOwner();
123 if ( owner == null ) {if +16
124 return null;
125 }
126 return owner.getId();
127 }

VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:141

141 private String visitPetOwnerLastName(Visit visit) {
142 Pet pet = visit.getPet();
143 if ( pet == null ) {if +17
144 return null;
145 }
146 Owner owner = pet.getOwner();
147 if ( owner == null ) {if +18
148 return null;
149 }
150 return owner.getLastName();
151 }

VisitMapperImpl.toVisitDto(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:53

53 public VisitDto toVisitDto(Visit visit) {
54 if ( visit == null ) {if +19
55 return null;
56 }
57
58 VisitDto visitDto = new VisitDto();
59
60 visitDto.setPetId( visitPetId( visit ) );
61 visitDto.setPetName( visitPetName( visit ) );
62 visitDto.setOwnerId( visitPetOwnerId( visit ) );
63 visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) );
64 visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) );
65 visitDto.setVetId( visitVetId( visit ) );
66 visitDto.setVetFirstName( visitVetFirstName( visit ) );
67 visitDto.setVetLastName( visitVetLastName( visit ) );
68 visitDto.setDate( visit.getDate() );
69 visitDto.setDescription( visit.getDescription() );
70 visitDto.setId( visit.getId() );
71
72 return visitDto;
73 }

VisitMapperImpl.visitPetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:101

101 private Integer visitPetId(Visit visit) {
102 Pet pet = visit.getPet();
103 if ( pet == null ) {if +110
104 return null;
105 }
106 return pet.getId();
107 }

VisitMapperImpl.visitPetName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:109

109 private String visitPetName(Visit visit) {
110 Pet pet = visit.getPet();
111 if ( pet == null ) {if +111
112 return null;
113 }
114 return pet.getName();
115 }

VisitMapperImpl.visitVetFirstName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:161

161 private String visitVetFirstName(Visit visit) {
162 Vet vet = visit.getVet();
163 if ( vet == null ) {if +112
164 return null;
165 }
166 return vet.getFirstName();
167 }

VisitMapperImpl.visitVetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:153

153 private Integer visitVetId(Visit visit) {
154 Vet vet = visit.getVet();
155 if ( vet == null ) {if +113
156 return null;
157 }
158 return vet.getId();
159 }

VisitMapperImpl.visitVetLastName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:169

169 private String visitVetLastName(Visit visit) {
170 Vet vet = visit.getVet();
171 if ( vet == null ) {if +114
172 return null;
173 }
174 return vet.getLastName();
175 }

Total for VisitRestController.listVisits() = 14

GET /api/visits/{visitId} 9 methods cost something, out of 37 in the flow 12

VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:129

129 private String visitPetOwnerFirstName(Visit visit) {
130 Pet pet = visit.getPet();
131 if ( pet == null ) {if +11
132 return null;
133 }
134 Owner owner = pet.getOwner();
135 if ( owner == null ) {if +12
136 return null;
137 }
138 return owner.getFirstName();
139 }

VisitMapperImpl.visitPetOwnerId(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:117

117 private Integer visitPetOwnerId(Visit visit) {
118 Pet pet = visit.getPet();
119 if ( pet == null ) {if +13
120 return null;
121 }
122 Owner owner = pet.getOwner();
123 if ( owner == null ) {if +14
124 return null;
125 }
126 return owner.getId();
127 }

VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:141

141 private String visitPetOwnerLastName(Visit visit) {
142 Pet pet = visit.getPet();
143 if ( pet == null ) {if +15
144 return null;
145 }
146 Owner owner = pet.getOwner();
147 if ( owner == null ) {if +16
148 return null;
149 }
150 return owner.getLastName();
151 }

VisitMapperImpl.toVisitDto(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:53

53 public VisitDto toVisitDto(Visit visit) {
54 if ( visit == null ) {if +17
55 return null;
56 }
57
58 VisitDto visitDto = new VisitDto();
59
60 visitDto.setPetId( visitPetId( visit ) );
61 visitDto.setPetName( visitPetName( visit ) );
62 visitDto.setOwnerId( visitPetOwnerId( visit ) );
63 visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) );
64 visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) );
65 visitDto.setVetId( visitVetId( visit ) );
66 visitDto.setVetFirstName( visitVetFirstName( visit ) );
67 visitDto.setVetLastName( visitVetLastName( visit ) );
68 visitDto.setDate( visit.getDate() );
69 visitDto.setDescription( visit.getDescription() );
70 visitDto.setId( visit.getId() );
71
72 return visitDto;
73 }

VisitMapperImpl.visitPetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:101

101 private Integer visitPetId(Visit visit) {
102 Pet pet = visit.getPet();
103 if ( pet == null ) {if +18
104 return null;
105 }
106 return pet.getId();
107 }

VisitMapperImpl.visitPetName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:109

109 private String visitPetName(Visit visit) {
110 Pet pet = visit.getPet();
111 if ( pet == null ) {if +19
112 return null;
113 }
114 return pet.getName();
115 }

VisitMapperImpl.visitVetFirstName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:161

161 private String visitVetFirstName(Visit visit) {
162 Vet vet = visit.getVet();
163 if ( vet == null ) {if +110
164 return null;
165 }
166 return vet.getFirstName();
167 }

VisitMapperImpl.visitVetId(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:153

153 private Integer visitVetId(Visit visit) {
154 Vet vet = visit.getVet();
155 if ( vet == null ) {if +111
156 return null;
157 }
158 return vet.getId();
159 }

VisitMapperImpl.visitVetLastName(Visit) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:169

169 private String visitVetLastName(Visit visit) {
170 Vet vet = visit.getVet();
171 if ( vet == null ) {if +112
172 return null;
173 }
174 return vet.getLastName();
175 }

Total for VisitRestController.getVisit(int) = 12

GET /api/vets 4 methods cost something, out of 22 in the flow 6

SpecialtyMapperImpl.toSpecialtyDtos(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:49

49 public List<SpecialtyDto> toSpecialtyDtos(List<Specialty> specialties) {
50 if ( specialties == null ) {if +11
51 return null;
52 }
53
54 List<SpecialtyDto> list = new ArrayList<SpecialtyDto>( specialties.size() );
55 for ( Specialty specialty : specialties ) {for-each +12
56 list.add( toSpecialtyDto( specialty ) );
57 }
58
59 return list;
60 }

VetMapperImpl.toVetDtos(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/VetMapperImpl.java:71

71 public List<VetDto> toVetDtos(List<Vet> vets) {
72 if ( vets == null ) {if +13
73 return null;
74 }
75
76 List<VetDto> list = new ArrayList<VetDto>( vets.size() );
77 for ( Vet vet : vets ) {for-each +14
78 list.add( toVetDto( vet ) );
79 }
80
81 return list;
82 }

SpecialtyMapperImpl.toSpecialtyDto(Specialty) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:34

34 public SpecialtyDto toSpecialtyDto(Specialty specialty) {
35 if ( specialty == null ) {if +15
36 return null;
37 }
38
39 SpecialtyDto specialtyDto = new SpecialtyDto();
40
41 specialtyDto.setId( specialty.getId() );
42 specialtyDto.setName( specialty.getName() );
43 specialtyDto.setDescription( specialty.getDescription() );
44
45 return specialtyDto;
46 }

VetMapperImpl.toVetDto(Vet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VetMapperImpl.java:55

55 public VetDto toVetDto(Vet vet) {
56 if ( vet == null ) {if +16
57 return null;
58 }
59
60 VetDto vetDto = new VetDto();
61
62 vetDto.setFirstName( vet.getFirstName() );
63 vetDto.setLastName( vet.getLastName() );
64 vetDto.setSpecialties( specialtyMapper.toSpecialtyDtos( vet.getSpecialties() ) );
65 vetDto.setId( vet.getId() );
66
67 return vetDto;
68 }

Total for VetRestController.listVets() = 6

POST /api/vets 4 methods cost something, out of 27 in the flow 5

SpecialtyMapperImpl.toSpecialty(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:63

63 public List<Specialty> toSpecialty(List<SpecialtyDto> specialties) {
64 if ( specialties == null ) {if +11
65 return null;
66 }
67
68 List<Specialty> list = new ArrayList<Specialty>( specialties.size() );
69 for ( SpecialtyDto specialtyDto : specialties ) {for-each +12
70 list.add( toSpecialty( specialtyDto ) );
71 }
72
73 return list;
74 }

SpecialtyMapperImpl.toSpecialty(SpecialtyDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:19

19 public Specialty toSpecialty(SpecialtyDto specialtyDto) {
20 if ( specialtyDto == null ) {if +13
21 return null;
22 }
23
24 Specialty specialty = new Specialty();
25
26 specialty.setId( specialtyDto.getId() );
27 specialty.setName( specialtyDto.getName() );
28 specialty.setDescription( specialtyDto.getDescription() );
29
30 return specialty;
31 }

VetMapperImpl.toVet(VetDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VetMapperImpl.java:24

24 public Vet toVet(VetDto vetDto) {
25 if ( vetDto == null ) {if +14
26 return null;
27 }
28
29 Vet vet = new Vet();
30
31 vet.setId( vetDto.getId() );
32 vet.setFirstName( vetDto.getFirstName() );
33 vet.setLastName( vetDto.getLastName() );
34 vet.setSpecialties( specialtyMapper.toSpecialty( vetDto.getSpecialties() ) );
35
36 return vet;
37 }

VetRestController.updateSpecialties(Vet)+1

src/main/java/victor/training/petclinic/rest/VetRestController.java:76

76 private void updateSpecialties(Vet currentVet) {
77 if (currentVet.getNrOfSpecialties() > 0) {if +15
78 Set<String> names = currentVet.getSpecialties().stream().map(Specialty::getName)
79 .collect(Collectors.toSet());
80 List<Specialty> vetSpecialities = specialtyRepository.findSpecialtiesByNameIn(names);
81 currentVet.setSpecialties(vetSpecialities);
82 }
83 vetRepository.save(currentVet);
84 }

Total for VetRestController.addVet(VetDto) = 5

PUT /api/vets/{vetId} 4 methods cost something, out of 25 in the flow 5

SpecialtyMapperImpl.toSpecialty(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:63

63 public List<Specialty> toSpecialty(List<SpecialtyDto> specialties) {
64 if ( specialties == null ) {if +11
65 return null;
66 }
67
68 List<Specialty> list = new ArrayList<Specialty>( specialties.size() );
69 for ( SpecialtyDto specialtyDto : specialties ) {for-each +12
70 list.add( toSpecialty( specialtyDto ) );
71 }
72
73 return list;
74 }

SpecialtyMapperImpl.toSpecialty(SpecialtyDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:19

19 public Specialty toSpecialty(SpecialtyDto specialtyDto) {
20 if ( specialtyDto == null ) {if +13
21 return null;
22 }
23
24 Specialty specialty = new Specialty();
25
26 specialty.setId( specialtyDto.getId() );
27 specialty.setName( specialtyDto.getName() );
28 specialty.setDescription( specialtyDto.getDescription() );
29
30 return specialty;
31 }

VetRestController.updateSpecialties(Vet)+1

src/main/java/victor/training/petclinic/rest/VetRestController.java:76

76 private void updateSpecialties(Vet currentVet) {
77 if (currentVet.getNrOfSpecialties() > 0) {if +14
78 Set<String> names = currentVet.getSpecialties().stream().map(Specialty::getName)
79 .collect(Collectors.toSet());
80 List<Specialty> vetSpecialities = specialtyRepository.findSpecialtiesByNameIn(names);
81 currentVet.setSpecialties(vetSpecialities);
82 }
83 vetRepository.save(currentVet);
84 }

VetRestController.updateVet(int, VetDto)+1

src/main/java/victor/training/petclinic/rest/VetRestController.java:65

65 public void updateVet(@PathVariable int vetId, @RequestBody VetDto vetDto) {
66 Vet currentVet = vetRepository.findById(vetId).orElseThrow();
67 currentVet.setFirstName(vetDto.getFirstName());
68 currentVet.setLastName(vetDto.getLastName());
69 currentVet.clearSpecialties();
70 for (Specialty spec : specialtyMapper.toSpecialty(vetDto.getSpecialties())) {for-each +15
71 currentVet.addSpecialty(spec);
72 }
73 updateSpecialties(currentVet);
74 }

Total for VetRestController.updateVet(int, VetDto) = 5

GET /api/vets/{vetId} 3 methods cost something, out of 21 in the flow 4

SpecialtyMapperImpl.toSpecialtyDtos(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:49

49 public List<SpecialtyDto> toSpecialtyDtos(List<Specialty> specialties) {
50 if ( specialties == null ) {if +11
51 return null;
52 }
53
54 List<SpecialtyDto> list = new ArrayList<SpecialtyDto>( specialties.size() );
55 for ( Specialty specialty : specialties ) {for-each +12
56 list.add( toSpecialtyDto( specialty ) );
57 }
58
59 return list;
60 }

SpecialtyMapperImpl.toSpecialtyDto(Specialty) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:34

34 public SpecialtyDto toSpecialtyDto(Specialty specialty) {
35 if ( specialty == null ) {if +13
36 return null;
37 }
38
39 SpecialtyDto specialtyDto = new SpecialtyDto();
40
41 specialtyDto.setId( specialty.getId() );
42 specialtyDto.setName( specialty.getName() );
43 specialtyDto.setDescription( specialty.getDescription() );
44
45 return specialtyDto;
46 }

VetMapperImpl.toVetDto(Vet) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VetMapperImpl.java:55

55 public VetDto toVetDto(Vet vet) {
56 if ( vet == null ) {if +14
57 return null;
58 }
59
60 VetDto vetDto = new VetDto();
61
62 vetDto.setFirstName( vet.getFirstName() );
63 vetDto.setLastName( vet.getLastName() );
64 vetDto.setSpecialties( specialtyMapper.toSpecialtyDtos( vet.getSpecialties() ) );
65 vetDto.setId( vet.getId() );
66
67 return vetDto;
68 }

Total for VetRestController.getVet(int) = 4

POST /api/visits 4 methods cost something, out of 22 in the flow 4

VetRepository.getByIdOrNull(Integer)+1

src/main/java/victor/training/petclinic/repository/VetRepository.java:29

29 default Vet getByIdOrNull(@Nullable Integer vetId) {
30 if (vetId == null) {if +11
31 return null;
32 }
33 return findByIdWithoutSpecialties(vetId).orElseThrow();
34 }

VisitMapperImpl.toVisit(VisitDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:23

23 public Visit toVisit(VisitDto visitDto) {
24 if ( visitDto == null ) {if +12
25 return null;
26 }
27
28 Visit visit = new Visit();
29
30 visit.setPet( visitDtoToPet( visitDto ) );
31 visit.setId( visitDto.getId() );
32 visit.setDate( visitDto.getDate() );
33 visit.setDescription( visitDto.getDescription() );
34
35 return visit;
36 }

VisitMapperImpl.visitDtoToPet(VisitDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:89

89 protected Pet visitDtoToPet(VisitDto visitDto) {
90 if ( visitDto == null ) {if +13
91 return null;
92 }
93
94 Pet pet = new Pet();
95
96 pet.setId( visitDto.getPetId() );
97
98 return pet;
99 }

VisitRestController.resolveVet(Integer)+1

src/main/java/victor/training/petclinic/rest/VisitRestController.java:89

89 private Vet resolveVet(Integer vetId) {
90 try {
91 return vetRepository.getByIdOrNull(vetId);
92 } catch (NoSuchElementException e) {catch +14
93 log.warn("Rejecting visit: attending vet id {} does not exist", vetId);
94 throw e;
95 }
96 }

Total for VisitRestController.addVisit(VisitDto) = 4

POST /api/owners/{ownerId}/pets/{petId}/visits 3 methods cost something, out of 17 in the flow 3

OwnerRestController.resolveVet(Integer)+1

src/main/java/victor/training/petclinic/rest/OwnerRestController.java:168

168 private Vet resolveVet(Integer vetId) {
169 try {
170 return vetRepository.getByIdOrNull(vetId);
171 } catch (NoSuchElementException e) {catch +11
172 log.warn("Rejecting visit: attending vet id {} does not exist", vetId);
173 throw e;
174 }
175 }

VetRepository.getByIdOrNull(Integer)+1

src/main/java/victor/training/petclinic/repository/VetRepository.java:29

29 default Vet getByIdOrNull(@Nullable Integer vetId) {
30 if (vetId == null) {if +12
31 return null;
32 }
33 return findByIdWithoutSpecialties(vetId).orElseThrow();
34 }

VisitMapperImpl.toVisit(VisitFieldsDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/VisitMapperImpl.java:39

39 public Visit toVisit(VisitFieldsDto visitFieldsDto) {
40 if ( visitFieldsDto == null ) {if +13
41 return null;
42 }
43
44 Visit visit = new Visit();
45
46 visit.setDate( visitFieldsDto.getDate() );
47 visit.setDescription( visitFieldsDto.getDescription() );
48
49 return visit;
50 }

Total for OwnerRestController.addVisitToOwner(int, int, VisitFieldsDto) = 3

GET /api/pettypes 2 methods cost something, out of 9 in the flow 3

PetTypeMapperImpl.toPetTypeDtos(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/PetTypeMapperImpl.java:60

60 public List<PetTypeDto> toPetTypeDtos(List<PetType> petTypes) {
61 if ( petTypes == null ) {if +11
62 return null;
63 }
64
65 List<PetTypeDto> list = new ArrayList<PetTypeDto>( petTypes.size() );
66 for ( PetType petType : petTypes ) {for-each +12
67 list.add( toPetTypeDto( petType ) );
68 }
69
70 return list;
71 }

PetTypeMapperImpl.toPetTypeDto(PetType) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetTypeMapperImpl.java:33

33 public PetTypeDto toPetTypeDto(PetType petType) {
34 if ( petType == null ) {if +13
35 return null;
36 }
37
38 PetTypeDto petTypeDto = new PetTypeDto();
39
40 petTypeDto.setName( petType.getName() );
41 petTypeDto.setId( petType.getId() );
42
43 return petTypeDto;
44 }

Total for PetTypeRestController.listPetTypes() = 3

GET /api/specialties 2 methods cost something, out of 11 in the flow 3

SpecialtyMapperImpl.toSpecialtyDtos(List) generated+2

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:49

49 public List<SpecialtyDto> toSpecialtyDtos(List<Specialty> specialties) {
50 if ( specialties == null ) {if +11
51 return null;
52 }
53
54 List<SpecialtyDto> list = new ArrayList<SpecialtyDto>( specialties.size() );
55 for ( Specialty specialty : specialties ) {for-each +12
56 list.add( toSpecialtyDto( specialty ) );
57 }
58
59 return list;
60 }

SpecialtyMapperImpl.toSpecialtyDto(Specialty) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:34

34 public SpecialtyDto toSpecialtyDto(Specialty specialty) {
35 if ( specialty == null ) {if +13
36 return null;
37 }
38
39 SpecialtyDto specialtyDto = new SpecialtyDto();
40
41 specialtyDto.setId( specialty.getId() );
42 specialtyDto.setName( specialty.getName() );
43 specialtyDto.setDescription( specialty.getDescription() );
44
45 return specialtyDto;
46 }

Total for SpecialtyRestController.listSpecialties() = 3

POST /api/owners/{ownerId}/pets 2 methods cost something, out of 23 in the flow 2

PetMapperImpl.toPet(PetFieldsDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:95

95 public Pet toPet(PetFieldsDto petFieldsDto) {
96 if ( petFieldsDto == null ) {if +11
97 return null;
98 }
99
100 Pet pet = new Pet();
101
102 pet.setName( petFieldsDto.getName() );
103 pet.setBirthDate( petFieldsDto.getBirthDate() );
104 pet.setType( toPetType( petFieldsDto.getType() ) );
105
106 return pet;
107 }

PetMapperImpl.toPetType(PetTypeDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:124

124 public PetType toPetType(PetTypeDto petTypeDto) {
125 if ( petTypeDto == null ) {if +12
126 return null;
127 }
128
129 PetType petType = new PetType();
130
131 petType.setId( petTypeDto.getId() );
132 petType.setName( petTypeDto.getName() );
133
134 return petType;
135 }

Total for OwnerRestController.addPetToOwner(int, PetFieldsDto) = 2

PUT /api/visits/{visitId} 2 methods cost something, out of 12 in the flow 2

VetRepository.getByIdOrNull(Integer)+1

src/main/java/victor/training/petclinic/repository/VetRepository.java:29

29 default Vet getByIdOrNull(@Nullable Integer vetId) {
30 if (vetId == null) {if +11
31 return null;
32 }
33 return findByIdWithoutSpecialties(vetId).orElseThrow();
34 }

VisitRestController.resolveVet(Integer)+1

src/main/java/victor/training/petclinic/rest/VisitRestController.java:89

89 private Vet resolveVet(Integer vetId) {
90 try {
91 return vetRepository.getByIdOrNull(vetId);
92 } catch (NoSuchElementException e) {catch +12
93 log.warn("Rejecting visit: attending vet id {} does not exist", vetId);
94 throw e;
95 }
96 }

Total for VisitRestController.updateVisit(int, VisitFieldsDto) = 2

POST /api/owners 1 method costs something, out of 15 in the flow 1

OwnerMapperImpl.toOwner(OwnerFieldsDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/OwnerMapperImpl.java:43

43 public Owner toOwner(OwnerFieldsDto ownerDto) {
44 if ( ownerDto == null ) {if +11
45 return null;
46 }
47
48 Owner owner = new Owner();
49
50 owner.setFirstName( ownerDto.getFirstName() );
51 owner.setLastName( ownerDto.getLastName() );
52 owner.setAddress( ownerDto.getAddress() );
53 owner.setCity( ownerDto.getCity() );
54 owner.setTelephone( ownerDto.getTelephone() );
55
56 return owner;
57 }

Total for OwnerRestController.addOwner(OwnerFieldsDto) = 1

PUT /api/pets/{petId} 1 method costs something, out of 14 in the flow 1

PetMapperImpl.toPetType(PetTypeDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetMapperImpl.java:124

124 public PetType toPetType(PetTypeDto petTypeDto) {
125 if ( petTypeDto == null ) {if +11
126 return null;
127 }
128
129 PetType petType = new PetType();
130
131 petType.setId( petTypeDto.getId() );
132 petType.setName( petTypeDto.getName() );
133
134 return petType;
135 }

Total for PetRestController.updatePet(int, PetDto) = 1

POST /api/pettypes 1 method costs something, out of 7 in the flow 1

PetTypeMapperImpl.toPetType(PetTypeFieldsDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetTypeMapperImpl.java:20

20 public PetType toPetType(PetTypeFieldsDto petTypeFieldsDto) {
21 if ( petTypeFieldsDto == null ) {if +11
22 return null;
23 }
24
25 PetType petType = new PetType();
26
27 petType.setName( petTypeFieldsDto.getName() );
28
29 return petType;
30 }

Total for PetTypeRestController.addPetType(PetTypeFieldsDto) = 1

GET /api/pettypes/{petTypeId} 1 method costs something, out of 8 in the flow 1

PetTypeMapperImpl.toPetTypeDto(PetType) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/PetTypeMapperImpl.java:33

33 public PetTypeDto toPetTypeDto(PetType petType) {
34 if ( petType == null ) {if +11
35 return null;
36 }
37
38 PetTypeDto petTypeDto = new PetTypeDto();
39
40 petTypeDto.setName( petType.getName() );
41 petTypeDto.setId( petType.getId() );
42
43 return petTypeDto;
44 }

Total for PetTypeRestController.getPetType(int) = 1

DELETE /api/pettypes/{petTypeId} 1 method costs something, out of 3 in the flow 1

PetTypeRestController.deletePetType(int)+1

src/main/java/victor/training/petclinic/rest/PetTypeRestController.java:70

70 public ResponseEntity<Void> deletePetType(@PathVariable int petTypeId) {
71 try {
72 PetType petType = petTypeRepository.findById(petTypeId).orElseThrow();
73 petTypeRepository.delete(petType);
74 return ResponseEntity.noContent().build();
75 } catch (DataIntegrityViolationException ex) {catch +11
76 throw new RuntimeException("PetType is in use by existing pets and cannot be deleted", ex);
77 }
78 }

Total for PetTypeRestController.deletePetType(int) = 1

POST /api/specialties 1 method costs something, out of 12 in the flow 1

SpecialtyMapperImpl.toSpecialty(SpecialtyDto) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:19

19 public Specialty toSpecialty(SpecialtyDto specialtyDto) {
20 if ( specialtyDto == null ) {if +11
21 return null;
22 }
23
24 Specialty specialty = new Specialty();
25
26 specialty.setId( specialtyDto.getId() );
27 specialty.setName( specialtyDto.getName() );
28 specialty.setDescription( specialtyDto.getDescription() );
29
30 return specialty;
31 }

Total for SpecialtyRestController.addSpecialty(SpecialtyDto) = 1

GET /api/specialties/feed 1 method costs something, out of 9 in the flow 1

SpecialtyFeedController.feed(String)+1

src/main/java/victor/training/petclinic/rest/SpecialtyFeedController.java:27

27 public ResponseEntity<List<SpecialtyFeed.Item>> feed(
28 @RequestHeader(value = HttpHeaders.IF_NONE_MATCH, required = false) String ifNoneMatch) {
29 List<SpecialtyFeed.Item> items = specialtyFeed.load();
30 String etag = specialtyFeed.etag(items);
31 if (etag.equals(ifNoneMatch)) {if +11
32 return ResponseEntity.status(304).eTag(etag).build();
33 }
34 return ResponseEntity.ok().eTag(etag).body(items);
35 }

Total for SpecialtyFeedController.feed(String) = 1

GET /api/specialties/{specialtyId} 1 method costs something, out of 10 in the flow 1

SpecialtyMapperImpl.toSpecialtyDto(Specialty) generated+1

target/generated-sources/annotations/victor/training/petclinic/mapper/SpecialtyMapperImpl.java:34

34 public SpecialtyDto toSpecialtyDto(Specialty specialty) {
35 if ( specialty == null ) {if +11
36 return null;
37 }
38
39 SpecialtyDto specialtyDto = new SpecialtyDto();
40
41 specialtyDto.setId( specialty.getId() );
42 specialtyDto.setName( specialty.getName() );
43 specialtyDto.setDescription( specialty.getDescription() );
44
45 return specialtyDto;
46 }

Total for SpecialtyRestController.getSpecialty(int) = 1

MCP tools

MCP call_vet_ambulance 1 method costs something, out of 3 in the flow 6

PetClinicMcp.callVetAmbulance(McpSyncRequestContext)+6

src/main/java/victor/training/petclinic/mcp/PetClinicMcp.java:210

210 public String callVetAmbulance(McpSyncRequestContext context) {
211 if (context == null || !context.elicitEnabled()) {if +1|| +12
212 throw new IllegalStateException(
213 "call_vet_ambulance requires an MCP client that supports elicitation (owner must confirm).");
214 }
215 // CONFIRMATION-style elicitation: phrase it so ACCEPT reads as "Request" (dispatch),
216 // not "Cancel". Same server-side context.elicit(...) API used elsewhere; the structured
217 // payload carries the required address the vet ambulance should drive to.
218 String prompt = "Request a vet ambulance to drive to your address? "
219 + "Enter the address to dispatch to, then confirm to Request the ambulance.";
220 StructuredElicitResult<AmbulanceAddressInput> elicit = context.elicit(e -> e.message(prompt),
221 AmbulanceAddressInput.class);
222 if (elicit.action() != ElicitResult.Action.ACCEPT) {if +13
223 return "Vet ambulance was not requested.";
224 }
225 AmbulanceAddressInput input = elicit.structuredContent();
226 String address = input == null ? null : input.address();ternary +14
227 if (address == null || address.isBlank()) {if +1|| +16
228 throw new IllegalArgumentException("An address is required to dispatch the vet ambulance.");
229 }
230 return "Vet ambulance dispatched to " + address.trim();
231 }

Total for PetClinicMcp.callVetAmbulance(McpSyncRequestContext) = 6

MCP create_visit 3 methods cost something, out of 20 in the flow 6

PetClinicMcp.createVisit(int, LocalDate, LocalTime, String)+3

src/main/java/victor/training/petclinic/mcp/PetClinicMcp.java:121

121 public String createVisit(
122 @McpToolParam(description = "Pet ID (must belong to the authenticated owner)", required = true) int petId,
123 @McpToolParam(description = "Visit date (yyyy-MM-dd); must be today or in the future",
124 required = true) LocalDate visitDate,
125 @McpToolParam(description = "Exact local time of the appointment (HH:mm), e.g. 08:00",
126 required = true) LocalTime visitTime,
127 @McpToolParam(description = "Visit description (reason, diagnosis, notes...)",
128 required = true) String description) {
129 int ownerId = McpSecurity.currentOwnerId();
130 Pet pet = petRepository.findById(petId)
131 .orElseThrow(() -> new IllegalArgumentException("Pet not found: " + petId));
132 if (pet.getOwner() == null || pet.getOwner().getId() != ownerId) {if +1|| +12
133 throw new IllegalArgumentException("Pet " + petId + " does not belong to owner " + ownerId);
134 }
135 requireFutureDate(visitDate);
136 if (LocalDateTime.of(visitDate, visitTime).isBefore(LocalDateTime.now())) {if +13
137 throw new IllegalArgumentException("Visit time must be in the future: " + visitDate + " " + visitTime);
138 }
139 requireUnderUpcomingVisitCap(pet);
140
141 Visit v = new Visit();
142 v.setDate(visitDate);
143 v.setTime(visitTime);
144 v.setDescription(description);
145 pet.addVisit(v); // maintain both sides of the Pet<->Visit association
146 Visit saved = visitRepository.save(v);
147 return "Created visit id=" + saved.getId() + " for pet '" + pet.getName() + "' on " + visitDate
148 + " at " + visitTime;
149 }

PetClinicMcp.requireUnderUpcomingVisitCap(Pet)+2

src/main/java/victor/training/petclinic/mcp/PetClinicMcp.java:187

187 private void requireUnderUpcomingVisitCap(Pet pet) {
188 LocalDate today = LocalDate.now();
189 long upcoming = pet.getVisits().stream()
190 .filter(v -> v.getDate() != null && !v.getDate().isBefore(today))&& +14
191 .count();
192 if (upcoming >= MAX_UPCOMING_VISITS_PER_PET) {if +15
193 throw new IllegalArgumentException(
194 "Pet '" + pet.getName() + "' already has the maximum of " + MAX_UPCOMING_VISITS_PER_PET
195 + " upcoming visits. Please cancel an existing visit before booking another.");
196 }
197 }

PetClinicMcp.requireFutureDate(LocalDate)+1

src/main/java/victor/training/petclinic/mcp/PetClinicMcp.java:199

199 private static void requireFutureDate(LocalDate d) {
200 if (d.isBefore(LocalDate.now())) {if +16
201 throw new IllegalArgumentException("Visit date must be today or in the future: " + d);
202 }
203 }

Total for PetClinicMcp.createVisit(int, LocalDate, LocalTime, String) = 6

MCP list_visits 2 methods cost something, out of 17 in the flow 4

PetClinicMcp.listVisits()+3

src/main/java/victor/training/petclinic/mcp/PetClinicMcp.java:100

100 public List<VisitView> listVisits() {
101 int ownerId = McpSecurity.currentOwnerId();
102 Owner owner = ownerRepository.findByIdFetchingPets(ownerId)
103 .orElseThrow(() -> new IllegalArgumentException("Owner not found: " + ownerId));
104 List<VisitView> result = new ArrayList<>();
105 for (Pet pet : owner.getPets()) {for-each +11
106 // Navigate the mapped Pet→Visit association (lazy; safe under @Transactional) instead of a per-pet repo query.
107 for (Visit v : pet.getVisitsSortedByDate()) {for-each +2 · nesting 13
108 result.add(new VisitView(v.getId(), pet.getId(), pet.getName(), v.getDate(), v.getTime(),
109 v.getDescription(), formatVet(v.getVet())));
110 }
111 }
112 return result;
113 }

PetClinicMcp.formatVet(Vet)+1

src/main/java/victor/training/petclinic/mcp/PetClinicMcp.java:76

76 private String formatVet(Vet vet) {
77 if (vet == null) {if +14
78 return null;
79 }
80 return vet.getFirstName() + " " + vet.getLastName();
81 }

Total for PetClinicMcp.listVisits() = 4

MCP cancel_visit 2 methods cost something, out of 13 in the flow 2

PetClinicMcp.cancelVisit(LocalDate)+1

src/main/java/victor/training/petclinic/mcp/PetClinicMcp.java:157

157 public String cancelVisit(
158 @McpToolParam(description = "Visit date (yyyy-MM-dd); must be in the future",
159 required = true) LocalDate visitDate) {
160 requireFutureDate(visitDate);
161
162 int ownerId = McpSecurity.currentOwnerId();
163 Owner owner = ownerRepository.findByIdFetchingPets(ownerId)
164 .orElseThrow(() -> new IllegalArgumentException("Owner not found: " + ownerId));
165
166 // Navigate the mapped Pet→Visit association and filter the matching date (lazy; safe under @Transactional).
167 List<Visit> matching = owner.getPets().stream()
168 .flatMap(pet -> pet.getVisits().stream())
169 .filter(v -> v.getDate().equals(visitDate))
170 .toList();
171 // Detach from the managed collection too, otherwise cascade=ALL re-persists the visit on flush.
172 matching.forEach(v -> {
173 v.getPet().getVisits().remove(v);
174 visitRepository.delete(v);
175 });
176
177 if (matching.isEmpty()) {if +11
178 return "No upcoming visits found on " + visitDate;
179 }
180 return "Cancelled " + matching.size() + " visit(s) on " + visitDate;
181 }

PetClinicMcp.requireFutureDate(LocalDate)+1

src/main/java/victor/training/petclinic/mcp/PetClinicMcp.java:199

199 private static void requireFutureDate(LocalDate d) {
200 if (d.isBefore(LocalDate.now())) {if +12
201 throw new IllegalArgumentException("Visit date must be today or in the future: " + d);
202 }
203 }

Total for PetClinicMcp.cancelVisit(LocalDate) = 2

MCP get_owner_profile 1 method costs something, out of 16 in the flow 1

PetClinicMcp.formatPet(Pet)+1

src/main/java/victor/training/petclinic/mcp/PetClinicMcp.java:83

83 private String formatPet(Pet pet) {
84 String type = pet.getType() == null ? "?" : pet.getType().getName();ternary +11
85 return "- id=%d — %s (%s), born %s".formatted(pet.getId(), pet.getName(), type, pet.getBirthDate());
86 }

Total for PetClinicMcp.getOwnerProfile() = 1

Nothing to explain

11 entry points score 0: every method in their flow reads top to bottom.