@Test public void test_exclude_returns_null_when_null_submitted_without_default() { ParameterReader<Pattern> excludeFromAutoEnrollmentReader = factory .buildExcludeFromAutoEnrollmentReader(); Pattern withoutDefault = excludeFromAutoEnrollmentReader.readParameter(null, true); assertThat(withoutDefault, is(nullValue())); }
@Bean(name = Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT) public ParameterReader<Pattern> buildExcludeFromAutoEnrollmentReader() { return new ParameterReader<Pattern>() { @Override public String getParameterName() { return Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT; } @Override public Pattern readParameter(Object parameter, boolean withDefault) throws InvalidParameterException { if (parameter != null) { String excludeNamesStr = (String) parameter; if (!excludeNamesStr.trim().equals("")) { log.debug("excludeFromAutoEnrollment " + excludeNamesStr); try { return Pattern.compile(excludeNamesStr); } catch (PatternSyntaxException p) { log.error("Wrong format for exclusion - format cannot be compiled to a valid regexp"); throw new InvalidParameterException( Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT, "should be a valid regexp"); } } else { return null; } } else { return null; } } }; }
ParameterReaderFactory { @Bean(name = Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT) public ParameterReader<Pattern> buildExcludeFromAutoEnrollmentReader() { return new ParameterReader<Pattern>() { @Override public String getParameterName() { return Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT; } @Override public Pattern readParameter(Object parameter, boolean withDefault) throws InvalidParameterException { if (parameter != null) { String excludeNamesStr = (String) parameter; if (!excludeNamesStr.trim().equals("")) { log.debug("excludeFromAutoEnrollment " + excludeNamesStr); try { return Pattern.compile(excludeNamesStr); } catch (PatternSyntaxException p) { log.error("Wrong format for exclusion - format cannot be compiled to a valid regexp"); throw new InvalidParameterException( Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT, "should be a valid regexp"); } } else { return null; } } else { return null; } } }; } }
ParameterReaderFactory { @Bean(name = Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT) public ParameterReader<Pattern> buildExcludeFromAutoEnrollmentReader() { return new ParameterReader<Pattern>() { @Override public String getParameterName() { return Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT; } @Override public Pattern readParameter(Object parameter, boolean withDefault) throws InvalidParameterException { if (parameter != null) { String excludeNamesStr = (String) parameter; if (!excludeNamesStr.trim().equals("")) { log.debug("excludeFromAutoEnrollment " + excludeNamesStr); try { return Pattern.compile(excludeNamesStr); } catch (PatternSyntaxException p) { log.error("Wrong format for exclusion - format cannot be compiled to a valid regexp"); throw new InvalidParameterException( Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT, "should be a valid regexp"); } } else { return null; } } else { return null; } } }; }  }
ParameterReaderFactory { @Bean(name = Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT) public ParameterReader<Pattern> buildExcludeFromAutoEnrollmentReader() { return new ParameterReader<Pattern>() { @Override public String getParameterName() { return Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT; } @Override public Pattern readParameter(Object parameter, boolean withDefault) throws InvalidParameterException { if (parameter != null) { String excludeNamesStr = (String) parameter; if (!excludeNamesStr.trim().equals("")) { log.debug("excludeFromAutoEnrollment " + excludeNamesStr); try { return Pattern.compile(excludeNamesStr); } catch (PatternSyntaxException p) { log.error("Wrong format for exclusion - format cannot be compiled to a valid regexp"); throw new InvalidParameterException( Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT, "should be a valid regexp"); } } else { return null; } } else { return null; } } }; }  @Bean(name = Config.ServiceInstanceParameters.AUTO_ENROLLMENT) ParameterReader<Enrollment> buildAutoEnrollmentReader(); @Bean(name = Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT) ParameterReader<Pattern> buildExcludeFromAutoEnrollmentReader(); @Bean(name = Config.ServiceInstanceParameters.IDLE_DURATION) ParameterReader<Duration> buildIdleDurationReader(); @Bean(name = ServiceInstanceParameters.IGNORE_ROUTE_SERVICE_ERROR) ParameterReader<Boolean> buildIgnoreRouteServiceErrorReader(); @Bean(name = Config.ServiceInstanceParameters.SECRET) ParameterReader<String> buildSecretReader(); @Bean(name = EnrollmentConfig.EnrollmentParameters.STATE) ParameterReader<EnrollmentState> buildEnrollmentStateReader(); }
ParameterReaderFactory { @Bean(name = Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT) public ParameterReader<Pattern> buildExcludeFromAutoEnrollmentReader() { return new ParameterReader<Pattern>() { @Override public String getParameterName() { return Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT; } @Override public Pattern readParameter(Object parameter, boolean withDefault) throws InvalidParameterException { if (parameter != null) { String excludeNamesStr = (String) parameter; if (!excludeNamesStr.trim().equals("")) { log.debug("excludeFromAutoEnrollment " + excludeNamesStr); try { return Pattern.compile(excludeNamesStr); } catch (PatternSyntaxException p) { log.error("Wrong format for exclusion - format cannot be compiled to a valid regexp"); throw new InvalidParameterException( Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT, "should be a valid regexp"); } } else { return null; } } else { return null; } } }; }  @Bean(name = Config.ServiceInstanceParameters.AUTO_ENROLLMENT) ParameterReader<Enrollment> buildAutoEnrollmentReader(); @Bean(name = Config.ServiceInstanceParameters.EXCLUDE_FROM_AUTO_ENROLLMENT) ParameterReader<Pattern> buildExcludeFromAutoEnrollmentReader(); @Bean(name = Config.ServiceInstanceParameters.IDLE_DURATION) ParameterReader<Duration> buildIdleDurationReader(); @Bean(name = ServiceInstanceParameters.IGNORE_ROUTE_SERVICE_ERROR) ParameterReader<Boolean> buildIgnoreRouteServiceErrorReader(); @Bean(name = Config.ServiceInstanceParameters.SECRET) ParameterReader<String> buildSecretReader(); @Bean(name = EnrollmentConfig.EnrollmentParameters.STATE) ParameterReader<EnrollmentState> buildEnrollmentStateReader();  }