DefaultImplementationSelector.java

1
package io.github.gipo999.smispi;
2
3
import java.util.List;
4
import java.util.Optional;
5
6
/** Default implementation selector. */
7
public class DefaultImplementationSelector implements ImplementationSelector {
8
9
  /**
10
   * Chooses an implementation of a service.
11
   *
12
   * @param clazz the class of the service
13
   * @param implementations the implementations of the service
14
   * @param params the parameters for choosing the implementation
15
   * @param <T> the type of the service
16
   * @return the chosen implementation
17
   */
18
  @Override
19
  public <T extends NamedService> Optional<T> choose(
20
      Class<T> clazz, List<T> implementations, Optional<ImplementationParams> params) {
21
22 2 1. choose : negated conditional → KILLED
2. choose : negated conditional → KILLED
    if (implementations == null || implementations.isEmpty()) {
23
      return Optional.empty();
24
    }
25
26
    T standard = null;
27
28
    T custom = null;
29
30
    for (T impl : implementations) {
31
32
      String implName = impl.getServiceImplementationName();
33
34 1 1. choose : negated conditional → KILLED
      if (NamedService.IMPL_STANDARD_NAME.equals(implName)) {
35
        standard = impl;
36 1 1. choose : negated conditional → KILLED
      } else if (NamedService.IMPL_CUSTOM_NAME.equals(implName)) {
37
        custom = impl;
38
      }
39
    }
40
41 1 1. choose : negated conditional → KILLED
    if (custom != null) {
42
43 1 1. choose : replaced return value with Optional.empty for io/github/gipo999/smispi/DefaultImplementationSelector::choose → KILLED
      return Optional.of(custom);
44 1 1. choose : negated conditional → KILLED
    } else if (standard != null) {
45
46 1 1. choose : replaced return value with Optional.empty for io/github/gipo999/smispi/DefaultImplementationSelector::choose → KILLED
      return Optional.of(standard);
47
    }
48
49
    return Optional.empty();
50
  }
51
}

Mutations

22

1.1
Location : choose
Killed by : io.github.gipo999.smispi.ImplementationTest.[engine:junit-jupiter]/[class:io.github.gipo999.smispi.ImplementationTest]/[method:testStandardOnlyNoCache()]
negated conditional → KILLED

2.2
Location : choose
Killed by : io.github.gipo999.smispi.ImplementationTest.[engine:junit-jupiter]/[class:io.github.gipo999.smispi.ImplementationTest]/[method:testStandardOnlyNoCache()]
negated conditional → KILLED

34

1.1
Location : choose
Killed by : io.github.gipo999.smispi.ImplementationTest.[engine:junit-jupiter]/[class:io.github.gipo999.smispi.ImplementationTest]/[method:testStandardOnlyNoCache()]
negated conditional → KILLED

36

1.1
Location : choose
Killed by : io.github.gipo999.smispi.ImplementationTest.[engine:junit-jupiter]/[class:io.github.gipo999.smispi.ImplementationTest]/[method:testBothOnlyNoCache()]
negated conditional → KILLED

41

1.1
Location : choose
Killed by : io.github.gipo999.smispi.ImplementationTest.[engine:junit-jupiter]/[class:io.github.gipo999.smispi.ImplementationTest]/[method:testStandardOnlyNoCache()]
negated conditional → KILLED

43

1.1
Location : choose
Killed by : io.github.gipo999.smispi.ImplementationTest.[engine:junit-jupiter]/[class:io.github.gipo999.smispi.ImplementationTest]/[method:testBothOnlyNoCache()]
replaced return value with Optional.empty for io/github/gipo999/smispi/DefaultImplementationSelector::choose → KILLED

44

1.1
Location : choose
Killed by : io.github.gipo999.smispi.ImplementationTest.[engine:junit-jupiter]/[class:io.github.gipo999.smispi.ImplementationTest]/[method:testStandardOnlyNoCache()]
negated conditional → KILLED

46

1.1
Location : choose
Killed by : io.github.gipo999.smispi.ImplementationTest.[engine:junit-jupiter]/[class:io.github.gipo999.smispi.ImplementationTest]/[method:testStandardOnlyNoCache()]
replaced return value with Optional.empty for io/github/gipo999/smispi/DefaultImplementationSelector::choose → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.2