| 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.beans.factory.annotation.Value; | |
| 21 | import org.springframework.http.HttpStatus; | |
| 22 | import org.springframework.http.ResponseEntity; | |
| 23 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 24 | import org.springframework.web.bind.annotation.*; | |
| 25 | import edu.ucsb.cs156.happiercows.services.CommonsPlusBuilderService; | |
| 26 | ||
| 27 | import java.time.LocalDateTime; | |
| 28 | import java.util.Optional; | |
| 29 | ||
| 30 | ||
| 31 | @Slf4j | |
| 32 | @Tag(name = "Commons") | |
| 33 | @RequestMapping("/api/commons") | |
| 34 | @RestController | |
| 35 | public class CommonsController extends ApiController { | |
| 36 | @Autowired | |
| 37 | private CommonsRepository commonsRepository; | |
| 38 | ||
| 39 | @Autowired | |
| 40 | private UserCommonsRepository userCommonsRepository; | |
| 41 | ||
| 42 | @Autowired | |
| 43 | ObjectMapper mapper; | |
| 44 | ||
| 45 | @Autowired | |
| 46 | CommonsPlusBuilderService commonsPlusBuilderService; | |
| 47 | ||
| 48 | @Value("${app.commons.default.startingBalance}") | |
| 49 | private int defaultStartingBalance; | |
| 50 | ||
| 51 | @Value("${app.commons.default.cowPrice}") | |
| 52 | private int defaultCowPrice; | |
| 53 | ||
| 54 | @Value("${app.commons.default.milkPrice}") | |
| 55 | private int defaultMilkPrice; | |
| 56 | ||
| 57 | @Value("${app.commons.default.degradationRate}") | |
| 58 | private double defaultDegradationRate; | |
| 59 | ||
| 60 | @Value("${app.commons.default.carryingCapacity}") | |
| 61 | private int defaultCarryingCapacity; | |
| 62 | ||
| 63 | @Value("${app.commons.default.capacityPerUser}") | |
| 64 | private int defaultCapacityPerUser; | |
| 65 | ||
| 66 | @Value("${app.commons.default.aboveCapacityHealthUpdateStrategy}") | |
| 67 | private String defaultAboveCapacityHealthUpdateStrategy; | |
| 68 | ||
| 69 | @Value("${app.commons.default.belowCapacityHealthUpdateStrategy}") | |
| 70 | private String defaultBelowCapacityHealthUpdateStrategy; | |
| 71 | ||
| 72 | @Operation(summary = "Get a list of all commons") | |
| 73 | @GetMapping("/all") | |
| 74 | public ResponseEntity<String> getCommons() throws JsonProcessingException { | |
| 75 | log.info("getCommons()..."); | |
| 76 | Iterable<Commons> commons = commonsRepository.findAll(); | |
| 77 | String body = mapper.writeValueAsString(commons); | |
| 78 |
1
1. getCommons : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommons → KILLED |
return ResponseEntity.ok().body(body); |
| 79 | } | |
| 80 | ||
| 81 | @Operation(summary = "Get a list of all commons and number of cows/users") | |
| 82 | @GetMapping("/allplus") | |
| 83 | public ResponseEntity<String> getCommonsPlus() throws JsonProcessingException { | |
| 84 | log.info("getCommonsPlus()..."); | |
| 85 | Iterable<Commons> commonsListIter = commonsRepository.findAll(); | |
| 86 | ||
| 87 | // convert Iterable to List for the purposes of using a Java Stream & lambda | |
| 88 | // below | |
| 89 | Iterable<CommonsPlus> commonsPlusList = commonsPlusBuilderService.convertToCommonsPlus(commonsListIter); | |
| 90 | ||
| 91 | String body = mapper.writeValueAsString(commonsPlusList); | |
| 92 |
1
1. getCommonsPlus : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommonsPlus → KILLED |
return ResponseEntity.ok().body(body); |
| 93 | } | |
| 94 | ||
| 95 | @Operation(summary = "Get the number of cows/users in a commons") | |
| 96 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 97 | @GetMapping("/plus") | |
| 98 | public CommonsPlus getCommonsPlusById( | |
| 99 | @Parameter(name="id") @RequestParam long id) throws JsonProcessingException { | |
| 100 | CommonsPlus commonsPlus = commonsPlusBuilderService.toCommonsPlus(commonsRepository.findById(id) | |
| 101 |
1
1. lambda$getCommonsPlusById$0 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$getCommonsPlusById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(Commons.class, id))); |
| 102 | ||
| 103 |
1
1. getCommonsPlusById : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommonsPlusById → KILLED |
return commonsPlus; |
| 104 | } | |
| 105 | | |
| 106 | @Operation(summary = "Get a commons object containing the default values") | |
| 107 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 108 | @GetMapping("/defaults") | |
| 109 | public ResponseEntity<String> getDefaultCommons() throws JsonProcessingException { | |
| 110 | var builder = Commons.builder() | |
| 111 | .name("") | |
| 112 | .cowPrice(defaultCowPrice) | |
| 113 | .milkPrice(defaultMilkPrice) | |
| 114 | .startingBalance(defaultStartingBalance) | |
| 115 | .startingDate(LocalDateTime.now().withNano(0)) | |
| 116 | .degradationRate(defaultDegradationRate) | |
| 117 | .showLeaderboard(false) | |
| 118 | .capacityPerUser(defaultCapacityPerUser) | |
| 119 | .carryingCapacity(defaultCarryingCapacity); | |
| 120 | | |
| 121 | Commons defaultCommons = builder.build(); | |
| 122 | ||
| 123 |
1
1. getDefaultCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setAboveCapacityHealthUpdateStrategy → KILLED |
defaultCommons.setAboveCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(defaultAboveCapacityHealthUpdateStrategy)); |
| 124 |
1
1. getDefaultCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setBelowCapacityHealthUpdateStrategy → KILLED |
defaultCommons.setBelowCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(defaultBelowCapacityHealthUpdateStrategy)); |
| 125 | | |
| 126 | String body = mapper.writeValueAsString(defaultCommons); | |
| 127 |
1
1. getDefaultCommons : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getDefaultCommons → KILLED |
return ResponseEntity.ok().body(body); |
| 128 | } | |
| 129 | ||
| 130 | ||
| 131 | @Operation(summary = "Update a commons") | |
| 132 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 133 | @PutMapping("/update") | |
| 134 | public ResponseEntity<String> updateCommons( | |
| 135 | @Parameter(name="commons identifier") @RequestParam long id, | |
| 136 | @Parameter(name="request body") @RequestBody CreateCommonsParams params | |
| 137 | ) { | |
| 138 | Optional<Commons> existing = commonsRepository.findById(id); | |
| 139 | ||
| 140 | Commons updated; | |
| 141 | HttpStatus status; | |
| 142 | ||
| 143 |
1
1. updateCommons : negated conditional → KILLED |
if (existing.isPresent()) { |
| 144 | updated = existing.get(); | |
| 145 | status = HttpStatus.NO_CONTENT; | |
| 146 | } else { | |
| 147 | updated = new Commons(); | |
| 148 | status = HttpStatus.CREATED; | |
| 149 | } | |
| 150 | ||
| 151 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setName → KILLED |
updated.setName(params.getName()); |
| 152 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setCowPrice → KILLED |
updated.setCowPrice(params.getCowPrice()); |
| 153 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setMilkPrice → KILLED |
updated.setMilkPrice(params.getMilkPrice()); |
| 154 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setStartingBalance → KILLED |
updated.setStartingBalance(params.getStartingBalance()); |
| 155 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setStartingDate → KILLED |
updated.setStartingDate(params.getStartingDate()); |
| 156 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setLastDay → KILLED |
updated.setLastDay(params.getLastDay()); |
| 157 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setShowLeaderboard → KILLED |
updated.setShowLeaderboard(params.getShowLeaderboard()); |
| 158 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setDegradationRate → KILLED |
updated.setDegradationRate(params.getDegradationRate()); |
| 159 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setCapacityPerUser → KILLED |
updated.setCapacityPerUser(params.getCapacityPerUser()); |
| 160 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setCarryingCapacity → KILLED |
updated.setCarryingCapacity(params.getCarryingCapacity()); |
| 161 |
1
1. updateCommons : negated conditional → KILLED |
if (params.getAboveCapacityHealthUpdateStrategy() != null) { |
| 162 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setAboveCapacityHealthUpdateStrategy → KILLED |
updated.setAboveCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(params.getAboveCapacityHealthUpdateStrategy())); |
| 163 | } | |
| 164 |
1
1. updateCommons : negated conditional → KILLED |
if (params.getBelowCapacityHealthUpdateStrategy() != null) { |
| 165 |
1
1. updateCommons : removed call to edu/ucsb/cs156/happiercows/entities/Commons::setBelowCapacityHealthUpdateStrategy → KILLED |
updated.setBelowCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(params.getBelowCapacityHealthUpdateStrategy())); |
| 166 | } | |
| 167 | ||
| 168 |
2
1. updateCommons : changed conditional boundary → KILLED 2. updateCommons : negated conditional → KILLED |
if (params.getDegradationRate() < 0) { |
| 169 | throw new IllegalArgumentException("Degradation Rate cannot be negative"); | |
| 170 | } | |
| 171 | ||
| 172 | // Reference: frontend/src/main/components/Commons/CommonsForm.js | |
| 173 |
1
1. updateCommons : negated conditional → KILLED |
if (params.getName().equals("")) { |
| 174 | throw new IllegalArgumentException("Name cannot be empty"); | |
| 175 | } | |
| 176 | ||
| 177 |
2
1. updateCommons : changed conditional boundary → KILLED 2. updateCommons : negated conditional → KILLED |
if (params.getCowPrice() < 0.01) { |
| 178 | throw new IllegalArgumentException("Cow Price cannot be less than 0.01"); | |
| 179 | } | |
| 180 | ||
| 181 |
2
1. updateCommons : changed conditional boundary → KILLED 2. updateCommons : negated conditional → KILLED |
if (params.getMilkPrice() < 0.01) { |
| 182 | throw new IllegalArgumentException("Milk Price cannot be less than 0.01"); | |
| 183 | } | |
| 184 | ||
| 185 |
2
1. updateCommons : changed conditional boundary → KILLED 2. updateCommons : negated conditional → KILLED |
if (params.getStartingBalance() < 0) { |
| 186 | throw new IllegalArgumentException("Starting Balance cannot be negative"); | |
| 187 | } | |
| 188 | ||
| 189 |
2
1. updateCommons : changed conditional boundary → KILLED 2. updateCommons : negated conditional → KILLED |
if (params.getCarryingCapacity() < 1) { |
| 190 | throw new IllegalArgumentException("Carrying Capacity cannot be less than 1"); | |
| 191 | } | |
| 192 | commonsRepository.save(updated); | |
| 193 | ||
| 194 |
1
1. updateCommons : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::updateCommons → KILLED |
return ResponseEntity.status(status).build(); |
| 195 | } | |
| 196 | ||
| 197 | @Operation(summary = "Get a specific commons") | |
| 198 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 199 | @GetMapping("") | |
| 200 | public Commons getCommonsById( | |
| 201 | @Parameter(name="id") @RequestParam Long id) throws JsonProcessingException { | |
| 202 | ||
| 203 | Commons commons = commonsRepository.findById(id) | |
| 204 |
1
1. lambda$getCommonsById$1 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$getCommonsById$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(Commons.class, id)); |
| 205 | ||
| 206 |
1
1. getCommonsById : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::getCommonsById → KILLED |
return commons; |
| 207 | } | |
| 208 | ||
| 209 | @Operation(summary = "Create a new commons") | |
| 210 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 211 | @PostMapping(value = "/new", produces = "application/json") | |
| 212 | public ResponseEntity<String> createCommons( | |
| 213 | @Parameter(name="request body") @RequestBody CreateCommonsParams params | |
| 214 | ) throws JsonProcessingException { | |
| 215 | ||
| 216 | var builder = Commons.builder() | |
| 217 | .name(params.getName()) | |
| 218 | .cowPrice(params.getCowPrice()) | |
| 219 | .milkPrice(params.getMilkPrice()) | |
| 220 | .startingBalance(params.getStartingBalance()) | |
| 221 | .startingDate(params.getStartingDate()) | |
| 222 | .lastDay(params.getLastDay()) | |
| 223 | .degradationRate(params.getDegradationRate()) | |
| 224 | .showLeaderboard(params.getShowLeaderboard()) | |
| 225 | .capacityPerUser(params.getCapacityPerUser()) | |
| 226 | .carryingCapacity(params.getCarryingCapacity()); | |
| 227 | ||
| 228 | // ok to set null values for these, so old backend still works | |
| 229 |
1
1. createCommons : negated conditional → KILLED |
if (params.getAboveCapacityHealthUpdateStrategy() != null) { |
| 230 | builder.aboveCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(params.getAboveCapacityHealthUpdateStrategy())); | |
| 231 | } | |
| 232 |
1
1. createCommons : negated conditional → KILLED |
if (params.getBelowCapacityHealthUpdateStrategy() != null) { |
| 233 | builder.belowCapacityHealthUpdateStrategy(CowHealthUpdateStrategies.valueOf(params.getBelowCapacityHealthUpdateStrategy())); | |
| 234 | } | |
| 235 | ||
| 236 | Commons commons = builder.build(); | |
| 237 | ||
| 238 | // Reference: frontend/src/main/components/Commons/CommonsForm.js | |
| 239 |
1
1. createCommons : negated conditional → KILLED |
if (params.getName().equals("")) { |
| 240 | throw new IllegalArgumentException("Name cannot be empty"); | |
| 241 | } | |
| 242 | ||
| 243 |
2
1. createCommons : changed conditional boundary → KILLED 2. createCommons : negated conditional → KILLED |
if (params.getCowPrice() < 0.01) { |
| 244 | throw new IllegalArgumentException("Cow Price cannot be less than 0.01"); | |
| 245 | } | |
| 246 | ||
| 247 |
2
1. createCommons : changed conditional boundary → KILLED 2. createCommons : negated conditional → KILLED |
if (params.getMilkPrice() < 0.01) { |
| 248 | throw new IllegalArgumentException("Milk Price cannot be less than 0.01"); | |
| 249 | } | |
| 250 | ||
| 251 |
2
1. createCommons : changed conditional boundary → KILLED 2. createCommons : negated conditional → KILLED |
if (params.getStartingBalance() < 0) { |
| 252 | throw new IllegalArgumentException("Starting Balance cannot be negative"); | |
| 253 | } | |
| 254 | ||
| 255 | // throw exception for degradation rate | |
| 256 |
2
1. createCommons : changed conditional boundary → KILLED 2. createCommons : negated conditional → KILLED |
if (params.getDegradationRate() < 0) { |
| 257 | throw new IllegalArgumentException("Degradation Rate cannot be negative"); | |
| 258 | } | |
| 259 | ||
| 260 |
2
1. createCommons : changed conditional boundary → KILLED 2. createCommons : negated conditional → KILLED |
if (params.getCarryingCapacity() < 1) { |
| 261 | throw new IllegalArgumentException("Carrying Capacity cannot be less than 1"); | |
| 262 | } | |
| 263 | ||
| 264 | Commons saved = commonsRepository.save(commons); | |
| 265 | String body = mapper.writeValueAsString(saved); | |
| 266 | ||
| 267 |
1
1. createCommons : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::createCommons → KILLED |
return ResponseEntity.ok().body(body); |
| 268 | } | |
| 269 | ||
| 270 | ||
| 271 | @Operation(summary = "List all cow health update strategies") | |
| 272 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 273 | @GetMapping("/all-health-update-strategies") | |
| 274 | public ResponseEntity<String> listCowHealthUpdateStrategies() throws JsonProcessingException { | |
| 275 | var result = HealthUpdateStrategyList.create(); | |
| 276 | String body = mapper.writeValueAsString(result); | |
| 277 |
1
1. listCowHealthUpdateStrategies : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::listCowHealthUpdateStrategies → KILLED |
return ResponseEntity.ok().body(body); |
| 278 | } | |
| 279 | ||
| 280 | @Operation(summary = "Join a commons") | |
| 281 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 282 | @PostMapping(value = "/join", produces = "application/json") | |
| 283 | public ResponseEntity<String> joinCommon( | |
| 284 | @Parameter(name="commonsId") @RequestParam Long commonsId) throws Exception { | |
| 285 | ||
| 286 | User u = getCurrentUser().getUser(); | |
| 287 | Long userId = u.getId(); | |
| 288 | String username = u.getFullName(); | |
| 289 | ||
| 290 | Commons joinedCommons = commonsRepository.findById(commonsId) | |
| 291 |
1
1. lambda$joinCommon$2 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$joinCommon$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(Commons.class, commonsId)); |
| 292 | Optional<UserCommons> userCommonsLookup = userCommonsRepository.findByCommonsIdAndUserId(commonsId, userId); | |
| 293 | ||
| 294 |
1
1. joinCommon : negated conditional → KILLED |
if (userCommonsLookup.isPresent()) { |
| 295 | // user is already a member of this commons | |
| 296 | String body = mapper.writeValueAsString(joinedCommons); | |
| 297 |
1
1. joinCommon : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::joinCommon → KILLED |
return ResponseEntity.ok().body(body); |
| 298 | } | |
| 299 | ||
| 300 | UserCommons uc = UserCommons.builder() | |
| 301 | .user(u) | |
| 302 | .commons(joinedCommons) | |
| 303 | .username(username) | |
| 304 | .totalWealth(joinedCommons.getStartingBalance()) | |
| 305 | .numOfCows(0) | |
| 306 | .cowHealth(100) | |
| 307 | .cowsBought(0) | |
| 308 | .cowsSold(0) | |
| 309 | .cowDeaths(0) | |
| 310 | .build(); | |
| 311 | ||
| 312 | userCommonsRepository.save(uc); | |
| 313 | ||
| 314 | String body = mapper.writeValueAsString(joinedCommons); | |
| 315 |
1
1. joinCommon : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::joinCommon → KILLED |
return ResponseEntity.ok().body(body); |
| 316 | } | |
| 317 | ||
| 318 | @Operation(summary = "Delete a Commons") | |
| 319 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 320 | @DeleteMapping("") | |
| 321 | public Object deleteCommons( | |
| 322 | @Parameter(name="id") @RequestParam Long id) { | |
| 323 | ||
| 324 | commonsRepository.findById(id) | |
| 325 |
1
1. lambda$deleteCommons$3 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$deleteCommons$3 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(Commons.class, id)); |
| 326 | ||
| 327 |
1
1. deleteCommons : removed call to edu/ucsb/cs156/happiercows/repositories/CommonsRepository::deleteById → KILLED |
commonsRepository.deleteById(id); |
| 328 | ||
| 329 | String responseString = String.format("commons with id %d deleted", id); | |
| 330 |
1
1. deleteCommons : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::deleteCommons → KILLED |
return genericMessage(responseString); |
| 331 | ||
| 332 | } | |
| 333 | ||
| 334 | @Operation(summary="Delete a user from a commons") | |
| 335 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 336 | @DeleteMapping("/{commonsId}/users/{userId}") | |
| 337 | public Object deleteUserFromCommon(@PathVariable("commonsId") Long commonsId, | |
| 338 | @PathVariable("userId") Long userId) throws Exception { | |
| 339 | ||
| 340 | UserCommons userCommons = userCommonsRepository.findByCommonsIdAndUserId(commonsId, userId) | |
| 341 |
1
1. lambda$deleteUserFromCommon$4 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::lambda$deleteUserFromCommon$4 → KILLED |
.orElseThrow(() -> new EntityNotFoundException( |
| 342 | UserCommons.class, "commonsId", commonsId, "userId", userId) | |
| 343 | ); | |
| 344 | ||
| 345 |
1
1. deleteUserFromCommon : removed call to edu/ucsb/cs156/happiercows/repositories/UserCommonsRepository::delete → KILLED |
userCommonsRepository.delete(userCommons); |
| 346 | ||
| 347 | String responseString = String.format("user with id %d deleted from commons with id %d, %d users remain", userId, commonsId, commonsRepository.getNumUsers(commonsId).orElse(0)); | |
| 348 | ||
| 349 |
1
1. deleteUserFromCommon : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/CommonsController::deleteUserFromCommon → KILLED |
return genericMessage(responseString); |
| 350 | } | |
| 351 | ||
| 352 | | |
| 353 | } | |
Mutations | ||
| 78 |
1.1 |
|
| 92 |
1.1 |
|
| 101 |
1.1 |
|
| 103 |
1.1 |
|
| 123 |
1.1 |
|
| 124 |
1.1 |
|
| 127 |
1.1 |
|
| 143 |
1.1 |
|
| 151 |
1.1 |
|
| 152 |
1.1 |
|
| 153 |
1.1 |
|
| 154 |
1.1 |
|
| 155 |
1.1 |
|
| 156 |
1.1 |
|
| 157 |
1.1 |
|
| 158 |
1.1 |
|
| 159 |
1.1 |
|
| 160 |
1.1 |
|
| 161 |
1.1 |
|
| 162 |
1.1 |
|
| 164 |
1.1 |
|
| 165 |
1.1 |
|
| 168 |
1.1 2.2 |
|
| 173 |
1.1 |
|
| 177 |
1.1 2.2 |
|
| 181 |
1.1 2.2 |
|
| 185 |
1.1 2.2 |
|
| 189 |
1.1 2.2 |
|
| 194 |
1.1 |
|
| 204 |
1.1 |
|
| 206 |
1.1 |
|
| 229 |
1.1 |
|
| 232 |
1.1 |
|
| 239 |
1.1 |
|
| 243 |
1.1 2.2 |
|
| 247 |
1.1 2.2 |
|
| 251 |
1.1 2.2 |
|
| 256 |
1.1 2.2 |
|
| 260 |
1.1 2.2 |
|
| 267 |
1.1 |
|
| 277 |
1.1 |
|
| 291 |
1.1 |
|
| 294 |
1.1 |
|
| 297 |
1.1 |
|
| 315 |
1.1 |
|
| 325 |
1.1 |
|
| 327 |
1.1 |
|
| 330 |
1.1 |
|
| 341 |
1.1 |
|
| 345 |
1.1 |
|
| 349 |
1.1 |