[networkupstools] Some sat improvements (#10017)
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
This commit is contained in:
committed by
GitHub
parent
c4a3b1e6ba
commit
ff9454596e
@@ -16,8 +16,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -28,7 +29,6 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.core.library.CoreItemFactory;
|
||||
|
||||
@@ -121,7 +121,7 @@ public class NutNameChannelsTest {
|
||||
final String path = getClass().getProtectionDomain().getClassLoader().getResource(".").getFile() + "../..";
|
||||
|
||||
try {
|
||||
final List<String> lines = FileUtils.readLines(new File(path, "README.md"));
|
||||
final List<String> lines = Files.readAllLines(Paths.get(path, "README.md"));
|
||||
|
||||
return lines.stream().filter(line -> README_PATTERN.matcher(line).find())
|
||||
.collect(Collectors.toMap(this::lineToNutName, Function.identity()));
|
||||
@@ -135,7 +135,7 @@ public class NutNameChannelsTest {
|
||||
final String path = getClass().getProtectionDomain().getClassLoader().getResource(".").getFile()
|
||||
+ "../../src/main/resources/OH-INF/thing";
|
||||
try {
|
||||
final List<String> lines = FileUtils.readLines(new File(path, filename));
|
||||
final List<String> lines = Files.readAllLines(Paths.get(path, filename));
|
||||
return lines.stream().filter(line -> pattern.matcher(line).find()).map(String::trim).sorted()
|
||||
.collect(Collectors.toList());
|
||||
} catch (final IOException e) {
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -40,10 +39,14 @@ public class NutNameTest {
|
||||
|
||||
assertTrue(matcher.find(), "NutName name '" + nn + "' could not be matched with expected pattern.");
|
||||
final String expectedChannelId = matcher.group(1)
|
||||
+ StringUtils.capitalize(Optional.ofNullable(matcher.group(2)).orElse(""))
|
||||
+ StringUtils.capitalize(Optional.ofNullable(matcher.group(3)).orElse(""))
|
||||
+ StringUtils.capitalize(Optional.ofNullable(matcher.group(4)).orElse(""));
|
||||
+ capitalize(Optional.ofNullable(matcher.group(2)).orElse(""))
|
||||
+ capitalize(Optional.ofNullable(matcher.group(3)).orElse(""))
|
||||
+ capitalize(Optional.ofNullable(matcher.group(4)).orElse(""));
|
||||
assertEquals(expectedChannelId, nn.getChannelId(), "Channel name not correct");
|
||||
}
|
||||
}
|
||||
|
||||
private String capitalize(String s) {
|
||||
return s.isEmpty() ? "" : Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user