CommonsController.java

1
package edu.ucsb.cs156.happiercows.controllers;
2
3
import com.fasterxml.jackson.core.JsonProcessingException;
4
import com.fasterxml.jackson.databind.ObjectMapper;
5
import edu.ucsb.cs156.happiercows.entities.Commons;
6
import edu.ucsb.cs156.happiercows.entities.CommonsPlus;
7
import edu.ucsb.cs156.happiercows.entities.User;
8
import edu.ucsb.cs156.happiercows.entities.UserCommons;
9
import edu.ucsb.cs156.happiercows.errors.EntityNotFoundException;
10
import edu.ucsb.cs156.happiercows.models.CreateCommonsParams;
11
import edu.ucsb.cs156.happiercows.models.HealthUpdateStrategyList;
12
import edu.ucsb.cs156.happiercows.repositories.CommonsRepository;
13
import edu.ucsb.cs156.happiercows.repositories.UserCommonsRepository;
14
import edu.ucsb.cs156.happiercows.strategies.CowHealthUpdateStrategies;
15
import io.swagger.v3.oas.annotations.tags.Tag;
16
import io.swagger.v3.oas.annotations.Operation;
17
import io.swagger.v3.oas.annotations.Parameter;
18
import lombok.extern.slf4j.Slf4j;
19
import org.springframework.beans.factory.annotation.Autowired;
20
import org.springframework.http.HttpStatus;
21
import org.springframework.http.ResponseEntity;
22
import org.springframework.security.access.prepost.PreAuthorize;
23
import org.springframework.web.bind.annotation.*;
24
25
import java.util.ArrayList;
26
import java.util.List;
27
import java.util.Optional;
28
import java.util.stream.Collectors;
29
30
@Slf4j
31
@Tag(name = "Commons")
32
@RequestMapping("/api/commons")
33
@RestController
34
public class CommonsController extends ApiController {
35
    @Autowired
36
    private CommonsRepository commonsRepository;
37
38
    @Autowired
39
    private UserCommonsRepository userCommonsRepository;
40
41
    @Autowired
42
    ObjectMapper mapper;
43
44
    @Operation(summary = "Get a list of all commons")
45
    @GetMapping("/all")
46
    public ResponseEntity<String> getCommons() throws JsonProcessingException {
47
        log.info("getCommons()...");
48
        Iterable<Commons> commons = commonsRepository.findAll();
49
        String body = mapper.writeValueAsString(commons);
50 1 1. getCommons : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommons → KILLED
        return ResponseEntity.ok().body(body);
51
    }
52
53
    @Operation(summary = "Get a list of all commons and number of cows/users")
54
    @GetMapping("/allplus")
55
    public ResponseEntity<String> getCommonsPlus() throws JsonProcessingException {
56
        log.info("getCommonsPlus()...");
57
        Iterable<Commons> commonsListIter = commonsRepository.findAll();
58
59
        // convert Iterable to List for the purposes of using a Java Stream & lambda
60
        // below
61
        List<Commons> commonsList = new ArrayList<Commons>();
62 1 1. getCommonsPlus : removed call to java/lang/Iterable::forEach → KILLED
        commonsListIter.forEach(commonsList::add);
63
64
        List<CommonsPlus> commonsPlusList1 = commonsList.stream()
65 1 1. lambda$getCommonsPlus$0 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$getCommonsPlus$0 → KILLED
                .map(c -> toCommonsPlus(c))
66
                .collect(Collectors.toList());
67
68
        ArrayList<CommonsPlus> commonsPlusList = new ArrayList<CommonsPlus>(commonsPlusList1);
69
70
        String body = mapper.writeValueAsString(commonsPlusList);
71 1 1. getCommonsPlus : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommonsPlus → KILLED
        return ResponseEntity.ok().body(body);
72
    }
73
74
    @Operation(summary = "Get the number of cows/users in a commons")
75
    @PreAuthorize("hasRole('ROLE_USER')")
76
    @GetMapping("/plus")
77
    public CommonsPlus getCommonsPlusById(
78
            @Parameter(name="id") @RequestParam long id) throws JsonProcessingException {
79
                CommonsPlus commonsPlus = toCommonsPlus(commonsRepository.findById(id)
80 1 1. lambda$getCommonsPlusById$1 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$getCommonsPlusById$1 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(Commons.class, id)));
81
82 1 1. getCommonsPlusById : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommonsPlusById → KILLED
        return commonsPlus;
83
    }
