### Question:
KeyDataUtil { public static Class<? extends ConfigKeyPair> getKeyPairTypeFor(KeyData keyData) { if (isDirect(keyData)) { return DirectKeyPair.class; } if (isInline(keyData)) { return InlineKeypair.class; } if (isAzure(keyData)) { return AzureVaultKeyPair.class; } if (isHashicorp(keyData)) { return HashicorpVaultKeyPair.class; } if (isAws(keyData)) { return AWSKeyPair.class; } if (isFileSystem(keyData)) { return FilesystemKeyPair.class; } return UnsupportedKeyPair.class; } private  KeyDataUtil(); static Class<? extends ConfigKeyPair> getKeyPairTypeFor(KeyData keyData); static boolean isLocked(KeyData keyData); static boolean isDirect(KeyData keyData); static boolean isInline(KeyData keyData); static boolean isAzure(KeyData keyData); static boolean isHashicorp(KeyData keyData); static boolean isAws(KeyData keyData); static boolean isFileSystem(KeyData keyData); static boolean isUnsupported(KeyData keyData); static ConfigKeyPair unmarshal(final KeyData keyData, final KeyEncryptor keyEncryptor); static KeyData marshal(final ConfigKeyPair keyPair);  }### Answer:
@Test public void getKeyPairTypeForDirectKeyPair() { KeyData keyData = new KeyData(); keyData.setPrivateKey("PRIVATE_KEY"); keyData.setPublicKey("PUBLIC_KEY"); Class<? extends ConfigKeyPair> result = KeyDataUtil.getKeyPairTypeFor(keyData); assertThat(result).isEqualTo(DirectKeyPair.class); }
@Test public void getKeyPairTypeForInlineKeyPair() { KeyData keyData = new KeyData(); keyData.setPublicKey("PUBLIC_KEY"); keyData.setConfig(new KeyDataConfig()); Class<? extends ConfigKeyPair> result = KeyDataUtil.getKeyPairTypeFor(keyData); assertThat(result).isEqualTo(InlineKeypair.class); }
@Test public void getKeyPairTypeForAzureVaultKeyPair() { KeyData keyData = new KeyData(); keyData.setAzureVaultPublicKeyId("AZURE_PUBLIC_ID"); keyData.setAzureVaultPrivateKeyId("AZURE_PRIVATE_ID"); Class<? extends ConfigKeyPair> result = KeyDataUtil.getKeyPairTypeFor(keyData); assertThat(result).isEqualTo(AzureVaultKeyPair.class); }
@Test public void getKeyPairTypeForHashicorpVaultKeyPair() { KeyData keyData = new KeyData(); keyData.setHashicorpVaultSecretName("HASHICORP_SECRET_NAME"); keyData.setHashicorpVaultSecretEngineName("HASHICORP_VAULT_ENGINE"); keyData.setHashicorpVaultPrivateKeyId("HASHICORP_PRIVATE_ID"); keyData.setHashicorpVaultPublicKeyId("HASHICORP_PUBLIC_ID"); Class<? extends ConfigKeyPair> result = KeyDataUtil.getKeyPairTypeFor(keyData); assertThat(result).isEqualTo(HashicorpVaultKeyPair.class); }
@Test public void getKeyPairTypeForAwsVaultKeyPair() { KeyData keyData = new KeyData(); keyData.setAwsSecretsManagerPrivateKeyId("AWS_PRIVATE_KEY"); keyData.setAwsSecretsManagerPublicKeyId("AWS_PUBLIC_KEY"); Class<? extends ConfigKeyPair> result = KeyDataUtil.getKeyPairTypeFor(keyData); assertThat(result).isEqualTo(AWSKeyPair.class); }
@Test public void getKeyPairTypeForFileSystemKeyPair() { KeyData keyData = new KeyData(); keyData.setPublicKeyPath(mock(Path.class)); keyData.setPrivateKeyPath(mock(Path.class)); Class<? extends ConfigKeyPair> result = KeyDataUtil.getKeyPairTypeFor(keyData); assertThat(result).isEqualTo(FilesystemKeyPair.class); }