ListChecker.java

1
package com.github.valid8j.pcond.core.fluent.builtins;
2
3
import com.github.valid8j.pcond.core.fluent.AbstractObjectChecker;
4
import com.github.valid8j.pcond.experimentals.cursor.Cursors;
5
import com.github.valid8j.pcond.forms.Predicates;
6
import com.github.valid8j.pcond.forms.Printables;
7
import com.github.valid8j.pcond.internals.InternalUtils;
8
9
import java.util.Arrays;
10
import java.util.List;
11
import java.util.Objects;
12
import java.util.function.Function;
13
import java.util.function.Predicate;
14
import java.util.function.Supplier;
15
import java.util.stream.Collectors;
16
17
public interface ListChecker<
18
    T,
19
    E
20
    > extends
21
    AbstractObjectChecker<
22
        ListChecker<T, E>,
23
        T,
24
        List<E>> {
25
  default ListChecker<T, E> empty() {
26 1 1. empty : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::empty → KILLED
    return checkWithPredicate(Predicates.isEmpty());
27
  }
28
  
29
  default ListChecker<T, E> notEmpty() {
30 1 1. notEmpty : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::notEmpty → KILLED
    return checkWithPredicate(Predicates.not(Predicates.isEmpty()));
31
  }
32
  
33
  default ListChecker<T, E> firstElementToBe(Predicate<E> predicate) {
34 3 1. lambda$firstElementToBe$0 : replaced boolean return with false for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$firstElementToBe$0 → NO_COVERAGE
2. lambda$firstElementToBe$0 : replaced boolean return with true for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$firstElementToBe$0 → NO_COVERAGE
3. firstElementToBe : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::firstElementToBe → KILLED
    return predicate(Printables.predicate("firstElementToBe[" + predicate + "]", l -> predicate.test(l.get(0))));
35
  }
36
  
37
  default ListChecker<T, E> lastElementToBe(Predicate<E> predicate) {
38 4 1. lambda$lastElementToBe$1 : Replaced integer subtraction with addition → NO_COVERAGE
2. lambda$lastElementToBe$1 : replaced boolean return with false for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$lastElementToBe$1 → NO_COVERAGE
3. lambda$lastElementToBe$1 : replaced boolean return with true for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$lastElementToBe$1 → NO_COVERAGE
4. lastElementToBe : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lastElementToBe → KILLED
    return predicate(Printables.predicate("lastElementToBe[" + predicate + "]", l -> predicate.test(l.get(l.size() - 1))));
39
  }
40
  
41
  default ListChecker<T, E> containingElementToBe(Predicate<E> predicate) {
42 3 1. lambda$containingElementToBe$2 : replaced boolean return with false for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$containingElementToBe$2 → NO_COVERAGE
2. lambda$containingElementToBe$2 : replaced boolean return with true for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$containingElementToBe$2 → NO_COVERAGE
3. containingElementToBe : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::containingElementToBe → KILLED
    return predicate(Printables.predicate("containingElementToBe[" + predicate + "]", l -> l.stream().anyMatch(predicate)));
43
  }
44
45
  default ListChecker<T, E> containing(E element) {
46 1 1. containing : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::containing → KILLED
    return checkWithPredicate(Predicates.contains(element));
47
  }
48
  
49
  @SuppressWarnings("unchecked")
50
  default ListChecker<T, E> containingElementsInOrder(List<Predicate<E>> predicates) {
51 1 1. containingElementsInOrder : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::containingElementsInOrder → KILLED
    return checkWithPredicate(Cursors.findElements(predicates.toArray(new Predicate[0])));
52
  }
53
  
54
  @SuppressWarnings("unchecked")
55
  default ListChecker<T, E> containingElementsInOrder(E... elements) {
56 1 1. containingElementsInOrder : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::containingElementsInOrder → KILLED
    return this.containingElementsInOrder(
57
        Arrays.stream(elements)
58 3 1. lambda$containingElementsInOrder$4 : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$containingElementsInOrder$4 → SURVIVED
2. lambda$null$3 : replaced boolean return with false for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$null$3 → NO_COVERAGE
3. lambda$null$3 : replaced boolean return with true for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$null$3 → NO_COVERAGE
              .map(v -> Printables.predicate("[" + v + "]", e -> Objects.equals(v, e)))
59 1 1. lambda$containingElementsInOrder$5 : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$containingElementsInOrder$5 → SURVIVED
              .map(p -> (Predicate<E>) p)
60
              .collect(Collectors.toList()));
61
  }
62
  
63
  class Impl<
64
      T,
65
      E
66
      > extends Base<
67
      ListChecker<T, E>,
68
      T,
69
      List<E>> implements
70
      ListChecker<T, E> {
71
    public Impl(Supplier<T> rootValue, Function<T, List<E>> transformFunction) {
72
      super(rootValue, transformFunction);
73
    }
74
    
75
    @Override
76
    protected ListChecker<List<E>, E> rebase() {
77 1 1. rebase : replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker$Impl::rebase → SURVIVED
      return new Impl<>(this::value, InternalUtils.trivialIdentityFunction());
78
    }
79
  }
80
}

