FarmerController.java

1
package edu.ucsb.cs156.happiercows.controllers;
2
3
import com.fasterxml.jackson.core.JsonProcessingException;
4
import com.fasterxml.jackson.databind.ObjectMapper;
5
6
import org.springframework.beans.factory.annotation.Autowired;
7
8
import org.springframework.security.access.prepost.PreAuthorize;
9
import org.springframework.web.bind.annotation.GetMapping;
10
import org.springframework.web.bind.annotation.RequestMapping;
11
import org.springframework.web.bind.annotation.RequestParam;
12
import org.springframework.web.bind.annotation.RestController;
13
14
import edu.ucsb.cs156.happiercows.repositories.FarmerRepository;
15
import edu.ucsb.cs156.happiercows.repositories.GameRepository;
16
import edu.ucsb.cs156.happiercows.repositories.HerdRepository;
17
import edu.ucsb.cs156.happiercows.entities.User;
18
import edu.ucsb.cs156.happiercows.entities.Farmer;
19
import edu.ucsb.cs156.happiercows.entities.FarmerActivity;
20
import edu.ucsb.cs156.happiercows.entities.Game;
21
import edu.ucsb.cs156.happiercows.entities.Herd;
22
import edu.ucsb.cs156.happiercows.errors.EntityNotFoundException;
23
import edu.ucsb.cs156.happiercows.errors.InvalidNumberOfCowsException;
24
import edu.ucsb.cs156.happiercows.errors.NoCowsException;
25
import edu.ucsb.cs156.happiercows.errors.NotEnoughMoneyException;
26
import edu.ucsb.cs156.happiercows.errors.GameHiddenException;
27
import edu.ucsb.cs156.happiercows.errors.NotEnrolledInCourseAssociatedWithGameException;
28
import edu.ucsb.cs156.happiercows.models.FarmerWithStudentStatus;
29
import edu.ucsb.cs156.happiercows.services.CourseAccessService;
30
import edu.ucsb.cs156.happiercows.services.FarmerActivityService;
31
32
import java.util.ArrayList;
33
import java.util.List;
34
35
import io.swagger.v3.oas.annotations.tags.Tag;
36
import io.swagger.v3.oas.annotations.Operation;
37
import io.swagger.v3.oas.annotations.Parameter;
38
39
import org.springframework.http.ResponseEntity;
40
import org.springframework.web.bind.annotation.PutMapping;
41
42
@Tag(name = "User Game")
43
@RequestMapping("/api/farmer")
44
@RestController
45
public class FarmerController extends ApiController {
46
47
  @Autowired
48
  private FarmerRepository farmerRepository;
49
50
  @Autowired
51
  private GameRepository gameRepository;
52
53
  @Autowired
54
  private HerdRepository herdRepository;
55
56
  @Autowired
57
  ObjectMapper mapper;
58
59
  @Autowired
60
  private CourseAccessService courseAccessService;
61
62
  @Autowired
63
  private FarmerActivityService farmerActivityService;
64
65
  @Operation(summary = "Get a specific user game (admin only)")
66
  @PreAuthorize("hasRole('ROLE_ADMIN')")
67
  @GetMapping("")
68
  public Farmer getFarmerById(
69
      @Parameter(name="userId") @RequestParam Long userId,
70
      @Parameter(name="gameId") @RequestParam Long gameId) throws JsonProcessingException {
71
72
    Farmer farmer = farmerRepository.findByGameIdAndUserId(gameId, userId)
73
        .orElseThrow(
74 1 1. lambda$getFarmerById$0 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::lambda$getFarmerById$0 → KILLED
            () -> new EntityNotFoundException(Farmer.class, "gameId", gameId, "userId", userId));
75 1 1. getFarmerById : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::getFarmerById → KILLED
    return farmer;
76
  }
77
78
  @Operation(summary = "Get a user game for current user")
79
  @PreAuthorize("hasRole('ROLE_USER')")
80
  @GetMapping("/forcurrentuser")
81
  public Farmer getFarmerById(
82
      @Parameter(name="gameId") @RequestParam Long gameId) throws JsonProcessingException {
83
84
    User u = getCurrentUser().getUser();
85
    Long userId = u.getId();
86
    Game game = gameRepository.findById(gameId)
87 1 1. lambda$getFarmerById$1 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::lambda$getFarmerById$1 → KILLED
        .orElseThrow(() -> new EntityNotFoundException("Game", gameId));
88 1 1. getFarmerById : removed call to edu/ucsb/cs156/happiercows/controllers/FarmerController::ensureUserCanAccessCourseLinkedGame → KILLED
    ensureUserCanAccessCourseLinkedGame(u, game);
89
    Farmer farmer = farmerRepository.findByGameIdAndUserId(gameId, userId)
90
        .orElseThrow(
91 1 1. lambda$getFarmerById$2 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::lambda$getFarmerById$2 → KILLED
            () -> new EntityNotFoundException(Farmer.class, "gameId", gameId, "userId", userId));
92 1 1. getFarmerById : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::getFarmerById → KILLED
    return farmer;
93
  }
94
95
  @Operation(summary = "Buy a herd of numCows cows (starting at 100 health), totalWealth updated")
96
  @PreAuthorize("hasRole('ROLE_USER')")
97
  @PutMapping("/buy")
98
  public ResponseEntity<String> putFarmerByIdBuy(
99
          @Parameter(name="gameId") @RequestParam Long gameId,
100
          @Parameter(name="numCows") @RequestParam int numCows) throws NotEnoughMoneyException, InvalidNumberOfCowsException, JsonProcessingException{
101
102 2 1. putFarmerByIdBuy : changed conditional boundary → KILLED
2. putFarmerByIdBuy : negated conditional → KILLED
        if (numCows < 1) {
103
          throw new InvalidNumberOfCowsException("You must buy at least 1 cow!");
104
        }
105
106
        User u = getCurrentUser().getUser();
107
        Long userId = u.getId();
108
109
        Game game = gameRepository.findById(gameId).orElseThrow( 
110 1 1. lambda$putFarmerByIdBuy$0 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::lambda$putFarmerByIdBuy$0 → KILLED
          ()->new EntityNotFoundException("Game", gameId));
111
112 1 1. putFarmerByIdBuy : removed call to edu/ucsb/cs156/happiercows/controllers/FarmerController::ensureUserCanAccessCourseLinkedGame → KILLED
        ensureUserCanAccessCourseLinkedGame(u, game);
113
114 1 1. putFarmerByIdBuy : negated conditional → KILLED
        if (game.isHidden()) {
115
          throw new GameHiddenException(gameId);
116
        }
117
118
        Farmer farmer = farmerRepository.findByGameIdAndUserId(gameId, userId)
119
        .orElseThrow(
120 1 1. lambda$putFarmerByIdBuy$1 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::lambda$putFarmerByIdBuy$1 → KILLED
            () -> new EntityNotFoundException(Farmer.class, "gameId", gameId, "userId", userId));
121
122 1 1. putFarmerByIdBuy : Replaced double addition with subtraction → KILLED
        double costPerCow = game.getCowPrice() + game.getPurchaseFee();
123 3 1. putFarmerByIdBuy : Replaced double multiplication with division → KILLED
2. putFarmerByIdBuy : negated conditional → KILLED
3. putFarmerByIdBuy : changed conditional boundary → KILLED
        if(farmer.getTotalWealth() >= (costPerCow * numCows)){
124 3 1. putFarmerByIdBuy : removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setTotalWealth → KILLED
2. putFarmerByIdBuy : Replaced double subtraction with addition → KILLED
3. putFarmerByIdBuy : Replaced double multiplication with division → KILLED
          farmer.setTotalWealth(farmer.getTotalWealth() - (costPerCow * numCows));
125 2 1. putFarmerByIdBuy : removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setNumOfCows → KILLED
2. putFarmerByIdBuy : Replaced integer addition with subtraction → KILLED
          farmer.setNumOfCows(farmer.getNumOfCows() + numCows);
126 2 1. putFarmerByIdBuy : removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setCowsBought → KILLED
2. putFarmerByIdBuy : Replaced integer addition with subtraction → KILLED
          farmer.setCowsBought(farmer.getCowsBought() + numCows);
127
        }
128
        else{
129
          throw new NotEnoughMoneyException("You need more money!");
130
        }
131
        farmerRepository.save(farmer);
132
        herdRepository.save(Herd.builder().farmer(farmer).numCows(numCows).health(100).build());
133
134 1 1. putFarmerByIdBuy : removed call to edu/ucsb/cs156/happiercows/services/FarmerActivityService::recordActivityIfStudentMatch → KILLED
        farmerActivityService.recordActivityIfStudentMatch(
135
            u, game, farmer, FarmerActivity.ACTIVITY_TYPE_BUY, numCows);
136
137
        String body = mapper.writeValueAsString(farmer);
138 1 1. putFarmerByIdBuy : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::putFarmerByIdBuy → KILLED
        return ResponseEntity.ok().body(body);
139
    }
140
141
  @Operation(summary = "Sell a cow, totalWealth updated")
142
  @PreAuthorize("hasRole('ROLE_USER')")
143
  @PutMapping("/sell")
144
  public ResponseEntity<String> putFarmerByIdSell(
145
          @Parameter(name="gameId") @RequestParam Long gameId,
146
          @Parameter(name="numCows") @RequestParam int numCows) throws NoCowsException, JsonProcessingException {
147
        User u = getCurrentUser().getUser();
148
        Long userId = u.getId();
149
150
        Game game = gameRepository.findById(gameId).orElseThrow( 
151 1 1. lambda$putFarmerByIdSell$0 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::lambda$putFarmerByIdSell$0 → KILLED
          ()->new EntityNotFoundException("Game", gameId));
152
153 1 1. putFarmerByIdSell : removed call to edu/ucsb/cs156/happiercows/controllers/FarmerController::ensureUserCanAccessCourseLinkedGame → KILLED
        ensureUserCanAccessCourseLinkedGame(u, game);
154
155 1 1. putFarmerByIdSell : negated conditional → KILLED
        if (game.isHidden()) {
156
          throw new GameHiddenException(gameId);
157
        }
158
159
        Farmer farmer = farmerRepository.findByGameIdAndUserId(gameId, userId)
160
        .orElseThrow(
161 1 1. lambda$putFarmerByIdSell$1 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::lambda$putFarmerByIdSell$1 → KILLED
            () -> new EntityNotFoundException(Farmer.class, "gameId", gameId, "userId", userId));
162
163
164 2 1. putFarmerByIdSell : negated conditional → KILLED
2. putFarmerByIdSell : changed conditional boundary → KILLED
        if(farmer.getNumOfCows() >= numCows ){
165 2 1. putFarmerByIdSell : Replaced double division with multiplication → KILLED
2. putFarmerByIdSell : Replaced double multiplication with division → KILLED
          double cowValue = game.getCowPrice() * farmer.getCowHealth() / 100
166 1 1. putFarmerByIdSell : Replaced double subtraction with addition → KILLED
              - game.getSellingFee();
167 3 1. putFarmerByIdSell : Replaced double multiplication with division → KILLED
2. putFarmerByIdSell : Replaced double addition with subtraction → KILLED
3. putFarmerByIdSell : removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setTotalWealth → KILLED
          farmer.setTotalWealth(farmer.getTotalWealth() + (cowValue * numCows));
168 2 1. putFarmerByIdSell : Replaced integer subtraction with addition → KILLED
2. putFarmerByIdSell : removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setNumOfCows → KILLED
          farmer.setNumOfCows(farmer.getNumOfCows() - numCows);
169 2 1. putFarmerByIdSell : Replaced integer addition with subtraction → KILLED
2. putFarmerByIdSell : removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setCowsSold → KILLED
          farmer.setCowsSold(farmer.getCowsSold() + numCows);
170
        }
171
        else{
172
          throw new NoCowsException("You do not have enough cows to sell!");
173
        }
174
        farmerRepository.save(farmer);
175
176 1 1. putFarmerByIdSell : removed call to edu/ucsb/cs156/happiercows/services/FarmerActivityService::recordActivityIfStudentMatch → KILLED
        farmerActivityService.recordActivityIfStudentMatch(
177
            u, game, farmer, FarmerActivity.ACTIVITY_TYPE_SELL, numCows);
178
179
        String body = mapper.writeValueAsString(farmer);
180 1 1. putFarmerByIdSell : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::putFarmerByIdSell → KILLED
        return ResponseEntity.ok().body(body);
181
    }
182
183
    
184
185
    @Operation(summary = "Get all user game for a specific game")
186
    @PreAuthorize("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')")
187
    @GetMapping("/game/all")
188
    public List<FarmerWithStudentStatus> getFarmersByGameId(
189
        @Parameter(name="gameId") @RequestParam Long gameId) {
190
191
      Game game = gameRepository.findById(gameId)
192 1 1. lambda$getFarmersByGameId$0 : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::lambda$getFarmersByGameId$0 → KILLED
          .orElseThrow(() -> new EntityNotFoundException("Game", gameId));
193
194
      List<FarmerWithStudentStatus> result = new ArrayList<>();
195
      for (Farmer farmer : farmerRepository.findByGameId(gameId)) {
196
        boolean isStudent = courseAccessService
197
            .findMatchingStudentForCourseLinkedGame(farmer.getUser(), game)
198
            .isPresent();
199
200
        result.add(FarmerWithStudentStatus.builder()
201
            .userId(farmer.getUserId())
202
            .gameId(farmer.getGameId())
203
            .username(farmer.getUsername())
204
            .totalWealth(farmer.getTotalWealth())
205
            .numOfCows(farmer.getNumOfCows())
206
            .cowHealth(farmer.getCowHealth())
207
            .cowsBought(farmer.getCowsBought())
208
            .cowsSold(farmer.getCowsSold())
209
            .cowDeaths(farmer.getCowDeaths())
210
            .student(isStudent)
211
            .build());
212
      }
213 1 1. getFarmersByGameId : replaced return value with Collections.emptyList for edu/ucsb/cs156/happiercows/controllers/FarmerController::getFarmersByGameId → KILLED
      return result;
214
  }
215
216
  private void ensureUserCanAccessCourseLinkedGame(User user, Game game) {
217 2 1. ensureUserCanAccessCourseLinkedGame : negated conditional → KILLED
2. ensureUserCanAccessCourseLinkedGame : negated conditional → KILLED
    if (game.getCourseId() != null && !courseAccessService.isEligibleForGame(user, game)) {
218
      throw new NotEnrolledInCourseAssociatedWithGameException();
219
    }
220
  }
221
222
}

