|
1
|
|
package org.hplr.elo.core.usecases.service; |
|
2
|
|
|
|
3
|
|
import org.hplr.elo.core.usecases.port.in.CalculateELOChangeForGameUseCaseInterface; |
|
4
|
|
import org.hplr.library.core.util.ConstValues; |
|
5
|
|
import org.hplr.library.exception.HPLRIllegalStateException; |
|
6
|
|
import org.springframework.stereotype.Service; |
|
7
|
|
|
|
8
|
|
import java.util.HashMap; |
|
9
|
|
import java.util.Map; |
|
10
|
|
|
|
11
|
|
@Service |
|
12
|
|
public class CalculateELOChangeForGameUseCaseService implements CalculateELOChangeForGameUseCaseInterface { |
|
13
|
|
|
|
14
|
|
|
|
15
|
|
@Override |
|
16
|
|
public Map<Integer, Long> calculateChangeForGame(Long firstElo, Long secondElo, Long gameScore) { |
|
17
|
4
1. calculateChangeForGame : Replaced long subtraction with addition → KILLED
2. calculateChangeForGame : Replaced double division with multiplication → KILLED
3. calculateChangeForGame : Replaced double division with multiplication → KILLED
4. calculateChangeForGame : Replaced double addition with subtraction → KILLED
|
double firstPlayerWinProbability = (1 / (1 + Math.pow(10, ((double) (secondElo - firstElo) / (ConstValues.INITIAL_WEIGHT))))); |
|
18
|
4
1. calculateChangeForGame : Replaced long subtraction with addition → KILLED
2. calculateChangeForGame : Replaced double division with multiplication → KILLED
3. calculateChangeForGame : Replaced double addition with subtraction → KILLED
4. calculateChangeForGame : Replaced double division with multiplication → KILLED
|
double secondPlayerWinProbability = (1 / (1 + Math.pow(10, ((double) (firstElo - secondElo) / (ConstValues.INITIAL_WEIGHT))))); |
|
19
|
|
Map<Integer, Long> eloChangeForGame = new HashMap<>(); |
|
20
|
1
1. calculateChangeForGame : negated conditional → KILLED
|
if (gameScore == 0) { |
|
21
|
3
1. calculateChangeForGame : Replaced double subtraction with addition → SURVIVED
2. calculateChangeForGame : Replaced double multiplication with division → SURVIVED
3. calculateChangeForGame : Replaced long multiplication with division → KILLED
|
eloChangeForGame.put(1, (long) (ConstValues.ELO_CONST * gameScore * (0.5 - firstPlayerWinProbability))); |
|
22
|
3
1. calculateChangeForGame : Replaced double subtraction with addition → SURVIVED
2. calculateChangeForGame : Replaced double multiplication with division → SURVIVED
3. calculateChangeForGame : Replaced long multiplication with division → KILLED
|
eloChangeForGame.put(2, (long) (ConstValues.ELO_CONST * gameScore * (0.5 - secondPlayerWinProbability))); |
|
23
|
1
1. calculateChangeForGame : replaced return value with Collections.emptyMap for org/hplr/elo/core/usecases/service/CalculateELOChangeForGameUseCaseService::calculateChangeForGame → KILLED
|
return eloChangeForGame; |
|
24
|
|
} |
|
25
|
4
1. calculateChangeForGame : changed conditional boundary → SURVIVED
2. calculateChangeForGame : changed conditional boundary → KILLED
3. calculateChangeForGame : negated conditional → KILLED
4. calculateChangeForGame : negated conditional → KILLED
|
if (gameScore >= -20 && gameScore < 0) { |
|
26
|
1
1. calculateChangeForGame : removed negation → KILLED
|
gameScore = -gameScore; |
|
27
|
3
1. calculateChangeForGame : Replaced double subtraction with addition → KILLED
2. calculateChangeForGame : Replaced long multiplication with division → KILLED
3. calculateChangeForGame : Replaced double multiplication with division → KILLED
|
eloChangeForGame.put(1, (long) (ConstValues.ELO_CONST * gameScore * (0 - firstPlayerWinProbability))); |
|
28
|
3
1. calculateChangeForGame : Replaced double subtraction with addition → KILLED
2. calculateChangeForGame : Replaced long multiplication with division → KILLED
3. calculateChangeForGame : Replaced double multiplication with division → KILLED
|
eloChangeForGame.put(2, (long) (ConstValues.ELO_CONST * gameScore * (1 - secondPlayerWinProbability))); |
|
29
|
1
1. calculateChangeForGame : replaced return value with Collections.emptyMap for org/hplr/elo/core/usecases/service/CalculateELOChangeForGameUseCaseService::calculateChangeForGame → KILLED
|
return eloChangeForGame; |
|
30
|
4
1. calculateChangeForGame : changed conditional boundary → SURVIVED
2. calculateChangeForGame : negated conditional → KILLED
3. calculateChangeForGame : changed conditional boundary → KILLED
4. calculateChangeForGame : negated conditional → KILLED
|
} else if (gameScore > 0 && gameScore <= 20) { |
|
31
|
3
1. calculateChangeForGame : Replaced long multiplication with division → KILLED
2. calculateChangeForGame : Replaced double subtraction with addition → KILLED
3. calculateChangeForGame : Replaced double multiplication with division → KILLED
|
eloChangeForGame.put(1, (long) (ConstValues.ELO_CONST * gameScore * (1 - firstPlayerWinProbability))); |
|
32
|
3
1. calculateChangeForGame : Replaced double multiplication with division → KILLED
2. calculateChangeForGame : Replaced long multiplication with division → KILLED
3. calculateChangeForGame : Replaced double subtraction with addition → KILLED
|
eloChangeForGame.put(2, (long) (ConstValues.ELO_CONST * gameScore * (0 - secondPlayerWinProbability))); |
|
33
|
1
1. calculateChangeForGame : replaced return value with Collections.emptyMap for org/hplr/elo/core/usecases/service/CalculateELOChangeForGameUseCaseService::calculateChangeForGame → KILLED
|
return eloChangeForGame; |
|
34
|
|
} else { |
|
35
|
|
throw new HPLRIllegalStateException("Wrong score!"); |
|
36
|
|
} |
|
37
|
|
} |
|
38
|
|
} |
| | Mutations |
| 17 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced long subtraction with addition → KILLED 2.2 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double division with multiplication → KILLED 3.3 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double division with multiplication → KILLED 4.4 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double addition with subtraction → KILLED
|
| 18 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced long subtraction with addition → KILLED 2.2 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double division with multiplication → KILLED 3.3 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double addition with subtraction → KILLED 4.4 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double division with multiplication → KILLED
|
| 20 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[method:get_game_wrong_score_and_throw_HPLRIllegalStateException()] negated conditional → KILLED
|
| 21 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[method:get_game_draw_and_check_probabilities()] Replaced long multiplication with division → KILLED 2.2 Location : calculateChangeForGame Killed by : none Replaced double subtraction with addition → SURVIVED 3.3 Location : calculateChangeForGame Killed by : none Replaced double multiplication with division → SURVIVED
|
| 22 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[method:get_game_draw_and_check_probabilities()] Replaced long multiplication with division → KILLED 2.2 Location : calculateChangeForGame Killed by : none Replaced double subtraction with addition → SURVIVED 3.3 Location : calculateChangeForGame Killed by : none Replaced double multiplication with division → SURVIVED
|
| 23 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[method:get_game_draw_and_check_probabilities()] replaced return value with Collections.emptyMap for org/hplr/elo/core/usecases/service/CalculateELOChangeForGameUseCaseService::calculateChangeForGame → KILLED
|
| 25 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#20] changed conditional boundary → KILLED 2.2 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#20] negated conditional → KILLED 3.3 Location : calculateChangeForGame Killed by : none changed conditional boundary → SURVIVED 4.4 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[method:get_game_wrong_score_and_throw_HPLRIllegalStateException()] negated conditional → KILLED
|
| 26 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#8] removed negation → KILLED
|
| 27 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#8] Replaced double subtraction with addition → KILLED 2.2 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#8] Replaced long multiplication with division → KILLED 3.3 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#8] Replaced double multiplication with division → KILLED
|
| 28 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#8] Replaced double subtraction with addition → KILLED 2.2 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#8] Replaced long multiplication with division → KILLED 3.3 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#8] Replaced double multiplication with division → KILLED
|
| 29 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_lost_for_first_side_and_check_probabilities()]/[test-template-invocation:#8] replaced return value with Collections.emptyMap for org/hplr/elo/core/usecases/service/CalculateELOChangeForGameUseCaseService::calculateChangeForGame → KILLED
|
| 30 |
|
1.1 Location : calculateChangeForGame Killed by : none changed conditional boundary → SURVIVED 2.2 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] negated conditional → KILLED 3.3 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#1] changed conditional boundary → KILLED 4.4 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[method:get_game_wrong_score_and_throw_HPLRIllegalStateException()] negated conditional → KILLED
|
| 31 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#16] Replaced long multiplication with division → KILLED 2.2 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double subtraction with addition → KILLED 3.3 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double multiplication with division → KILLED
|
| 32 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double multiplication with division → KILLED 2.2 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#16] Replaced long multiplication with division → KILLED 3.3 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] Replaced double subtraction with addition → KILLED
|
| 33 |
|
1.1 Location : calculateChangeForGame Killed by : org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.elo.core.usecases.service.CalculateELOChangeForGameUseCaseServiceTests]/[test-template:get_game_won_for_first_side_and_check_probabilities(java.lang.Long)]/[test-template-invocation:#20] replaced return value with Collections.emptyMap for org/hplr/elo/core/usecases/service/CalculateELOChangeForGameUseCaseService::calculateChangeForGame → KILLED
|