84
85
    @Operation(summary = "Update a commons")
86
    @PreAuthorize("hasRole('ROLE_ADMIN')")
87
    @PutMapping("/update")
88
    public ResponseEntity<String> updateCommons(
89
            @Parameter(name="commons identifier") @RequestParam long id,
90
            @Parameter(name="request body") @RequestBody CreateCommonsParams params
91
    ) {
92
        Optional<Commons> existing = commonsRepository.findById(id);
93
94
        Commons updated;
95
        HttpStatus status;
96
97 1 1. updateCommons : negated conditional → KILLED
        if (existing.isPresent()) {
98
            updated = existing.get();
99
            status = HttpStatus.NO_CONTENT;
100
        } else {
101
            updated = new Commons();
102
            status = HttpStatus.CREATED;
103
        }
104
105 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setName → KILLED
        updated.setName(params.getName());
106 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setCowPrice → KILLED
        updated.setCowPrice(params.getCowPrice());
107 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setMilkPrice → KILLED
        updated.setMilkPrice(params.getMilkPrice());
108 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setStartingBalance → KILLED
        updated.setStartingBalance(params.getStartingBalance());
109 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setStartingDate → KILLED
        updated.setStartingDate(params.getStartingDate());
110 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setShowLeaderboard → KILLED
        updated.setShowLeaderboard(params.getShowLeaderboard());
111 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setDegradationRate → KILLED
        updated.setDegradationRate(params.getDegradationRate());
112 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setCarryingCapacity → KILLED
        updated.setCarryingCapacity(params.getCarryingCapacity());
113 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setCapacityPerUser → KILLED
        updated.setCapacityPerUser(params.getCapacityPerUser());
114 1 1. updateCommons : negated conditional → KILLED
        if (params.getAboveCapacityHealthUpdateStrategy() != null) {
115 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setAboveCapacityHealthUpdateStrategy → KILLED
            updated.setAboveCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(params.getAboveCapacityHealthUpdateStrategy()));
116
        }
117 1 1. updateCommons : negated conditional → KILLED
        if (params.getBelowCapacityHealthUpdateStrategy() != null) {
118 1 1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setBelowCapacityHealthUpdateStrategy → KILLED
            updated.setBelowCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(params.getBelowCapacityHealthUpdateStrategy()));
119
        }
120
121 2 1. updateCommons : changed conditional boundary → KILLED
2. updateCommons : negated conditional → KILLED
        if (params.getDegradationRate() < 0) {
122
            throw new IllegalArgumentException("Degradation Rate cannot be negative");
123
        }
124
125
        commonsRepository.save(updated);
126
127 1 1. updateCommons : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::updateCommons → KILLED
        return ResponseEntity.status(status).build();
128
    }
129
130
    @Operation(summary = "Get a specific commons")
131
    @PreAuthorize("hasRole('ROLE_USER')")
132
    @GetMapping("")
133
    public Commons getCommonsById(
134
            @Parameter(name="id") @RequestParam Long id) throws JsonProcessingException {
135
136
        Commons commons = commonsRepository.findById(id)
137 1 1. lambda$getCommonsById$2 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$getCommonsById$2 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(Commons.class, id));
138
139 1 1. getCommonsById : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommonsById → KILLED
        return commons;
140
    }
141
142
    @Operation(summary = "Create a new commons")
143
    @PreAuthorize("hasRole('ROLE_ADMIN')")
144
    @PostMapping(value = "/new", produces = "application/json")
