Skip to content
Permalink
Browse files

Step 6: Obtained Coverage

  • Loading branch information...
tlinkowski committed Jan 31, 2019
1 parent 6240a59 commit 274dedbccde45aaa0aad0cf2aa2955e69b3859f8
Showing with 7 additions and 9 deletions.
  1. +2 −2 IssueCoverage.java
  2. +1 −3 IssueDetector.java
  3. +2 −2 IssueWiseText.java
  4. +2 −2 Usage.java
@@ -1,7 +1,7 @@
import java.util.stream.Collector;

class IssueCoverage {
static Collector<IssueWiseText, ?, Double> collector() {
static Collector<IssueWiseText<?>, ?, Double> collector() {
return Collector.of(
Accumulator::new, Accumulator::accumulate, Accumulator::combine, Accumulator::finish,
Collector.Characteristics.UNORDERED
@@ -12,7 +12,7 @@
int totalIssueLength = 0;
int totalTextLength = 0;

void accumulate(IssueWiseText issueWiseText) {
void accumulate(IssueWiseText<?> issueWiseText) {
totalIssueLength += issueWiseText.issues().stream().mapToInt(Issue::length).sum();
totalTextLength += issueWiseText.text().length();
}
@@ -1,6 +1,4 @@
import java.util.List;

interface IssueDetector {
// e.g. text: "You migth know it.", probabilityThreshold: 0.75
List<ProbableIssue> detect(String text, double probabilityThreshold);
IssueWiseText<ProbableIssue> detect(String text, double probabilityThreshold);
}
@@ -1,7 +1,7 @@
import java.util.List;

interface IssueWiseText {
interface IssueWiseText<I extends Issue> {
String text(); // e.g. "You migth know it."

List<Issue> issues(); // e.g. ["migth"]
List<I> issues(); // e.g. ["migth"]
}
@@ -1,11 +1,11 @@
import java.util.stream.Stream;

class Usage {
static double issueCoverage(Stream<? extends IssueWiseText> textStream) {
static double issueCoverage(Stream<? extends IssueWiseText<?>> textStream) {
return textStream.collect(IssueCoverage.collector());
}

static Stream<IssueWiseText> testCaseStream() {
static Stream<IssueWiseText<Issue>> testCaseStream() {
return Stream.of();
}
}

0 comments on commit 274dedb

Please sign in to comment.
You can’t perform that action at this time.