### Question:
AddressResolutionStatement extends ResolutionStatement<UnresolvedAddress, Address> { public static Optional<Address> getResolvedAddress( List<AddressResolutionStatement> statements, BigInteger height, UnresolvedAddress unresolvedAddress, long primaryId, long secondaryId) { if (unresolvedAddress instanceof Address) { return Optional.of((Address) unresolvedAddress); } return statements.stream() .filter(s -> height.equals(s.getHeight())) .filter(r -> r.getUnresolved().equals(unresolvedAddress)) .map( r -> r.getResolutionEntryById(primaryId, secondaryId).map(ResolutionEntry::getResolved)) .findFirst() .flatMap(Function.identity()); } AddressResolutionStatement(
      String recordId,
      BigInteger height,
      UnresolvedAddress unresolved,
      List<ResolutionEntry<Address>> resolutionEntries); static Optional<Address> getResolvedAddress(
      List<AddressResolutionStatement> statements,
      BigInteger height,
      UnresolvedAddress unresolvedAddress,
      long primaryId,
      long secondaryId);  }### Answer:
@Test void shouldGetResolvedEntryWhenPrimaryIdIsGreaterThanMaxAddress() { Optional<Address> resolved = AddressResolutionStatement.getResolvedAddress( addressResolutionStatements, height, addressNamespace1, 4, 0); Assertions.assertTrue(resolved.isPresent()); Assertions.assertEquals(address1, resolved.get()); }
@Test void shouldNotResolveAddressWhenInvalidHeight() { Optional<Address> resolved = AddressResolutionStatement.getResolvedAddress( addressResolutionStatements, height2, addressNamespace1, 4, 0); Assertions.assertFalse(resolved.isPresent()); }
@Test void shouldGetResolvedEntryRealAddress() { Optional<Address> resolved = AddressResolutionStatement.getResolvedAddress( addressResolutionStatements, height, address1, 4, 0); Assertions.assertTrue(resolved.isPresent()); Assertions.assertEquals(address1, resolved.get()); }
@Test void shouldGetResolvedEntryWhenPrimaryIdMatchesButSecondaryIdLessThanMinimum() { Optional<Address> resolved = AddressResolutionStatement.getResolvedAddress( addressResolutionStatements, height, mosaicNamespace1, 0, 6); Assertions.assertFalse(resolved.isPresent()); }
@Test void shouldReturnUndefinedAddress() { Optional<Address> resolved = AddressResolutionStatement.getResolvedAddress( addressResolutionStatements, height, addressNamespace1, 0, 6); Assertions.assertFalse(resolved.isPresent()); }
@Test void resolutionChangeInTheBlockMoreThanOneAggregate() { Optional<Address> resolved = AddressResolutionStatement.getResolvedAddress( addressResolutionStatements, height2, addressNamespace1, 0, 6); Assertions.assertFalse(resolved.isPresent()); }