145
    public ResponseEntity<String> createCommons(
146
            @Parameter(name="request body") @RequestBody CreateCommonsParams params
147
    ) throws JsonProcessingException {
148
149
        var builder = Commons.builder()
150
                .name(params.getName())
151
                .cowPrice(params.getCowPrice())
152
                .milkPrice(params.getMilkPrice())
153
                .startingBalance(params.getStartingBalance())
154
                .startingDate(params.getStartingDate())
155
                .degradationRate(params.getDegradationRate())
156
                .showLeaderboard(params.getShowLeaderboard())
157
                .carryingCapacity(params.getCarryingCapacity())
158
                .capacityPerUser(params.getCapacityPerUser());
159
160
        // ok to set null values for these, so old backend still works
161 1 1. createCommons : negated conditional → KILLED
        if (params.getAboveCapacityHealthUpdateStrategy() != null) {
162
            builder.aboveCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(params.getAboveCapacityHealthUpdateStrategy()));
163
        }
164 1 1. createCommons : negated conditional → KILLED
        if (params.getBelowCapacityHealthUpdateStrategy() != null) {
165
            builder.belowCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(params.getBelowCapacityHealthUpdateStrategy()));
166
        }
167
168
        Commons commons = builder.build();
169
170
171
        // throw exception for degradation rate
172 2 1. createCommons : changed conditional boundary → KILLED
2. createCommons : negated conditional → KILLED
        if (params.getDegradationRate() < 0) {
173
            throw new IllegalArgumentException("Degradation Rate cannot be negative");
174
        }
175
176
        Commons saved = commonsRepository.save(commons);
177
        String body = mapper.writeValueAsString(saved);
178
179 1 1. createCommons : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::createCommons → KILLED
        return ResponseEntity.ok().body(body);
180
    }
181
182
183
    @Operation(summary = "List all cow health update strategies")
184
    @PreAuthorize("hasRole('ROLE_USER')")
185
    @GetMapping("/all-health-update-strategies")
186
    public ResponseEntity<String> listCowHealthUpdateStrategies() throws JsonProcessingException {
187
        var result = HealthUpdateStrategyList.create();
188
        String body = mapper.writeValueAsString(result);
189 1 1. listCowHealthUpdateStrategies : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::listCowHealthUpdateStrategies → KILLED
        return ResponseEntity.ok().body(body);
190
    }
191
192
    @Operation(summary = "Join a commons")
193
    @PreAuthorize("hasRole('ROLE_USER')")
194
    @PostMapping(value = "/join", produces = "application/json")
195
    public ResponseEntity<String> joinCommon(
196
            @Parameter(name="commonsId") @RequestParam Long commonsId) throws Exception {
197
198
        User u = getCurrentUser().getUser();
199
        Long userId = u.getId();
200
        String username = u.getFullName();
201
202
        Commons joinedCommons = commonsRepository.findById(commonsId)
203 1 1. lambda$joinCommon$3 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$joinCommon$3 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(Commons.class, commonsId));
204
        Optional<UserCommons> userCommonsLookup = userCommonsRepository.findByCommonsIdAndUserId(commonsId, userId);
205
206 1 1. joinCommon : negated conditional → KILLED
        if (userCommonsLookup.isPresent()) {
207
            // user is already a member of this commons
208
            String body = mapper.writeValueAsString(joinedCommons);
209 1 1. joinCommon : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::joinCommon → KILLED
            return ResponseEntity.ok().body(body);
210
        }
211
212
        UserCommons uc = UserCommons.builder()
213
                .user(u)
214
                .commons(joinedCommons)
215
                .username(username)
216
                .totalWealth(joinedCommons.getStartingBalance())
217
                .numOfCows(0)
218
                .cowHealth(100)
219
                .cowsBought(0)
220
                .cowsSold(0)
221
                .cowDeaths(0)
222
                .build();
223
224
        userCommonsRepository.save(uc);
225
226 2 1. joinCommon : Replaced integer addition with subtraction → KILLED
2. joinCommon : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setNumUsers → KILLED
        joinedCommons.setNumUsers(joinedCommons.getNumUsers() + 1);
227
        commonsRepository.save(joinedCommons);
228
229
        String body = mapper.writeValueAsString(joinedCommons);
