mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-02-20 21:44:23 +01:00
add convenience method
This commit is contained in:
@@ -45,12 +45,8 @@ public class NodeWarningsService {
|
||||
.map(LocalChannel::getRemotePubkey)
|
||||
.distinct()
|
||||
.map(pubkey -> new AbstractMap.SimpleEntry<>(pubkey, getNodeWarnings(pubkey)))
|
||||
.filter(this::hasWarnings)
|
||||
.filter(entry -> entry.getValue().hasWarnings())
|
||||
.map(entry -> new AbstractMap.SimpleEntry<>(nodeService.getNode(entry.getKey()), entry.getValue()))
|
||||
.collect(toMap(Entry::getKey, Entry::getValue));
|
||||
}
|
||||
|
||||
private boolean hasWarnings(Entry<?, NodeWarnings> entry) {
|
||||
return !entry.getValue().warnings().isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,8 @@ public record NodeWarnings(Set<NodeWarning> warnings) {
|
||||
public Set<String> descriptions() {
|
||||
return warnings.stream().map(NodeWarning::description).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public boolean hasWarnings() {
|
||||
return !warnings.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,4 +33,14 @@ class NodeWarningsTest {
|
||||
void none() {
|
||||
assertThat(NodeWarnings.NONE).isEqualTo(new NodeWarnings(Set.of()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasWarnings_empty() {
|
||||
assertThat(NodeWarnings.NONE.hasWarnings()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasWarnings_several_warnings() {
|
||||
assertThat(NODE_WARNINGS.hasWarnings()).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user