Merge pull request #22681 from biergit
* gh-22681: Polish "Look in correct context when finding Liquibase beans" Look in correct context when finding Liquibase beans Closes gh-22681
This commit is contained in:
commit
df198a0cd8
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -62,7 +62,7 @@ public class LiquibaseEndpoint {
|
||||||
while (target != null) {
|
while (target != null) {
|
||||||
Map<String, LiquibaseBean> liquibaseBeans = new HashMap<>();
|
Map<String, LiquibaseBean> liquibaseBeans = new HashMap<>();
|
||||||
DatabaseFactory factory = DatabaseFactory.getInstance();
|
DatabaseFactory factory = DatabaseFactory.getInstance();
|
||||||
this.context.getBeansOfType(SpringLiquibase.class)
|
target.getBeansOfType(SpringLiquibase.class)
|
||||||
.forEach((name, liquibase) -> liquibaseBeans.put(name, createReport(liquibase, factory)));
|
.forEach((name, liquibase) -> liquibaseBeans.put(name, createReport(liquibase, factory)));
|
||||||
ApplicationContext parent = target.getParent();
|
ApplicationContext parent = target.getParent();
|
||||||
contextBeans.put(target.getId(),
|
contextBeans.put(target.getId(),
|
||||||
|
|
|
@ -62,6 +62,17 @@ class LiquibaseEndpointTests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void liquibaseReportIsReturnedForContextHierarchy() {
|
||||||
|
this.contextRunner.withUserConfiguration().run((parent) -> {
|
||||||
|
this.contextRunner.withUserConfiguration(Config.class).withParent(parent).run((context) -> {
|
||||||
|
Map<String, LiquibaseBean> liquibaseBeans = context.getBean(LiquibaseEndpoint.class).liquibaseBeans()
|
||||||
|
.getContexts().get(parent.getId()).getLiquibaseBeans();
|
||||||
|
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void invokeWithCustomSchema() {
|
void invokeWithCustomSchema() {
|
||||||
this.contextRunner.withUserConfiguration(Config.class)
|
this.contextRunner.withUserConfiguration(Config.class)
|
||||||
|
|
Loading…
Reference in New Issue