### Question:
KeyDataUtil { public static boolean isLocked(KeyData keyData) { if (isFileSystem(keyData)) { final KeyDataConfig keyDataConfig = JaxbUtil.unmarshal( IOCallback.execute(() -> Files.newInputStream(keyData.getPrivateKeyPath())), KeyDataConfig.class); return keyDataConfig.getType() == PrivateKeyType.LOCKED; } if (Objects.isNull(keyData.getConfig())) { return false; } return keyData.getConfig().getType() == PrivateKeyType.LOCKED; } 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 isLockedFromFileSystem() throws URISyntaxException { KeyData keyData = new KeyData(); keyData.setPublicKeyPath(mock(Path.class)); final Path privUnlockedFile = Paths.get(getClass().getResource("/unlockedprivatekey.json").toURI()); keyData.setPrivateKeyPath(privUnlockedFile); assertThat(KeyDataUtil.isLocked(keyData)).isFalse(); final Path privLockedFile = Paths.get(getClass().getResource("/lockedprivatekey.json").toURI()); keyData.setPrivateKeyPath(privLockedFile); assertThat(KeyDataUtil.isLocked(keyData)).isTrue(); }
@Test public void isLocked() { KeyData keyData = new KeyData(); keyData.setPublicKey("PUBLIC_KEY"); KeyDataConfig keyDataConfig = new KeyDataConfig(mock(PrivateKeyData.class), PrivateKeyType.LOCKED); keyData.setConfig(keyDataConfig); assertThat(KeyDataUtil.isLocked(keyData)).isTrue(); keyData.setConfig(null); assertThat(KeyDataUtil.isLocked(keyData)).isFalse(); keyData.setConfig(new KeyDataConfig()); assertThat(KeyDataUtil.isLocked(keyData)).isFalse(); }