-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Refresh view query language section (#144)
--------- Co-authored-by: Peter Vlugter <[email protected]>
- Loading branch information
1 parent
cafcb58
commit d28fb66
Showing
4 changed files
with
230 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,13 +34,15 @@ | |
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import java.time.Instant; | ||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
|
||
import static java.time.temporal.ChronoUnit.DAYS; | ||
import static java.time.temporal.ChronoUnit.HOURS; | ||
import static java.time.temporal.ChronoUnit.SECONDS; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
@@ -173,7 +175,9 @@ public void verifyAllTheFieldTypesView() throws Exception { | |
// see that we can persist and read a row with all fields, no indexed columns | ||
var id = newId(); | ||
var row = new AllTheTypesKvEntity.AllTheTypes(1, 2L, 3F, 4D, true, "text", 5, 6L, 7F, 8D, false, | ||
Instant.now(), ZonedDateTime.now(), | ||
Instant.now(), | ||
// Note: we turn it into a timestamp internally, so the specific TZ is lost (but the exact point in time stays the same) | ||
ZonedDateTime.now().withZoneSameInstant(ZoneId.of("Z")), | ||
Optional.of("optional"), List.of("text1", "text2"), | ||
new AllTheTypesKvEntity.ByEmail("[email protected]"), | ||
AllTheTypesKvEntity.AnEnum.THREE, new AllTheTypesKvEntity.Recursive(new AllTheTypesKvEntity.Recursive(null, "level2"), "level1")); | ||
|
@@ -221,6 +225,85 @@ public void verifyAllTheFieldTypesView() throws Exception { | |
|
||
assertThat(rows).hasSize(1); | ||
}); | ||
|
||
Awaitility.await() | ||
.ignoreExceptions() | ||
.atMost(10, TimeUnit.SECONDS) | ||
.untilAsserted(() -> { | ||
var result = await(componentClient.forView() | ||
.method(AllTheTypesView::countRows) | ||
.invokeAsync()); | ||
|
||
assertThat(result.count()).isEqualTo(1); | ||
}); | ||
|
||
|
||
Awaitility.await() | ||
.ignoreExceptions() | ||
.atMost(10, TimeUnit.SECONDS) | ||
.untilAsserted(() -> { | ||
var rows = await(componentClient.forView() | ||
.stream(AllTheTypesView::compareInstant) | ||
.source(new AllTheTypesView.InstantRequest(Instant.now().minus(3, DAYS))) | ||
.runWith(Sink.seq(), testKit.getMaterializer())); | ||
|
||
assertThat(rows).hasSize(1); | ||
}); | ||
|
||
Awaitility.await() | ||
.ignoreExceptions() | ||
.atMost(10, TimeUnit.SECONDS) | ||
.untilAsserted(() -> { | ||
var rows = await(componentClient.forView() | ||
.stream(AllTheTypesView::groupQuery) | ||
.source() | ||
.runWith(Sink.seq(), testKit.getMaterializer())); | ||
|
||
assertThat(rows).hasSize(1); | ||
assertThat(rows.getFirst().grouped()).hasSize(1); | ||
assertThat(rows.getFirst().grouped().getFirst()).isEqualTo(row); | ||
assertThat(rows.getFirst().totalCount()).isEqualTo(1L); | ||
}); | ||
|
||
Awaitility.await() | ||
.ignoreExceptions() | ||
.atMost(10, TimeUnit.SECONDS) | ||
.untilAsserted(() -> { | ||
var rows = await(componentClient.forView() | ||
.stream(AllTheTypesView::projectedGroupQuery) | ||
.source() | ||
.runWith(Sink.seq(), testKit.getMaterializer())); | ||
|
||
assertThat(rows).hasSize(1); | ||
assertThat(rows.getFirst().groupedStringValues()).hasSize(1); | ||
assertThat(rows.getFirst().groupedStringValues().getFirst()).isEqualTo(row.stringValue()); | ||
assertThat(rows.getFirst().totalCount()).isEqualTo(1L); | ||
}); | ||
|
||
|
||
Awaitility.await() | ||
.ignoreExceptions() | ||
.atMost(10, TimeUnit.SECONDS) | ||
.untilAsserted(() -> { | ||
var rows = await(componentClient.forView() | ||
.stream(AllTheTypesView::nullableQuery) | ||
.source() | ||
.runWith(Sink.seq(), testKit.getMaterializer())); | ||
|
||
assertThat(rows).hasSize(1); | ||
}); | ||
|
||
Awaitility.await() | ||
.ignoreExceptions() | ||
.atMost(10, TimeUnit.SECONDS) | ||
.untilAsserted(() -> { | ||
var page = await(componentClient.forView() | ||
.method(AllTheTypesView::paging) | ||
.invokeAsync(new AllTheTypesView.PageRequest(""))); | ||
|
||
assertThat(page.entries()).hasSize(1); | ||
assertThat(page.hasMore()).isFalse(); | ||
}); | ||
} | ||
|
||
@Disabled // pending primitive query parameters working | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.