### Question:
Encr { public static final String encryptPasswordIfNotUsingVariables( String password ) { return encoder.encode( password, true ); } Encr(); @Deprecated boolean init(); static void init( String encoderPluginId ); @Deprecated static final boolean checkSignatureShort( String signature, String verify ); @Deprecated static final String getSignatureShort( String signature ); static final String encryptPassword( String password ); static final String decryptPassword( String encrypted ); static final String encryptPasswordIfNotUsingVariables( String password ); static final String decryptPasswordOptionallyEncrypted( String password ); static void main( String[] args ); static final String PASSWORD_ENCRYPTED_PREFIX; }### Answer:
@Test public void testEncryptPasswordIfNotUsingVariables() throws KettleValueException { String encryption; encryption = Encr.encryptPasswordIfNotUsingVariables( null ); assertTrue( "Encrypted ".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( "" ); assertTrue( "Encrypted ".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( "String" ); assertTrue( "Encrypted 2be98afc86aa7f2e4cb799d64cc9ba1dd".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( " ${VAR} String" ); assertTrue( " ${VAR} String".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( " %%VAR%% String" ); assertTrue( " %%VAR%% String".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( " %% VAR String" ); assertTrue( "Encrypted 2be988fed4f87a4a599599d64cc9ba1dd".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( "${%%$$$$" ); assertTrue( "Encrypted 2be98afc86aa7f2e4ef02eb359ad6eb9e".equals( encryption ) ); }
@Test public void testEncryptPasswordIfNotUsingVariables() throws HopValueException { String encryption; encryption = Encr.encryptPasswordIfNotUsingVariables( null ); assertTrue( "Encrypted ".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( "" ); assertTrue( "Encrypted ".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( "String" ); assertTrue( "Encrypted 2be98afc86aa7f2e4cb799d64cc9ba1dd".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( " ${VAR} String" ); assertTrue( " ${VAR} String".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( " %%VAR%% String" ); assertTrue( " %%VAR%% String".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( " %% VAR String" ); assertTrue( "Encrypted 2be988fed4f87a4a599599d64cc9ba1dd".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( "${%%$$$$" ); assertTrue( "Encrypted 2be98afc86aa7f2e4ef02eb359ad6eb9e".equals( encryption ) ); }