### Question:
SshUriPropertyProcessor { public Map<String, JGitEnvironmentProperties> getSshKeysByHostname() { return extractNestedProperties(this.sshUriProperties); } SshUriPropertyProcessor(MultipleJGitEnvironmentProperties sshUriProperties); Map<String, JGitEnvironmentProperties> getSshKeysByHostname();  }### Answer:
@Test public void testHttpsUriDoesNotAddEntry() { MultipleJGitEnvironmentProperties sshUriProperties = new MultipleJGitEnvironmentProperties(); sshUriProperties.setUri("https: SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(sshUriProperties); Map<String, JGitEnvironmentProperties> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values()).hasSize(0); }
@Test public void testSingleSshUriProperties() { SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(mainRepoPropertiesFixture()); Map<String, JGitEnvironmentProperties> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values()).hasSize(1); JGitEnvironmentProperties sshKey = sshKeysByHostname.get(HOST1); assertMainRepo(sshKey); }
@Test public void testSameHostnameDifferentKeysFirstOneWins() { MultipleJGitEnvironmentProperties sshUriProperties = mainRepoPropertiesFixture(); MultipleJGitEnvironmentProperties.PatternMatchingJGitEnvironmentProperties nestedSshUriProperties; nestedSshUriProperties = new MultipleJGitEnvironmentProperties.PatternMatchingJGitEnvironmentProperties(); nestedSshUriProperties.setUri(URI1); nestedSshUriProperties.setPrivateKey(PRIVATE_KEY1); nestedSshUriProperties.setHostKey(HOST_KEY1); nestedSshUriProperties.setHostKeyAlgorithm(ALGO1); addRepoProperties(sshUriProperties, nestedSshUriProperties, "repo2"); SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(sshUriProperties); Map<String, JGitEnvironmentProperties> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values()).hasSize(1); JGitEnvironmentProperties sshKey = sshKeysByHostname.get(HOST1); assertMainRepo(sshKey); }
@Test public void testNoSshUriProperties() { SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor( new MultipleJGitEnvironmentProperties()); Map<String, JGitEnvironmentProperties> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values()).hasSize(0); }
@Test public void testInvalidUriDoesNotAddEntry() { MultipleJGitEnvironmentProperties sshUriProperties = new MultipleJGitEnvironmentProperties(); sshUriProperties.setUri("invalid_uri"); SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(sshUriProperties); Map<String, JGitEnvironmentProperties> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname(); assertThat(sshKeysByHostname.values()).hasSize(0); }