230 1 1. joinCommon : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::joinCommon → KILLED
        return ResponseEntity.ok().body(body);
231
    }
232
233
    @Operation(summary = "Delete a Commons")
234
    @PreAuthorize("hasRole('ROLE_ADMIN')")
235
    @DeleteMapping("")
236
    public Object deleteCommons(
237
            @Parameter(name="id") @RequestParam Long id) {
238
239
        commonsRepository.findById(id)
240 1 1. lambda$deleteCommons$4 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$deleteCommons$4 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(Commons.class, id));
241
242 1 1. deleteCommons : removed call to edu/ucsb/cs156/happiercows/repositories/CommonsRepository::deleteById → KILLED
        commonsRepository.deleteById(id);
243
244
        String responseString = String.format("commons with id %d deleted", id);
245 1 1. deleteCommons : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::deleteCommons → KILLED
        return genericMessage(responseString);
246
247
    }
248
249
    @Operation(summary="Delete a user from a commons")
250
    @PreAuthorize("hasRole('ROLE_ADMIN')")
251
    @DeleteMapping("/{commonsId}/users/{userId}")
252
    public Object deleteUserFromCommon(@PathVariable("commonsId") Long commonsId,
253
                                       @PathVariable("userId") Long userId) throws Exception {
254
255
        UserCommons userCommons = userCommonsRepository.findByCommonsIdAndUserId(commonsId, userId)
256 1 1. lambda$deleteUserFromCommon$5 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$deleteUserFromCommon$5 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(
257
                        UserCommons.class, "commonsId", commonsId, "userId", userId)
258
                );
259
260 1 1. deleteUserFromCommon : removed call to edu/ucsb/cs156/happiercows/repositories/UserCommonsRepository::delete → KILLED
        userCommonsRepository.delete(userCommons);
261
262
        String responseString = String.format("user with id %d deleted from commons with id %d, %d users remain", userId, commonsId, commonsRepository.getNumUsers(commonsId).orElse(0));
263
264
        Commons exitedCommon = commonsRepository.findById(commonsId).orElse(null);
265
266 2 1. deleteUserFromCommon : Replaced integer subtraction with addition → KILLED
2. deleteUserFromCommon : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setNumUsers → KILLED
        exitedCommon.setNumUsers(exitedCommon.getNumUsers() - 1);
267
        commonsRepository.save(exitedCommon);
268
        
269 1 1. deleteUserFromCommon : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::deleteUserFromCommon → KILLED
        return genericMessage(responseString);
270
    }
271
272
    public CommonsPlus toCommonsPlus(Commons c) {
273
        Optional<Integer> numCows = commonsRepository.getNumCows(c.getId());
274
        Optional<Integer> numUsers = commonsRepository.getNumUsers(c.getId());
275
276 1 1. toCommonsPlus : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::toCommonsPlus → KILLED
        return CommonsPlus.builder()
277
                .commons(c)
278
                .totalCows(numCows.orElse(0))
279
                .totalUsers(numUsers.orElse(0))
280
                .build();
281
    }
282
}

Mutations

50

1.1
Location : getCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getCommonsTest()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommons → KILLED

62

1.1
Location : getCommonsPlus
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getCommonsPlusTest()]
removed call to java/lang/Iterable::forEach → KILLED

65

1.1
Location : lambda$getCommonsPlus$0
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getCommonsPlusTest()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$getCommonsPlus$0 → KILLED

71

1.1
Location : getCommonsPlus
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getCommonsPlusTest()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommonsPlus → KILLED

80

1.1
Location : lambda$getCommonsPlusById$1
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getCommonsPlusByIdTest_invalid()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$getCommonsPlusById$1 → KILLED

82

1.1
Location : getCommonsPlusById
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getCommonsPlusByIdTest_valid()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommonsPlusById → KILLED

97

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withNoCowHealthUpdateStrategy()]
negated conditional → KILLED

105

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withIllegalDegradationRate()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setName → KILLED

106

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withIllegalDegradationRate()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setCowPrice → KILLED

