Skip to content

Commit

Permalink
errorprone fixes for PreferredInterfaceType
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-mlb committed May 19, 2024
1 parent 58d57d7 commit 7976da8
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/java/emissary/output/filter/JsonOutputFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected boolean includeParameter(String key) {
}

protected Collection<Object> filter(String key, Collection<Object> values) {
Collection<Object> keep = new TreeSet<>();
Set<Object> keep = new TreeSet<>();
for (final Object value : values) {
if (!(denylistValues.containsKey(key) && denylistValues.get(key).contains(value.toString()))) {
keep.add(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public void close() throws IOException {
}
}

@SuppressWarnings("PreferredInterfaceType")
public static Collection<Path> getJournalPaths(Path dir) throws IOException {
ArrayList<Path> paths = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*" + EXT)) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/emissary/config/FTestServiceConfigGuide.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;

import static emissary.util.io.UnitTestFileUtils.findFilesByExtension;
Expand All @@ -27,7 +27,7 @@ public static Stream<? extends Arguments> data() throws IOException, EmissaryExc
ConfigUtil.initialize();

// look in config dir
Collection<Path> configFiles = new ArrayList<>();
List<Path> configFiles = new ArrayList<>();

for (String dir : ConfigUtil.getConfigDirs()) {
configFiles.addAll(findFilesByExtension(Paths.get(dir), ".cfg"));
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/emissary/core/BaseDataObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import ch.qos.logback.classic.Level;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ListMultimap;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -818,7 +818,7 @@ void testPutParametersWithPolicy() {

@Test
void testPutParametersWithMultimapAsMap() {
final Multimap<String, String> map = ArrayListMultimap.create();
final ListMultimap<String, String> map = ArrayListMultimap.create();
map.put("ONE", "uno");
map.put("ONE", "ein");
map.put("ONE", "neo");
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/emissary/output/roller/journal/JournalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.jupiter.api.io.TempDir;

import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -47,7 +47,7 @@ void testLoadEntries() throws Exception {
long twoOffset = 0;
try (JournalReader instance = new JournalReader(this.tmpDir.resolve(uuid + Journal.EXT))) {
Journal j = instance.getJournal();
final Collection<JournalEntry> entries = j.getEntries();
final List<JournalEntry> entries = j.getEntries();
assertEquals(4, entries.size(), "Expected 4 entries but was " + entries.size());
for (final JournalEntry entry : entries) {
if ((uuid + "-1").equals(entry.getVal())) {
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/emissary/test/core/junit5/ExtractionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
Expand Down Expand Up @@ -350,8 +349,8 @@ protected void checkStringValue(Element meta, String data, String tname) {
Attribute separatorAttribute = meta.getAttribute("collectionSeparator");
String separator = null != separatorAttribute ? separatorAttribute.getValue() : ","; // comma is default
// separator
Collection<String> expectedValues = Arrays.asList(value.split(separator));
Collection<String> actualValues = Arrays.asList(data.split(separator));
List<String> expectedValues = Arrays.asList(value.split(separator));
List<String> actualValues = Arrays.asList(data.split(separator));
assertTrue(CollectionUtils.isEqualCollection(expectedValues, actualValues),
String.format(
"%s element '%s' problem in %s did not have equal collection, value '%s' does not equal '%s' split by separator '%s'",
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/emissary/util/DataUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -34,7 +34,7 @@ void testPushDedupedForm() {
void testPushDedupedForms() {
final IBaseDataObject d = DataObjectFactory.getInstance();
// this has a duplicate value
final Collection<String> myforms = Arrays.asList("FOO", "FOO", "BAR");
final List<String> myforms = Arrays.asList("FOO", "FOO", "BAR");
DataUtil.pushDedupedForms(d, myforms);
assertTrue(d.getAllCurrentForms().contains("FOO"), "failed to add FOO");
assertTrue(d.getAllCurrentForms().contains("BAR"), "failed to add BAR");
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/emissary/util/io/UnitTestFileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ public static List<Path> findFilesWithRegex(Path path, String regex) throws Exce
return paths;
}

@SuppressWarnings("PreferredInterfaceType")
public static Collection<Path> findFilesByExtension(Path dir, String ext) throws IOException {
return findFilesByExtension(dir, ext, Integer.MAX_VALUE);
}

@SuppressWarnings("PreferredInterfaceType")
public static Collection<Path> findFilesByExtension(Path dir, String ext, int depth) throws IOException {
try (Stream<Path> walk = Files.find(dir, depth, (path, attrs) -> path.toString().endsWith(ext))) {
return walk.collect(Collectors.toList());
Expand Down

0 comments on commit 7976da8

Please sign in to comment.