Skip to content

Commit cb3bd35

Browse files
committed
Update standard test
1 parent c224e09 commit cb3bd35

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,13 @@ Using Maven:
180180

181181
### Standard test
182182

183-
Add a standard test to your project as shown below. Ideally, all checks should work and return an empty result.
183+
Add a standard test to your project as shown below. Ideally, all checks should pass and return an empty result.
184184

185185
```java
186186
import io.github.mfvanek.pg.core.checks.common.DatabaseCheckOnHost;
187187
import io.github.mfvanek.pg.core.checks.common.Diagnostic;
188188
import io.github.mfvanek.pg.model.dbobject.DbObject;
189+
import org.jspecify.annotations.NonNull;
189190
import org.junit.jupiter.api.Test;
190191
import org.springframework.beans.factory.annotation.Autowired;
191192
import org.springframework.boot.test.context.SpringBootTest;
@@ -200,7 +201,7 @@ import static org.assertj.core.api.Assertions.assertThat;
200201
class DatabaseStructureStaticAnalysisTest {
201202

202203
@Autowired
203-
private List<DatabaseCheckOnHost<? extends DbObject>> checks;
204+
private List<DatabaseCheckOnHost<? extends @NonNull DbObject>> checks;
204205

205206
@Test
206207
void checksShouldWork() {
@@ -217,6 +218,44 @@ class DatabaseStructureStaticAnalysisTest {
217218
}
218219
```
219220

221+
<details>
222+
<summary>with Kotlin</summary>
223+
224+
```kotlin
225+
import io.github.mfvanek.pg.core.checks.common.DatabaseCheckOnHost
226+
import io.github.mfvanek.pg.core.checks.common.Diagnostic
227+
import io.github.mfvanek.pg.model.dbobject.DbObject
228+
import org.assertj.core.api.Assertions.assertThat
229+
import org.junit.jupiter.api.Test
230+
import org.springframework.beans.factory.annotation.Autowired
231+
import org.springframework.boot.test.context.SpringBootTest
232+
import org.springframework.test.context.ActiveProfiles
233+
234+
@SpringBootTest
235+
@ActiveProfiles("test")
236+
internal class DatabaseStructureStaticAnalysisTest {
237+
238+
@Autowired
239+
private lateinit var checks: List<DatabaseCheckOnHost<out DbObject>>
240+
241+
@Test
242+
fun checksShouldWork() {
243+
assertThat(checks)
244+
.hasSameSizeAs(Diagnostic.entries.toTypedArray())
245+
246+
checks
247+
.filter { it.isStatic }
248+
.forEach {
249+
assertThat(it.check())
250+
.`as`(it.diagnostic.name)
251+
.isEmpty()
252+
}
253+
}
254+
}
255+
```
256+
257+
</details>
258+
220259
### Spring Boot compatibility
221260

222261
| Spring Boot | Min JDK | pg-index-health-test-starter |

0 commit comments

Comments
 (0)