@Test public void shouldInsertLightParameterEntriesIntoIndexWhenParameterHasNoIdentifyEntriesFlagSet() { Level[] levels = new Level[]{ level().withName("outputLevel").withType("type").build() }; ParameterEntry[] entries = new ParameterEntry[]{ parameterEntry().withLevels("hello").build() }; Parameter parameter = parameter().withName("param").withInputLevels(0) .withLevels(levels).withEntries(entries).build(); when(levelPreparer.prepare(any(Level.class))).thenReturn(preparedLevel().build()).thenReturn(preparedLevel().withName("outputLevel").build()); PreparedParameter preparedParameter = paramPreparer.prepare(new ParameterFromRepository(parameter, RepositoryName.from("test"))); FastLevelIndexWalker<PreparedEntry> walker = new FastLevelIndexWalker<PreparedEntry>(preparedParameter.getIndex()); assertThat(walker.find().get(0)).isExactlyInstanceOf(PreparedEntry.class); }
@Override public PreparedParameter prepare(ParameterFromRepository parameterFromRepository) { Parameter parameter = parameterFromRepository.parameter(); int levelCount = getLevelCount(parameter); PreparedLevel[] levels = new PreparedLevel[levelCount]; Type<?>[] types = new Type<?>[levelCount]; Matcher[] matchers = new Matcher[levelCount]; for (int currentLevelIndex = 0; currentLevelIndex < levelCount; currentLevelIndex++) { Level level = getLevel(parameter, currentLevelIndex); PreparedLevel preparedLevel = levelPreparer.prepare(level); levels[currentLevelIndex] = preparedLevel; types[currentLevelIndex] = preparedLevel.getType(); matchers[currentLevelIndex] = preparedLevel.getMatcher(); } PreparedParameter preparedParameter = new PreparedParameter(parameterFromRepository.repositoryName(), parameter, levels); preparedParameter.setLevelNameMap(buildLevelNameToIndexMap(preparedParameter)); if (parameter.isCacheable()) { preparedParameter.setIndex(buildIndex(parameter, types, matchers)); } return preparedParameter; }
BasicParamPreparer implements ParamPreparer { @Override public PreparedParameter prepare(ParameterFromRepository parameterFromRepository) { Parameter parameter = parameterFromRepository.parameter(); int levelCount = getLevelCount(parameter); PreparedLevel[] levels = new PreparedLevel[levelCount]; Type<?>[] types = new Type<?>[levelCount]; Matcher[] matchers = new Matcher[levelCount]; for (int currentLevelIndex = 0; currentLevelIndex < levelCount; currentLevelIndex++) { Level level = getLevel(parameter, currentLevelIndex); PreparedLevel preparedLevel = levelPreparer.prepare(level); levels[currentLevelIndex] = preparedLevel; types[currentLevelIndex] = preparedLevel.getType(); matchers[currentLevelIndex] = preparedLevel.getMatcher(); } PreparedParameter preparedParameter = new PreparedParameter(parameterFromRepository.repositoryName(), parameter, levels); preparedParameter.setLevelNameMap(buildLevelNameToIndexMap(preparedParameter)); if (parameter.isCacheable()) { preparedParameter.setIndex(buildIndex(parameter, types, matchers)); } return preparedParameter; } }
BasicParamPreparer implements ParamPreparer { @Override public PreparedParameter prepare(ParameterFromRepository parameterFromRepository) { Parameter parameter = parameterFromRepository.parameter(); int levelCount = getLevelCount(parameter); PreparedLevel[] levels = new PreparedLevel[levelCount]; Type<?>[] types = new Type<?>[levelCount]; Matcher[] matchers = new Matcher[levelCount]; for (int currentLevelIndex = 0; currentLevelIndex < levelCount; currentLevelIndex++) { Level level = getLevel(parameter, currentLevelIndex); PreparedLevel preparedLevel = levelPreparer.prepare(level); levels[currentLevelIndex] = preparedLevel; types[currentLevelIndex] = preparedLevel.getType(); matchers[currentLevelIndex] = preparedLevel.getMatcher(); } PreparedParameter preparedParameter = new PreparedParameter(parameterFromRepository.repositoryName(), parameter, levels); preparedParameter.setLevelNameMap(buildLevelNameToIndexMap(preparedParameter)); if (parameter.isCacheable()) { preparedParameter.setIndex(buildIndex(parameter, types, matchers)); } return preparedParameter; } BasicParamPreparer(LevelPreparer levelPreparer); }
BasicParamPreparer implements ParamPreparer { @Override public PreparedParameter prepare(ParameterFromRepository parameterFromRepository) { Parameter parameter = parameterFromRepository.parameter(); int levelCount = getLevelCount(parameter); PreparedLevel[] levels = new PreparedLevel[levelCount]; Type<?>[] types = new Type<?>[levelCount]; Matcher[] matchers = new Matcher[levelCount]; for (int currentLevelIndex = 0; currentLevelIndex < levelCount; currentLevelIndex++) { Level level = getLevel(parameter, currentLevelIndex); PreparedLevel preparedLevel = levelPreparer.prepare(level); levels[currentLevelIndex] = preparedLevel; types[currentLevelIndex] = preparedLevel.getType(); matchers[currentLevelIndex] = preparedLevel.getMatcher(); } PreparedParameter preparedParameter = new PreparedParameter(parameterFromRepository.repositoryName(), parameter, levels); preparedParameter.setLevelNameMap(buildLevelNameToIndexMap(preparedParameter)); if (parameter.isCacheable()) { preparedParameter.setIndex(buildIndex(parameter, types, matchers)); } return preparedParameter; } BasicParamPreparer(LevelPreparer levelPreparer); @Override PreparedParameter prepare(ParameterFromRepository parameterFromRepository); @Override PreparedEntry prepareIdentifiableEntry(ParameterEntry parameterEntry); }
BasicParamPreparer implements ParamPreparer { @Override public PreparedParameter prepare(ParameterFromRepository parameterFromRepository) { Parameter parameter = parameterFromRepository.parameter(); int levelCount = getLevelCount(parameter); PreparedLevel[] levels = new PreparedLevel[levelCount]; Type<?>[] types = new Type<?>[levelCount]; Matcher[] matchers = new Matcher[levelCount]; for (int currentLevelIndex = 0; currentLevelIndex < levelCount; currentLevelIndex++) { Level level = getLevel(parameter, currentLevelIndex); PreparedLevel preparedLevel = levelPreparer.prepare(level); levels[currentLevelIndex] = preparedLevel; types[currentLevelIndex] = preparedLevel.getType(); matchers[currentLevelIndex] = preparedLevel.getMatcher(); } PreparedParameter preparedParameter = new PreparedParameter(parameterFromRepository.repositoryName(), parameter, levels); preparedParameter.setLevelNameMap(buildLevelNameToIndexMap(preparedParameter)); if (parameter.isCacheable()) { preparedParameter.setIndex(buildIndex(parameter, types, matchers)); } return preparedParameter; } BasicParamPreparer(LevelPreparer levelPreparer); @Override PreparedParameter prepare(ParameterFromRepository parameterFromRepository); @Override PreparedEntry prepareIdentifiableEntry(ParameterEntry parameterEntry);  }