Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unnecessary method from ingesthelper and clean test pt2 #2116

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;

import org.apache.hadoop.conf.Configuration;
import org.apache.log4j.Logger;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Sets;

import datawave.ingest.data.config.FieldConfigHelper;

Expand Down Expand Up @@ -69,7 +67,7 @@ private static Collection<String> trimConfigStrings(Configuration config, String
String[] names = datawave.util.StringUtils.split(c, ',');
for (String n : names) {
n = n.trim();
if (n.equals(""))
if (n.isEmpty())
continue;

s.add(n);
Expand Down Expand Up @@ -179,25 +177,4 @@ public String getRawDocumentViewName() {
return rawDocumentViewName;
}

public static Set<String> parseMultiLineConfigValue(String s, Pattern splitter) {
return cleanSet(Sets.newHashSet(splitter.split(s)));
}

/**
* Utility method to take a {@code String[]} and return a {@code Set<String>} where the values are trimmed
*
* @param items
* String[] of items to trim and turn into a set
* @return unique Set of strings where whitespace has been trimmed.
*/
public static Set<String> cleanSet(Collection<String> items) {
Set<String> itemSet = new HashSet<>();
for (String item : items) {
item = item.trim();
if (!item.isEmpty()) {
itemSet.add(item);
}
}
return itemSet;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,34 @@ public void testIteratorStackSetup() throws Exception {

// Top of the stack is a ConfigurableVisibilityFilter (which creates a VisibilityFilter as its source) with auths C1,C2,C3
assertEquals(ConfigurableVisibilityFilter.class, internalIter.getClass());
cvf = ConfigurableVisibilityFilter.class.cast(internalIter);
cvf = (ConfigurableVisibilityFilter) internalIter;
source = Whitebox.getInternalState(cvf, "source");
assertEquals(VisibilityFilter.class, source.getClass());
vf = VisibilityFilter.class.cast(source);
vf = (VisibilityFilter) source;
actualAuths = new TreeSet<>(Arrays.asList(Whitebox.getInternalState(vf, Authorizations.class).toString().split(",")));
assertEquals(new TreeSet<>(Arrays.asList("C1", "C2", "C3")), actualAuths);
source = Whitebox.getInternalState(vf, "source");

// Next on the stack is a ConfigurableVisibilityFilter (which creates a VisibilityFilter as its source) with auths B1,B2,B3
assertEquals(ConfigurableVisibilityFilter.class, source.getClass());
cvf = ConfigurableVisibilityFilter.class.cast(source);
cvf = (ConfigurableVisibilityFilter) source;
source = Whitebox.getInternalState(cvf, "source");
assertEquals(VisibilityFilter.class, source.getClass());
vf = VisibilityFilter.class.cast(source);
vf = (VisibilityFilter) source;
actualAuths = new TreeSet<>(Arrays.asList(Whitebox.getInternalState(vf, Authorizations.class).toString().split(",")));
assertEquals(new TreeSet<>(Arrays.asList("B1", "B2", "B3")), actualAuths);
source = Whitebox.getInternalState(vf, "source");

// The next table iterator should be the standard VisibilityFilter which will have auths A1,A2,A3
assertEquals(VisibilityFilter.class, source.getClass());
vf = VisibilityFilter.class.cast(source);
vf = (VisibilityFilter) source;
actualAuths = new TreeSet<>(Arrays.asList(Whitebox.getInternalState(vf, Authorizations.class).toString().split(",")));
assertEquals(new TreeSet<>(Arrays.asList("A1", "A2", "A3")), actualAuths);
source = Whitebox.getInternalState(vf, "source");

// The next table iterator should be a DeletingIterator
assertEquals(DeletingIterator.class, source.getClass());
DeletingIterator di = DeletingIterator.class.cast(source);
DeletingIterator di = (DeletingIterator) source;
source = Whitebox.getInternalState(di, "source");

// And finally, at the bottom of the stack is a MultiIterator (which has no source field)
Expand Down
Loading
Loading