Commons.java

1
package edu.ucsb.cs156.happiercows.entities;
2
3
import com.fasterxml.jackson.annotation.JsonIgnore;
4
import edu.ucsb.cs156.happiercows.strategies.CowHealthUpdateStrategies;
5
import lombok.AllArgsConstructor;
6
import lombok.Builder;
7
import lombok.Data;
8
import lombok.NoArgsConstructor;
9
10
import javax.persistence.*;
11
import java.time.LocalDateTime;
12
import java.util.List;
13
14
15
16
@Data
17
@AllArgsConstructor
18
@NoArgsConstructor
19
@Builder
20
@Entity(name = "commons")
21
public class Commons {
22
    @Id
23
    @GeneratedValue(strategy = GenerationType.IDENTITY)
24
    private long id;
25
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 boolean showChat;
33
    private boolean showLeaderboard;
34
35
    private int capacityPerUser;
36
    private int carryingCapacity;
37
    private double degradationRate;
38
39
    // these defaults match old behavior
40
    @Enumerated(EnumType.STRING)
41
    @Builder.Default
42
    private CowHealthUpdateStrategies belowCapacityHealthUpdateStrategy = CowHealthUpdateStrategies.DEFAULT_BELOW_CAPACITY;
43
    @Enumerated(EnumType.STRING)
44
    @Builder.Default
45
    private CowHealthUpdateStrategies aboveCapacityHealthUpdateStrategy = CowHealthUpdateStrategies.DEFAULT_ABOVE_CAPACITY;
46
47
48
    @OneToMany(mappedBy = "commons", cascade = CascadeType.REMOVE)
49
    @JsonIgnore
50
    private List<UserCommons> joinedUsers;
51
52
    public boolean gameInProgress() {
53
        LocalDateTime today = LocalDateTime.now();
54 2 1. gameInProgress : negated conditional → KILLED
2. gameInProgress : negated conditional → KILLED
        if (startingDate.isBefore(today) && lastDate.isAfter(today)) {
55 1 1. gameInProgress : replaced boolean return with false for edu/ucsb/cs156/happiercows/entities/Commons::gameInProgress → KILLED
            return true;
56
        }
57 1 1. gameInProgress : replaced boolean return with true for edu/ucsb/cs156/happiercows/entities/Commons::gameInProgress → KILLED
        return false;
58
    }
59
}

Mutations

54

1.1
Location : gameInProgress
Killed by : edu.ucsb.cs156.happiercows.entities.CommonsTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.entities.CommonsTests]/[method:test_gameInProgress_true()]
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_gameInProgress_true()]
negated conditional → KILLED

55

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

57

1.1
Location : gameInProgress
Killed by : edu.ucsb.cs156.happiercows.entities.CommonsTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.entities.CommonsTests]/[method:test_gameInProgress_not_started()]
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