@Test public void testValidateOptions() { TransformingIterator ti = new ColFamReversingKeyTransformingIterator(); IteratorSetting is = new IteratorSetting(100, "cfrkt", ColFamReversingKeyTransformingIterator.class); TransformingIterator.setAuthorizations(is, new Authorizations("A", "B")); TransformingIterator.setMaxBufferSize(is, 10000000); assertTrue(ti.validateOptions(is.getOptions())); Map<String,String> opts = new HashMap<>(); opts.put(TransformingIterator.MAX_BUFFER_SIZE_OPT, "10M"); assertTrue(ti.validateOptions(is.getOptions())); opts.clear(); opts.put(TransformingIterator.MAX_BUFFER_SIZE_OPT, "A,B"); try { ti.validateOptions(opts); fail(); } catch (IllegalArgumentException e) {} opts.clear(); opts.put(TransformingIterator.AUTH_OPT, Authorizations.HEADER + "~~~~"); try { ti.validateOptions(opts); fail(); } catch (IllegalArgumentException e) {} }
@Override public boolean validateOptions(Map<String,String> options) { for (Entry<String,String> option : options.entrySet()) { try { if (option.getKey().equals(AUTH_OPT)) { new Authorizations(option.getValue().getBytes(UTF_8)); } else if (option.getKey().equals(MAX_BUFFER_SIZE_OPT)) { ConfigurationTypeHelper.getFixedMemoryAsBytes(option.getValue()); } } catch (Exception e) { throw new IllegalArgumentException( "Failed to parse opt " + option.getKey() + " " + option.getValue(), e); } } return true; }
TransformingIterator extends WrappingIterator implements OptionDescriber { @Override public boolean validateOptions(Map<String,String> options) { for (Entry<String,String> option : options.entrySet()) { try { if (option.getKey().equals(AUTH_OPT)) { new Authorizations(option.getValue().getBytes(UTF_8)); } else if (option.getKey().equals(MAX_BUFFER_SIZE_OPT)) { ConfigurationTypeHelper.getFixedMemoryAsBytes(option.getValue()); } } catch (Exception e) { throw new IllegalArgumentException( "Failed to parse opt " + option.getKey() + " " + option.getValue(), e); } } return true; } }
TransformingIterator extends WrappingIterator implements OptionDescriber { @Override public boolean validateOptions(Map<String,String> options) { for (Entry<String,String> option : options.entrySet()) { try { if (option.getKey().equals(AUTH_OPT)) { new Authorizations(option.getValue().getBytes(UTF_8)); } else if (option.getKey().equals(MAX_BUFFER_SIZE_OPT)) { ConfigurationTypeHelper.getFixedMemoryAsBytes(option.getValue()); } } catch (Exception e) { throw new IllegalArgumentException( "Failed to parse opt " + option.getKey() + " " + option.getValue(), e); } } return true; }  }
TransformingIterator extends WrappingIterator implements OptionDescriber { @Override public boolean validateOptions(Map<String,String> options) { for (Entry<String,String> option : options.entrySet()) { try { if (option.getKey().equals(AUTH_OPT)) { new Authorizations(option.getValue().getBytes(UTF_8)); } else if (option.getKey().equals(MAX_BUFFER_SIZE_OPT)) { ConfigurationTypeHelper.getFixedMemoryAsBytes(option.getValue()); } } catch (Exception e) { throw new IllegalArgumentException( "Failed to parse opt " + option.getKey() + " " + option.getValue(), e); } } return true; }  @Override void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options,
      IteratorEnvironment env); @Override IteratorOptions describeOptions(); @Override boolean validateOptions(Map<String,String> options); @Override SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env); @Override boolean hasTop(); @Override Key getTopKey(); @Override Value getTopValue(); @Override void next(); @Override void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive); static void setAuthorizations(IteratorSetting config, Authorizations auths); static void setMaxBufferSize(IteratorSetting config, long maxBufferSize); }
TransformingIterator extends WrappingIterator implements OptionDescriber { @Override public boolean validateOptions(Map<String,String> options) { for (Entry<String,String> option : options.entrySet()) { try { if (option.getKey().equals(AUTH_OPT)) { new Authorizations(option.getValue().getBytes(UTF_8)); } else if (option.getKey().equals(MAX_BUFFER_SIZE_OPT)) { ConfigurationTypeHelper.getFixedMemoryAsBytes(option.getValue()); } } catch (Exception e) { throw new IllegalArgumentException( "Failed to parse opt " + option.getKey() + " " + option.getValue(), e); } } return true; }  @Override void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options,
      IteratorEnvironment env); @Override IteratorOptions describeOptions(); @Override boolean validateOptions(Map<String,String> options); @Override SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env); @Override boolean hasTop(); @Override Key getTopKey(); @Override Value getTopValue(); @Override void next(); @Override void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive); static void setAuthorizations(IteratorSetting config, Authorizations auths); static void setMaxBufferSize(IteratorSetting config, long maxBufferSize); static final String AUTH_OPT; static final String MAX_BUFFER_SIZE_OPT; }