Skip to content

Commit de99810

Browse files
FelixTJDietrichFelix T.J. Dietrich
andauthored
test(server): fix the nullness NullAway 0.14.1 finds in three tests (#1823)
Co-authored-by: Felix T.J. Dietrich <felix.dietrich@financial-health-initiative.org>
1 parent 080091d commit de99810

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

server/application/src/test/java/de/tum/cit/aet/hephaestus/core/runtime/NoPerRequestAccessLogTest.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ void webappNginxDisablesTheAccessLogForTheWholeServerBlock() throws Exception {
5656

5757
@Test
5858
void maintenancePageNginxDisablesTheAccessLogForTheWholeServerBlock() throws Exception {
59-
String conf = propertyIn(PROXY_COMPOSE, "configs.nginx-default-config.content");
60-
61-
assertThat(conf)
62-
.as("docker/compose.proxy.yaml no longer inlines an nginx server config under that key")
63-
.isNotNull();
64-
assertThat(directivesAtServerLevel(conf))
59+
assertThat(directivesAtServerLevel(maintenancePageConf()))
6560
.as("the maintenance page answers on a catch-all Host rule whenever the webapp router is "
6661
+ "down, so the URL it would log is the deep link the contributor was reaching for")
6762
.contains("access_log off");
@@ -75,9 +70,8 @@ void maintenancePageNginxDisablesTheAccessLogForTheWholeServerBlock() throws Exc
7570
@Test
7671
void noNginxLocationReEnablesTheAccessLog() throws Exception {
7772
List<String> reEnabling = new ArrayList<>();
78-
for (String conf : List.of(
79-
Files.readString(WEBAPP_NGINX_CONF, StandardCharsets.UTF_8),
80-
propertyIn(PROXY_COMPOSE, "configs.nginx-default-config.content"))) {
73+
for (String conf :
74+
List.of(Files.readString(WEBAPP_NGINX_CONF, StandardCharsets.UTF_8), maintenancePageConf())) {
8175
conf.lines()
8276
.map(NoPerRequestAccessLogTest::directive)
8377
.filter(line -> line.startsWith("access_log") && !line.equals("access_log off"))
@@ -89,6 +83,20 @@ void noNginxLocationReEnablesTheAccessLog() throws Exception {
8983
.isEmpty();
9084
}
9185

86+
/**
87+
* The maintenance page's nginx config is inlined into the compose file rather than shipped as a
88+
* file, so a key that stops resolving would silently narrow both tests that read it to the webapp
89+
* config alone. Asserting here names that as the failure instead.
90+
*/
91+
private static String maintenancePageConf() throws IOException {
92+
String conf = propertyIn(PROXY_COMPOSE, "configs.nginx-default-config.content");
93+
94+
assertThat(conf)
95+
.as("docker/compose.proxy.yaml no longer inlines an nginx server config under that key")
96+
.isNotNull();
97+
return conf;
98+
}
99+
92100
/**
93101
* Directives written directly inside the single {@code server { … }} block — brace depth 1, so a
94102
* {@code location} nested inside it does not count.

server/application/src/test/java/de/tum/cit/aet/hephaestus/integration/schema/ProductionSchemaContractIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static void configureDatabase(DynamicPropertyRegistry registry) {
115115

116116
@Test
117117
void observationForeignKeysPreserveTenantAndProvenance() {
118-
List<String> foreignKeys = jdbcTemplate.queryForList("""
118+
List<@Nullable String> foreignKeys = jdbcTemplate.queryForList("""
119119
SELECT DISTINCT rc.constraint_name || ':' || parent.table_name || ':' || rc.delete_rule
120120
FROM information_schema.referential_constraints rc
121121
JOIN information_schema.key_column_usage child

server/application/src/test/java/de/tum/cit/aet/hephaestus/practices/curated/CuratedCatalogAdminControllerIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ private long overrideRows() {
10031003
return rows;
10041004
}
10051005

1006-
private List<String> auditValues(String entityType, String entityId) {
1006+
private List<@Nullable String> auditValues(String entityType, String entityId) {
10071007
return jdbcTemplate.queryForList("""
10081008
SELECT new_value::text
10091009
FROM config_audit_event

0 commit comments

Comments
 (0)