### Question:
HubMetadataPublicKeyStore implements InternalPublicKeyStore { @Override public List<PublicKey> getVerifyingKeysForEntity() { try { CriteriaSet criteria = new CriteriaSet(new EntityIdCriterion(hubEntityId)); return Optional.ofNullable(metadataResolver.resolveSingle(criteria)) .map(this::getPublicKeys) .orElseThrow(hubMissingException()); } catch (ResolverException e) { throw Throwables.propagate(e); } } @Inject  HubMetadataPublicKeyStore(MetadataResolver metadataResolver,
                                     PublicKeyFactory publicKeyFactory,
                                     @Named("HubEntityId") String hubEntityId); @Override List<PublicKey> getVerifyingKeysForEntity();  }### Answer:
@Test public void shouldReturnTheSigningPublicKeysForTheHub() throws Exception { HubMetadataPublicKeyStore hubMetadataPublicKeyStore = new HubMetadataPublicKeyStore(metadataResolver, new PublicKeyFactory(), TestEntityIds.HUB_ENTITY_ID); List<PublicKey> verifyingKeysForEntity = hubMetadataPublicKeyStore.getVerifyingKeysForEntity(); assertThat(verifyingKeysForEntity).containsOnly(getX509Key(TestCertificateStrings.HUB_TEST_PUBLIC_SIGNING_CERT), getX509Key(TestCertificateStrings.HUB_TEST_SECONDARY_PUBLIC_SIGNING_CERT)); }
@Test public void shouldErrorWhenMetadataIsInvalid() throws Exception { HubMetadataPublicKeyStore hubMetadataPublicKeyStore = new HubMetadataPublicKeyStore(invalidMetadataResolver, new PublicKeyFactory(), TestEntityIds.HUB_ENTITY_ID); try { hubMetadataPublicKeyStore.getVerifyingKeysForEntity(); fail("we expected the HubEntityMissingException"); } catch (HubEntityMissingException e) { assertThat(e).hasMessage("The HUB entity-id: \"https: } }
@Test public void shouldErrorWhenMetadataIsEmpty() throws Exception { HubMetadataPublicKeyStore hubMetadataPublicKeyStore = new HubMetadataPublicKeyStore(emptyMetadataResolver, new PublicKeyFactory(), TestEntityIds.HUB_ENTITY_ID); try { hubMetadataPublicKeyStore.getVerifyingKeysForEntity(); fail("we expected the HubEntityMissingException"); } catch (HubEntityMissingException e) { assertThat(e).hasMessage("The HUB entity-id: \"https: } }