Mutations

26

1.1
Location : empty
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[52: Given:<"A:B">:When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::empty → KILLED

30

1.1
Location : notEmpty
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[52: Given:<"A:B">:When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::notEmpty → KILLED

34

1.1
Location : firstElementToBe
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[52: Given:<"A:B">:When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::firstElementToBe → KILLED

2.2
Location : lambda$firstElementToBe$0
Killed by : none
replaced boolean return with false for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$firstElementToBe$0 → NO_COVERAGE

3.3
Location : lambda$firstElementToBe$0
Killed by : none
replaced boolean return with true for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$firstElementToBe$0 → NO_COVERAGE

38

1.1
Location : lambda$lastElementToBe$1
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

2.2
Location : lambda$lastElementToBe$1
Killed by : none
replaced boolean return with false for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$lastElementToBe$1 → NO_COVERAGE

3.3
Location : lambda$lastElementToBe$1
Killed by : none
replaced boolean return with true for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$lastElementToBe$1 → NO_COVERAGE

4.4
Location : lastElementToBe
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[52: Given:<"A:B">:When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lastElementToBe → KILLED

42

1.1
Location : containingElementToBe
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[52: Given:<"A:B">:When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::containingElementToBe → KILLED

2.2
Location : lambda$containingElementToBe$2
Killed by : none
replaced boolean return with false for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$containingElementToBe$2 → NO_COVERAGE

3.3
Location : lambda$containingElementToBe$2
Killed by : none
replaced boolean return with true for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$containingElementToBe$2 → NO_COVERAGE

46

1.1
Location : containing
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[52: Given:<"A:B">:When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::containing → KILLED

51

1.1
Location : containingElementsInOrder
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[52: Given:<"A:B">:When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::containingElementsInOrder → KILLED

56

1.1
Location : containingElementsInOrder
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[52: Given:<"A:B">:When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::containingElementsInOrder → KILLED

58

1.1
Location : lambda$containingElementsInOrder$4
Killed by : none
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$containingElementsInOrder$4 → SURVIVED

2.2
Location : lambda$null$3
Killed by : none
replaced boolean return with false for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$null$3 → NO_COVERAGE

3.3
Location : lambda$null$3
Killed by : none
replaced boolean return with true for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$null$3 → NO_COVERAGE

59

1.1
Location : lambda$containingElementsInOrder$5
Killed by : none
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker::lambda$containingElementsInOrder$5 → SURVIVED

77

1.1
Location : rebase
Killed by : none
replaced return value with null for com/github/valid8j/pcond/core/fluent/builtins/ListChecker$Impl::rebase → SURVIVED

Active mutators

Tests examined


Report generated by PIT 1.7.3