Mutations

74

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

75

1.1
Location : getFarmerById
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_getFarmerById_exists_admin()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::getFarmerById → KILLED

87

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

88

1.1
Location : getFarmerById
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_getFarmerById_course_linked_game_requires_current_enrollment()]
removed call to edu/ucsb/cs156/happiercows/controllers/FarmerController::ensureUserCanAccessCourseLinkedGame → KILLED

91

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

92

1.1
Location : getFarmerById
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_getFarmerById_exists()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::getFarmerById → KILLED

102

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

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

110

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

112

1.1
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_course_linked_game_requires_current_enrollment()]
removed call to edu/ucsb/cs156/happiercows/controllers/FarmerController::ensureUserCanAccessCourseLinkedGame → KILLED

114

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

120

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

122

1.1
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_chargesPurchaseFeePerCow()]
Replaced double addition with subtraction → KILLED

123

1.1
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_BuyCow_not_enough_money()]
Replaced double multiplication with division → KILLED

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

3.3
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_BuyCow_game_exists_user_has_exact_amount_needed()]
changed conditional boundary → KILLED

124

1.1
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_chargesPurchaseFeePerCow()]
removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setTotalWealth → KILLED

2.2
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_chargesPurchaseFeePerCow()]
Replaced double subtraction with addition → KILLED

