I'm new to unit tests, and I'm having trouble covering a line trying to get in the tests, follow the code and the line it couldn't cover.
Code:
public void setKey(String myKey) {
MessageDigest sha = null;
try {
key = myKey.getBytes("UTF-8");
sha = MessageDigest.getInstance("SHA-256");
key = sha.digest(key);
key = Arrays.copyOf(key, 16); // use only first 128 bit
secretKey = new SecretKeySpec(key, "AES");
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
logger.error("Error while Set Key:", e);
}
}