mirror of
https://github.com/google/nomulus.git
synced 2025-07-08 12:13:19 +02:00
Convert CountDomainsCommand to tm (#1092)
* Convert CountDomainsCommand to tm As part of this, implement "select count(*)" queries in the QueryComposer. * Replaced kludgy trick for objectify count
This commit is contained in:
parent
48732c51e8
commit
4657be21b7
7 changed files with 54 additions and 16 deletions
|
@ -111,6 +111,17 @@ public class QueryComposerTest {
|
|||
.isEqualTo(alpha);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
public void testCount() {
|
||||
assertThat(
|
||||
transactIfJpaTm(
|
||||
() ->
|
||||
tm().createQueryComposer(TestEntity.class)
|
||||
.where("name", Comparator.GTE, "bravo")
|
||||
.count()))
|
||||
.isEqualTo(2L);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
public void testGetSingleResult() {
|
||||
assertThat(
|
||||
|
|
|
@ -19,12 +19,14 @@ import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
|||
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
|
||||
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.InjectExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link CountDomainsCommand}. */
|
||||
@DualDatabaseTest
|
||||
public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand> {
|
||||
|
||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
||||
|
@ -36,7 +38,7 @@ public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand
|
|||
createTlds("foo", "bar", "baz", "qux");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testSuccess_singleTld() throws Exception {
|
||||
for (int i = 0; i < 51; i++) {
|
||||
persistActiveDomain(String.format("test-%d.foo", i));
|
||||
|
@ -48,7 +50,7 @@ public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand
|
|||
assertStdoutIs("foo,51\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testSuccess_multipleTlds() throws Exception {
|
||||
for (int i = 0; i < 29; i++) {
|
||||
persistActiveDomain(String.format("test-%d.foo", i));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue