53 ).collect(Collectors.toSet());
62 List<ConfigurationModule<?>> reversed =
new ArrayList<>(configModules);
63 Collections.reverse(reversed);
66 configModule.revert();
67 }
catch (Exception ex) {
69 logger.log(Level.SEVERE,
"An error occurred while reverting configuration module: " + configModule.getClass().getCanonicalName(), ex);
81 static String getProfileName(String caseName) {
82 return String.format(
"integrationTestProfile-%s", caseName);
95 getProfileName(caseName),
100 .collect(Collectors.toList())
114 Pair<IngestJobSettings, List<ConfigurationModule<?>>> runConfigurationModules(String caseName, List<ParameterizedResourceConfig> configModules) {
116 if (CollectionUtils.isEmpty(configModules)) {
121 IngestJobSettings curConfig =
new IngestJobSettings(
122 getProfileName(caseName),
124 Collections.emptyList());
126 List<ConfigurationModule<?>> configurationModuleCache =
new ArrayList<>();
129 for (ParameterizedResourceConfig configModule : configModules) {
130 Pair<IngestJobSettings, ConfigurationModule<?>> ingestResult =
runConfigurationModule(curConfig, configModule);
132 if (ingestResult !=
null) {
133 curConfig = ingestResult.first() ==
null ? curConfig : ingestResult.first();
134 if (ingestResult.second() !=
null) {
135 configurationModuleCache.add(ingestResult.second());
139 return Pair.of(curConfig, configurationModuleCache);
155 Class<?> clazz =
null;
158 }
catch (ClassNotFoundException ex) {
159 logger.log(Level.WARNING,
"Unable to find module: " + configModule.
getResource(), ex);
165 logger.log(Level.WARNING, String.format(
"%s does not seem to be an instance of a configuration module.", configModule.
getResource()));
170 Type configurationModuleType = Stream.of(clazz.getGenericInterfaces())
171 .filter(type -> type instanceof ParameterizedType && ((ParameterizedType) type).getRawType().equals(
ConfigurationModule.class))
172 .map(type -> ((ParameterizedType) type).getActualTypeArguments()[0])
176 if (configurationModuleType ==
null) {
177 logger.log(Level.SEVERE, String.format(
"Could not determine generic type of config module: %s", configModule.
getResource()));
183 Object result =
null;
186 Method m = clazz.getMethod(
"configure",
IngestJobSettings.class, (Class<?>) configurationModuleType);
188 }
catch (Exception ex) {
190 logger.log(Level.SEVERE, String.format(
"There was an error calling configure method on Configuration Module %s", configModule.
getResource()), ex);
198 logger.log(Level.SEVERE, String.format(
"Could not retrieve IngestJobSettings or null was returned from %s", configModule.
getResource()));