### Question:
SensitiveDataCodec { public String decodeData(String encrypted) throws InvalidConfigurationException, IOException { checkNotNull(encrypted, "encrypted message cannot be null"); SecurityLevel securityLevel = getSecurityLevel(encrypted); if (encrypted.startsWith(securityLevel.getPrefix())) { encrypted = encrypted.substring(securityLevel.getPrefix().length()); } switch (securityLevel) { case PLAIN_TEXT: return encrypted; case OBFUSCATED: return decryptAndBase64(encrypted, createObfuscatingCipher(), OBFUSCATING_KEY); case ENCRYPTED: KeyPair keyPair = sensitiveDataCodecHelper.getKeyPair(); return decryptAndBase64( encrypted, createEncryptingCipher(keyPair), keyPair.getPrivate()); default: throw new InvalidConfigurationException("Invalid SecurityLevel " + securityLevel); } } SensitiveDataCodec(); @VisibleForTesting  SensitiveDataCodec(SensitiveDataCodecHelper sensitiveDataCodecHelper); String encodeData(String readable, SecurityLevel securityLevel); String decodeData(String encrypted); static void main(String[] args);  }### Answer:
@Test public void testDecodeWithNullString() throws IOException { SensitiveDataCodec sensitiveDataCodec = new SensitiveDataCodec(); thrown.expect(NullPointerException.class); thrown.expectMessage("encrypted message cannot be null"); sensitiveDataCodec.decodeData(null); }
@Test public void testPlainTextDecode() throws IOException { SensitiveDataCodec sensitiveDataCodec = new SensitiveDataCodec(); String unreadable = "pl:obf:testPlainText"; String decrypt = sensitiveDataCodec.decodeData(unreadable); assertEquals("obf:testPlainText", decrypt); }
@Test public void testPlainTextDecodeWithNoPrefix() throws IOException { SensitiveDataCodec sensitiveDataCodec = new SensitiveDataCodec(); String unreadable = "testPlainText"; String decrypt = sensitiveDataCodec.decodeData(unreadable); assertEquals(unreadable, decrypt); }