Skip to content

Commit

Permalink
Adding value
Browse files Browse the repository at this point in the history
  • Loading branch information
josdem committed Apr 28, 2024
2 parents 9ea0142 + b44a0f4 commit c779ad1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.josdem.kata;

public record CustomInputStream(int id) implements Comparable<CustomInputStream> {

public record CustomInputStream(int id, String value) implements Comparable<CustomInputStream> {
@Override
public int compareTo(CustomInputStream that) {
return Integer.compare(this.id, that.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
public class CustomOutputStream {
private final Logger log = Logger.getLogger(this.getClass().getName());

void storeValue(int value) {
log.info("value: " + value);
void emitValue(String value) {
log.info(value);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public record StreamMerger(Set<CustomInputStream> streams) {

public Set<CustomInputStream> mergeInto(CustomOutputStream stream) {
TreeSet<CustomInputStream> treeSet = new TreeSet<>(streams);
treeSet.forEach(item -> stream.storeValue(item.id()));
treeSet.forEach(item -> stream.emitValue(item.value()));
return treeSet;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class StreamMergerTest {
@Test
@DisplayName("getting an ordered stream collection")
void shouldGetOrderedStreamCollection() {
CustomInputStream cst1 = new CustomInputStream(2);
CustomInputStream cst2 = new CustomInputStream(1);
CustomInputStream cst3 = new CustomInputStream(0);
CustomInputStream cst1 = new CustomInputStream(2, "awesome!");
CustomInputStream cst2 = new CustomInputStream(1, "is");
CustomInputStream cst3 = new CustomInputStream(0, "This");

Set<CustomInputStream> streams = new HashSet<>();
streams.add(cst1);
Expand Down

0 comments on commit c779ad1

Please sign in to comment.