@Test public void substitute() { @Nullable Optional<String> result = new ReplacingInterceptorVariableDictionary(testCase.request) .substitute(testCase.variableName); assertEquals("variable name found", testCase.expectNameValid, result != null); if (result != null) { String value = result.orElse(null); assertEquals("substituted value", testCase.expectedValueIfValid, value); } }
@Nullable @Override public Optional<String> substitute(String variableName) { try { @Nullable String substitution = substituteOrThrow(variableName); return Optional.ofNullable(substitution); } catch (UnknownVariableNameException e) { return null; } }
ReplacingInterceptorVariableDictionary implements VariableDictionary { @Nullable @Override public Optional<String> substitute(String variableName) { try { @Nullable String substitution = substituteOrThrow(variableName); return Optional.ofNullable(substitution); } catch (UnknownVariableNameException e) { return null; } } }
ReplacingInterceptorVariableDictionary implements VariableDictionary { @Nullable @Override public Optional<String> substitute(String variableName) { try { @Nullable String substitution = substituteOrThrow(variableName); return Optional.ofNullable(substitution); } catch (UnknownVariableNameException e) { return null; } } ReplacingInterceptorVariableDictionary(ParsedRequest request); }
ReplacingInterceptorVariableDictionary implements VariableDictionary { @Nullable @Override public Optional<String> substitute(String variableName) { try { @Nullable String substitution = substituteOrThrow(variableName); return Optional.ofNullable(substitution); } catch (UnknownVariableNameException e) { return null; } } ReplacingInterceptorVariableDictionary(ParsedRequest request); @Nullable @Override Optional<String> substitute(String variableName); }
ReplacingInterceptorVariableDictionary implements VariableDictionary { @Nullable @Override public Optional<String> substitute(String variableName) { try { @Nullable String substitution = substituteOrThrow(variableName); return Optional.ofNullable(substitution); } catch (UnknownVariableNameException e) { return null; } } ReplacingInterceptorVariableDictionary(ParsedRequest request); @Nullable @Override Optional<String> substitute(String variableName); static final String KEY_REQUEST_URL; static final String KEY_REQUEST_METHOD; static final String PREFIX_KEY_REQUEST_HEADER; static final String PREFIX_KEY_REQUEST_QUERY; }