107

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withIllegalDegradationRate()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setMilkPrice → KILLED

108

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withIllegalDegradationRate()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setStartingBalance → KILLED

109

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withIllegalDegradationRate()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setStartingDate → KILLED

110

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setShowLeaderboard → KILLED

111

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withIllegalDegradationRate()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setDegradationRate → KILLED

112

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withIllegalDegradationRate()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setCarryingCapacity → KILLED

113

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withIllegalDegradationRate()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setCapacityPerUser → KILLED

114

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withNoCowHealthUpdateStrategy()]
negated conditional → KILLED

115

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setAboveCapacityHealthUpdateStrategy → KILLED

117

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withNoCowHealthUpdateStrategy()]
negated conditional → KILLED

118

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setBelowCapacityHealthUpdateStrategy → KILLED

121

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withDegradationRate_Zero()]
changed conditional boundary → KILLED

2.2
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withNoCowHealthUpdateStrategy()]
negated conditional → KILLED

127

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:updateCommonsTest_withNoCowHealthUpdateStrategy()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::updateCommons → KILLED

137

1.1
Location : lambda$getCommonsById$2
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getCommonsByIdTest_invalid()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$getCommonsById$2 → KILLED

139

1.1
Location : getCommonsById
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getCommonsByIdTest_valid()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommonsById → KILLED

161

1.1
Location : createCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:createCommonsTest()]
negated conditional → KILLED

164

1.1
Location : createCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:createCommonsTest()]
negated conditional → KILLED

172

1.1
Location : createCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:createCommonsTest_zeroDegradation()]
changed conditional boundary → KILLED

2.2
Location : createCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:createCommonsTest()]
negated conditional → KILLED

179

1.1
Location : createCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:createCommonsTest()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::createCommons → KILLED

189

1.1
Location : listCowHealthUpdateStrategies
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getHealthUpdateStrategiesTest()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::listCowHealthUpdateStrategies → KILLED

203

1.1
Location : lambda$joinCommon$3
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:join_when_commons_with_id_does_not_exist()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$joinCommon$3 → KILLED

206

1.1
Location : joinCommon
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:joinCommonsTest()]
negated conditional → KILLED

209

1.1
Location : joinCommon
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:already_joined_common_test()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::joinCommon → KILLED

226

1.1
Location : joinCommon
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:joinCommonsTest()]
Replaced integer addition with subtraction → KILLED

2.2
Location : joinCommon
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:joinCommonsTest()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setNumUsers → KILLED

230

1.1
Location : joinCommon
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:joinCommonsTest()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::joinCommon → KILLED

240

1.1
Location : lambda$deleteCommons$4
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:deleteCommons_test_admin_nonexists()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$deleteCommons$4 → KILLED

242

1.1
Location : deleteCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:deleteCommons_test_admin_exists()]
removed call to edu/ucsb/cs156/happiercows/repositories/CommonsRepository::deleteById → KILLED

245

1.1
Location : deleteCommons
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:deleteCommons_test_admin_exists()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::deleteCommons → KILLED

256

1.1
Location : lambda$deleteUserFromCommon$5
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:deleteUserFromCommons_when_not_joined()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$deleteUserFromCommon$5 → KILLED

260

1.1
Location : deleteUserFromCommon
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:deleteUserFromCommonsTest()]
removed call to edu/ucsb/cs156/happiercows/repositories/UserCommonsRepository::delete → KILLED

266

1.1
Location : deleteUserFromCommon
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:deleteUserFromCommonsTest()]
Replaced integer subtraction with addition → KILLED

2.2
Location : deleteUserFromCommon
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:deleteUserFromCommonsTest()]
removed call to edu/ucsb/cs156/happiercows/entities/Commons::setNumUsers → KILLED

269

1.1
Location : deleteUserFromCommon
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:deleteUserFromCommonsTest()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::deleteUserFromCommon → KILLED

276

1.1
Location : toCommonsPlus
Killed by : edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.CommonsControllerTests]/[method:getCommonsPlusByIdTest_valid()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::toCommonsPlus → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3