### Question:
SshUriPropertyProcessor { public Map<String, SshUri> getSshKeysByHostname() { return extractNestedProperties(sshUriProperties); } SshUriPropertyProcessor(SshUriProperties sshUriProperties); Map<String, SshUri> getSshKeysByHostname();  }### Answer:
@Test public void testSingleSshUriProperties() { SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(mainRepoPropertiesFixture()); Map<String, SshUri> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values(), hasSize(1)); SshUri sshKey = sshKeysByHostname.get(HOST1); assertMainRepo(sshKey); }
@Test public void testSameHostnameDifferentKeysFirstOneWins() { SshUriProperties sshUriProperties = mainRepoPropertiesFixture(); addRepoProperties(sshUriProperties, SshUri.builder().uri(URI1) .privateKey(PRIVATE_KEY1) .hostKey(HOST_KEY1) .hostKeyAlgorithm(ALGO1) .buildAsNestedRepo(), "repo2"); SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(sshUriProperties); Map<String, SshUri> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values(), hasSize(1)); SshUri sshKey = sshKeysByHostname.get(HOST1); assertMainRepo(sshKey); }
@Test public void testNoSshUriProperties() { SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(new SshUriProperties()); Map<String, SshUri> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values(), hasSize(0)); }
@Test public void testInvalidUriDoesNotAddEntry() { SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(SshUri.builder().uri("invalid_uri").build()); Map<String, SshUri> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values(), hasSize(0)); }
@Test public void testHttpsUriDoesNotAddEntry() { SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(SshUri.builder().uri("https: Map<String, SshUri> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values(), hasSize(0)); }