3.3
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_chargesPurchaseFeePerCow()]
Replaced double multiplication with division → KILLED

125

1.1
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_chargesPurchaseFeePerCow()]
removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setNumOfCows → KILLED

2.2
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_chargesPurchaseFeePerCow()]
Replaced integer addition with subtraction → KILLED

126

1.1
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_chargesPurchaseFeePerCow()]
removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setCowsBought → KILLED

2.2
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_chargesPurchaseFeePerCow()]
Replaced integer addition with subtraction → KILLED

134

1.1
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_BuyCow_game_exists()]
removed call to edu/ucsb/cs156/happiercows/services/FarmerActivityService::recordActivityIfStudentMatch → KILLED

138

1.1
Location : putFarmerByIdBuy
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_buyCow_chargesPurchaseFeePerCow()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::putFarmerByIdBuy → KILLED

151

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

153

1.1
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_SellCow_course_linked_game_allows_current_enrollment()]
removed call to edu/ucsb/cs156/happiercows/controllers/FarmerController::ensureUserCanAccessCourseLinkedGame → KILLED

155

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

161

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

164

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

2.2
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
changed conditional boundary → KILLED

165

1.1
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
Replaced double division with multiplication → KILLED

2.2
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
Replaced double multiplication with division → KILLED

166

1.1
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
Replaced double subtraction with addition → KILLED

167

1.1
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
Replaced double multiplication with division → KILLED

2.2
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
Replaced double addition with subtraction → KILLED

3.3
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setTotalWealth → KILLED

168

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

2.2
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setNumOfCows → KILLED

169

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

2.2
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
removed call to edu/ucsb/cs156/happiercows/entities/Farmer::setCowsSold → KILLED

176

1.1
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_SellCow_game_exists()]
removed call to edu/ucsb/cs156/happiercows/services/FarmerActivityService::recordActivityIfStudentMatch → KILLED

180

1.1
Location : putFarmerByIdSell
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_sellCow_deductsSellingFeePerCow()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/FarmerController::putFarmerByIdSell → KILLED

192

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

213

1.1
Location : getFarmersByGameId
Killed by : edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.FarmerControllerTests]/[method:test_getAllFarmerById_exists()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/happiercows/controllers/FarmerController::getFarmersByGameId → KILLED

217

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

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

Active mutators

Tests examined


Report generated by PIT 1.22.1