FixedFormatSpliterator.java

1
/*
2
 * Copyright 2004 the original author or authors.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.ancientprogramming.fixedformat4j.io.read;
17
18
import com.ancientprogramming.fixedformat4j.exception.FixedFormatIOException;
19
20
import java.io.BufferedReader;
21
import java.io.IOException;
22
import java.util.ArrayDeque;
23
import java.util.Spliterators;
24
import java.util.function.Consumer;
25
26
import static java.lang.String.format;
27
28
class FixedFormatSpliterator extends Spliterators.AbstractSpliterator<Object> {
29
30
  private final BufferedReader reader;
31
  private final FixedFormatLineProcessor processor;
32 2 1. <init> : Removed assignment to member variable buffer → KILLED
2. <init> : removed call to java/util/ArrayDeque::<init> → KILLED
  private final ArrayDeque<Object> buffer = new ArrayDeque<>();
33 2 1. <init> : Removed assignment to member variable lineNumber → SURVIVED
2. <init> : Substituted 0 with 1 → KILLED
  private long lineNumber = 0L;
34 2 1. <init> : Removed assignment to member variable exhausted → SURVIVED
2. <init> : Substituted 0 with 1 → KILLED
  private boolean exhausted = false;
35
36
  FixedFormatSpliterator(BufferedReader reader, FixedFormatLineProcessor processor) {
37 2 1. <init> : Substituted 272 with 273 → SURVIVED
2. <init> : Substituted 9223372036854775807 with -9223372036854775808 → SURVIVED
    super(Long.MAX_VALUE, ORDERED | NONNULL);
38 1 1. <init> : Removed assignment to member variable reader → KILLED
    this.reader = reader;
39 1 1. <init> : Removed assignment to member variable processor → KILLED
    this.processor = processor;
40
  }
41
42
  @Override
43
  public boolean tryAdvance(Consumer<? super Object> action) {
44 4 1. tryAdvance : removed conditional - replaced equality check with false → TIMED_OUT
2. tryAdvance : removed call to java/util/ArrayDeque::isEmpty → TIMED_OUT
3. tryAdvance : negated conditional → TIMED_OUT
4. tryAdvance : removed conditional - replaced equality check with true → KILLED
    while (buffer.isEmpty()) {
45 5 1. tryAdvance : replaced boolean return with true for com/ancientprogramming/fixedformat4j/io/read/FixedFormatSpliterator::tryAdvance → NO_COVERAGE
2. tryAdvance : Substituted 0 with 1 → NO_COVERAGE
3. tryAdvance : removed conditional - replaced equality check with false → SURVIVED
4. tryAdvance : negated conditional → KILLED
5. tryAdvance : removed conditional - replaced equality check with true → KILLED
      if (exhausted) return false;
46
      String line;
47
      try {
48 1 1. tryAdvance : removed call to java/io/BufferedReader::readLine → KILLED
        line = reader.readLine();
49
      } catch (IOException e) {
50 8 1. tryAdvance : Substituted 1 with 2 → KILLED
2. tryAdvance : removed call to com/ancientprogramming/fixedformat4j/exception/FixedFormatIOException::<init> → KILLED
3. tryAdvance : Substituted 1 with 0 → KILLED
4. tryAdvance : Replaced long addition with subtraction → KILLED
5. tryAdvance : replaced call to java/lang/String::format with argument → KILLED
6. tryAdvance : removed call to java/lang/String::format → KILLED
7. tryAdvance : Substituted 0 with 1 → KILLED
8. tryAdvance : removed call to java/lang/Long::valueOf → KILLED
        throw new FixedFormatIOException(format("IO error reading line %d", lineNumber + 1), e);
51
      }
52 3 1. tryAdvance : removed conditional - replaced equality check with true → KILLED
2. tryAdvance : negated conditional → KILLED
3. tryAdvance : removed conditional - replaced equality check with false → KILLED
      if (line == null) {
53 2 1. tryAdvance : Substituted 1 with 0 → SURVIVED
2. tryAdvance : Removed assignment to member variable exhausted → SURVIVED
        exhausted = true;
54 2 1. tryAdvance : Substituted 0 with 1 → SURVIVED
2. tryAdvance : replaced boolean return with true for com/ancientprogramming/fixedformat4j/io/read/FixedFormatSpliterator::tryAdvance → SURVIVED
        return false;
55
      }
56 5 1. tryAdvance : removed call to com/ancientprogramming/fixedformat4j/io/read/FixedFormatLineProcessor::processLine → KILLED
2. tryAdvance : Removed assignment to member variable lineNumber → KILLED
3. lambda$tryAdvance$0 : removed call to java/util/ArrayDeque::add → KILLED
4. tryAdvance : Substituted 1 with 2 → KILLED
5. tryAdvance : Replaced long addition with subtraction → KILLED
      processor.processLine(line, ++lineNumber, (clazz, record) -> buffer.add(record));
57
    }
58 2 1. tryAdvance : removed call to java/util/ArrayDeque::poll → TIMED_OUT
2. tryAdvance : removed call to java/util/function/Consumer::accept → KILLED
    action.accept(buffer.poll());
59 2 1. tryAdvance : Substituted 1 with 0 → KILLED
2. tryAdvance : replaced boolean return with false for com/ancientprogramming/fixedformat4j/io/read/FixedFormatSpliterator::tryAdvance → KILLED
    return true;
60
  }
61
}

Mutations

32

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_reader_emptyInput_returnsEmptyStream()]
Removed assignment to member variable buffer → KILLED

2.2
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_reader_emptyInput_returnsEmptyStream()]
removed call to java/util/ArrayDeque::<init> → KILLED

33

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
Substituted 0 with 1 → KILLED

2.2
Location : <init>
Killed by : none
Removed assignment to member variable lineNumber → SURVIVED
Covering tests

34

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
Substituted 0 with 1 → KILLED

2.2
Location : <init>
Killed by : none
Removed assignment to member variable exhausted → SURVIVED
Covering tests

37

1.1
Location : <init>
Killed by : none
Substituted 272 with 273 → SURVIVED
Covering tests

2.2
Location : <init>
Killed by : none
Substituted 9223372036854775807 with -9223372036854775808 → SURVIVED Covering tests

38

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_reader_emptyInput_returnsEmptyStream()]
Removed assignment to member variable reader → KILLED

39

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
Removed assignment to member variable processor → KILLED

44

1.1
Location : tryAdvance
Killed by : none
removed conditional - replaced equality check with false → TIMED_OUT

2.2
Location : tryAdvance
Killed by : none
removed call to java/util/ArrayDeque::isEmpty → TIMED_OUT

3.3
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
removed conditional - replaced equality check with true → KILLED

4.4
Location : tryAdvance
Killed by : none
negated conditional → TIMED_OUT

45

1.1
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
negated conditional → KILLED

2.2
Location : tryAdvance
Killed by : none
replaced boolean return with true for com/ancientprogramming/fixedformat4j/io/read/FixedFormatSpliterator::tryAdvance → NO_COVERAGE

3.3
Location : tryAdvance
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

4.4
Location : tryAdvance
Killed by : none
removed conditional - replaced equality check with false → SURVIVED
Covering tests

5.5
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
removed conditional - replaced equality check with true → KILLED

48

1.1
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
removed call to java/io/BufferedReader::readLine → KILLED

50

1.1
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
Substituted 1 with 2 → KILLED

2.2
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
removed call to com/ancientprogramming/fixedformat4j/exception/FixedFormatIOException::<init> → KILLED

3.3
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
Substituted 1 with 0 → KILLED

4.4
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
Replaced long addition with subtraction → KILLED

5.5
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
replaced call to java/lang/String::format with argument → KILLED

6.6
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
removed call to java/lang/String::format → KILLED

7.7
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
Substituted 0 with 1 → KILLED

8.8
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
removed call to java/lang/Long::valueOf → KILLED

52

1.1
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
removed conditional - replaced equality check with true → KILLED

2.2
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_reader_emptyInput_returnsEmptyStream()]
negated conditional → KILLED

3.3
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_reader_emptyInput_returnsEmptyStream()]
removed conditional - replaced equality check with false → KILLED

53

1.1
Location : tryAdvance
Killed by : none
Substituted 1 with 0 → SURVIVED
Covering tests

2.2
Location : tryAdvance
Killed by : none
Removed assignment to member variable exhausted → SURVIVED Covering tests

54

1.1
Location : tryAdvance
Killed by : none
Substituted 0 with 1 → SURVIVED
Covering tests

2.2
Location : tryAdvance
Killed by : none
replaced boolean return with true for com/ancientprogramming/fixedformat4j/io/read/FixedFormatSpliterator::tryAdvance → SURVIVED Covering tests

56

1.1
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
removed call to com/ancientprogramming/fixedformat4j/io/read/FixedFormatLineProcessor::processLine → KILLED

2.2
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
Removed assignment to member variable lineNumber → KILLED

3.3
Location : lambda$tryAdvance$0
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
removed call to java/util/ArrayDeque::add → KILLED

4.4
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
Substituted 1 with 2 → KILLED

5.5
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_ioErrorDuringRead_throwsFixedFormatIOExceptionWithLineNumber()]
Replaced long addition with subtraction → KILLED

58

1.1
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
removed call to java/util/function/Consumer::accept → KILLED

2.2
Location : tryAdvance
Killed by : none
removed call to java/util/ArrayDeque::poll → TIMED_OUT

59

1.1
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
Substituted 1 with 0 → KILLED

2.2
Location : tryAdvance
Killed by : com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.io.TestFixedFormatReaderOpenStream]/[method:openStream_parseErrorSkipAndLog_streamContinuesAfterErrorLine()]
replaced boolean return with false for com/ancientprogramming/fixedformat4j/io/read/FixedFormatSpliterator::tryAdvance → KILLED

Active mutators

Tests examined


Report generated by PIT 1.23.1 support