Search in sources :

Example 1 with AddressBookFilter

use of com.hedera.mirror.grpc.domain.AddressBookFilter in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method lessThanPageSize.

@Test
void lessThanPageSize() {
    addressBookProperties.setPageSize(2);
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry = addressBookEntry();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).build();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry);
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with AddressBookFilter

use of com.hedera.mirror.grpc.domain.AddressBookFilter in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method cached.

@Test
void cached() {
    addressBookProperties.setPageSize(2);
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry1 = addressBookEntry();
    AddressBookEntry addressBookEntry2 = addressBookEntry();
    AddressBookEntry addressBookEntry3 = addressBookEntry();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).build();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry1, addressBookEntry2, addressBookEntry3);
    addressBookEntryRepository.deleteAll();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry1, addressBookEntry2, addressBookEntry3);
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with AddressBookFilter

use of com.hedera.mirror.grpc.domain.AddressBookFilter in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method invalidAddressBookFile.

@Test
void invalidAddressBookFile() {
    AddressBookFilter filter = AddressBookFilter.builder().fileId(EntityId.of(999L, EntityType.FILE)).build();
    assertThatThrownBy(() -> networkService.getNodes(filter)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining(INVALID_FILE_ID);
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with AddressBookFilter

use of com.hedera.mirror.grpc.domain.AddressBookFilter in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method invalidFilter.

@Test
void invalidFilter() {
    AddressBookFilter filter = AddressBookFilter.builder().fileId(null).limit(-1).build();
    assertThatThrownBy(() -> networkService.getNodes(filter)).isInstanceOf(ConstraintViolationException.class).hasMessageContaining("limit: must be greater than or equal to 0").hasMessageContaining("fileId: must not be null");
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 5 with AddressBookFilter

use of com.hedera.mirror.grpc.domain.AddressBookFilter in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method moreThanPageSize.

@Test
void moreThanPageSize() {
    addressBookProperties.setPageSize(2);
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry1 = addressBookEntry();
    AddressBookEntry addressBookEntry2 = addressBookEntry();
    AddressBookEntry addressBookEntry3 = addressBookEntry();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).build();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry1, addressBookEntry2, addressBookEntry3);
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

AddressBookFilter (com.hedera.mirror.grpc.domain.AddressBookFilter)10 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)9 Test (org.junit.jupiter.api.Test)9 AddressBook (com.hedera.mirror.common.domain.addressbook.AddressBook)6 AddressBookEntry (com.hedera.mirror.common.domain.addressbook.AddressBookEntry)6 EntityNotFoundException (com.hedera.mirror.grpc.exception.EntityNotFoundException)2 EntityId (com.hedera.mirror.common.domain.entity.EntityId)1 EntityType (com.hedera.mirror.common.domain.entity.EntityType)1 AddressBookEntryRepository (com.hedera.mirror.grpc.repository.AddressBookEntryRepository)1 AddressBookRepository (com.hedera.mirror.grpc.repository.AddressBookRepository)1 Collection (java.util.Collection)1 Set (java.util.Set)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Named (javax.inject.Named)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 Value (lombok.Value)1 Log4j2 (lombok.extern.log4j.Log4j2)1 Validated (org.springframework.validation.annotation.Validated)1