Commons.java

1
package edu.ucsb.cs156.happiercows.entities;
2
3
import java.time.LocalDateTime;
4
import java.util.List;
5
6
import com.fasterxml.jackson.annotation.JsonIgnore;
7
8
import javax.persistence.*;
9
10
import lombok.Data;
11
import lombok.AllArgsConstructor;
12
import lombok.NoArgsConstructor;
13
import lombok.Builder;
14
import lombok.AccessLevel;
15
16
@Data
17
@AllArgsConstructor
18
@NoArgsConstructor
19
@Builder
20
@Entity(name = "commons")
21
public class Commons
22
{
23
  @Id
24
  @GeneratedValue(strategy = GenerationType.IDENTITY)
25
  private long id;
26
  private String name;
27
  private double cowPrice;
28
  private double milkPrice;
29
  private double startingBalance;
30
  private LocalDateTime startingDate;
31
  private LocalDateTime lastDate;
32
  private double degradationRate;
33
  private boolean showLeaderboard;
34
  private int carryingCapacity;
35
  private double priceChange;
36
  public void increaseCowPrice() {
37 1 1. increaseCowPrice : Replaced double addition with subtraction → KILLED
    cowPrice += priceChange;
38
  }
39
  public void decreaseCowPrice() {
40 1 1. decreaseCowPrice : Replaced double subtraction with addition → KILLED
    cowPrice -= priceChange;
41
  }
42
  public boolean gameInProgress(){
43 2 1. gameInProgress : negated conditional → KILLED
2. gameInProgress : negated conditional → KILLED
    boolean output = (startingDate.isBefore(LocalDateTime.now()) && lastDate.isAfter(LocalDateTime.now()));
44 2 1. gameInProgress : replaced boolean return with false for edu/ucsb/cs156/happiercows/entities/Commons::gameInProgress → KILLED
2. gameInProgress : replaced boolean return with true for edu/ucsb/cs156/happiercows/entities/Commons::gameInProgress → KILLED
    return output;
45
  }
46
47
  @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST,CascadeType.REMOVE})
48
  @JoinTable(name = "user_commons",
49
    joinColumns = @JoinColumn(name = "commons_id", referencedColumnName = "id"),
50
    inverseJoinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"))
51
  @JsonIgnore // https://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion
52
  private List<User> users;
53
}

Mutations

37

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

40

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

43

1.1
Location : gameInProgress
Killed by : edu.ucsb.cs156.happiercows.entities.CommonsTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.entities.CommonsTests]/[method:test_gameInProgressTrue()]
negated conditional → KILLED

2.2
Location : gameInProgress
Killed by : edu.ucsb.cs156.happiercows.entities.CommonsTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.entities.CommonsTests]/[method:test_gameInProgressTrue()]
negated conditional → KILLED

44

1.1
Location : gameInProgress
Killed by : edu.ucsb.cs156.happiercows.entities.CommonsTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.entities.CommonsTests]/[method:test_gameInProgressTrue()]
replaced boolean return with false for edu/ucsb/cs156/happiercows/entities/Commons::gameInProgress → KILLED

2.2
Location : gameInProgress
Killed by : edu.ucsb.cs156.happiercows.entities.CommonsTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.entities.CommonsTests]/[method:test_gameInProgress_False_Already_Ended()]
replaced boolean return with true for edu/ucsb/cs156/happiercows/entities/Commons::gameInProgress → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3