Java to Beanshell: validate an attribute for each record of a spreadsheet
A few things come to mind:


In Java 9 one can use Set.of("X", "Y", ...).
Or could simplify to private static final Set&lt;String&gt; VALID_DEPARTMENTS = new HashSet&lt;&gt;(Arrays.asList("A", "B"));
Could modify validate(dep) to return set.contains(dep) ? dep : null;
It would be nice to return "" instead of null if at all possible.  This is so that a project won't end up with tons of if (x != null) all over the place.
Recommend renaming Test to something more descriptive.  Maybe DepartmentValidator might be a step in the right direction.
Probably refactor dep to department.  Eventually the meaning may become less obvious as time passes and the code base grows larger.
Note: the validation is currently quite strict (exact match), so I'm assuming the incoming data is pretty exact (no misspellings or different capitalization, etc.)