### Question:
KettleTwoWayPasswordEncoder implements TwoWayPasswordEncoderInterface { @Override public String encode( String rawPassword ) { return encode( rawPassword, true ); } KettleTwoWayPasswordEncoder(); @Override void init(); @Override String encode( String rawPassword ); @Override String encode( String rawPassword, boolean includePrefix ); @Override String decode( String encodedPassword ); @Override String decode( String encodedPassword, boolean optionallyEncrypted ); @Override String[] getPrefixes(); static final String encryptPasswordIfNotUsingVariables( String password ); static final String decryptPasswordOptionallyEncrypted( String password ); static final String encryptPassword( String password ); static final String decryptPassword( String encrypted ); static final String PASSWORD_ENCRYPTED_PREFIX; }### Answer:
@Test public void testEncode1() throws KettleValueException { KettleTwoWayPasswordEncoder encoder = new KettleTwoWayPasswordEncoder(); String encryption; encryption = encoder.encode( null, false ); assertTrue( "".equals( encryption ) ); encryption = encoder.encode( "", false ); assertTrue( "".equals( encryption ) ); encryption = encoder.encode( " ", false ); assertTrue( "2be98afc86aa7f2e4cb79ce309ed2ef9a".equals( encryption ) ); encryption = encoder.encode( "Test of different encryptions!!@#$%", false ); assertTrue( "54657374206f6620646966666572656e742067d0fbddb11ad39b8ba50aef31fed1eb9f".equals( encryption ) ); encryption = encoder.encode( " Spaces left", false ); assertTrue( "2be98afe84af48285a81cbd30d297a9ce".equals( encryption ) ); encryption = encoder.encode( "Spaces right", false ); assertTrue( "2be98afc839d79387ae0aee62d795a7ce".equals( encryption ) ); encryption = encoder.encode( " Spaces ", false ); assertTrue( "2be98afe84a87d2c49809af73db81ef9a".equals( encryption ) ); encryption = encoder.encode( "1234567890", false ); assertTrue( "2be98afc86aa7c3d6f84dfb2689caf68a".equals( encryption ) ); }
@Test public void testEncode2() throws KettleValueException { KettleTwoWayPasswordEncoder encoder = new KettleTwoWayPasswordEncoder(); String encryption; encryption = encoder.encode( null ); assertTrue( "Encrypted ".equals( encryption ) ); encryption = encoder.encode( "" ); assertTrue( "Encrypted ".equals( encryption ) ); encryption = encoder.encode( "String" ); assertTrue( "Encrypted 2be98afc86aa7f2e4cb799d64cc9ba1dd".equals( encryption ) ); encryption = encoder.encode( " ${VAR} String" ); assertTrue( " ${VAR} String".equals( encryption ) ); encryption = encoder.encode( " %%VAR%% String" ); assertTrue( " %%VAR%% String".equals( encryption ) ); encryption = encoder.encode( " %% VAR String" ); assertTrue( "Encrypted 2be988fed4f87a4a599599d64cc9ba1dd".equals( encryption ) ); encryption = encoder.encode( "${%%$$$$" ); assertTrue( "Encrypted 2be98afc86aa7f2e4ef02eb359ad6eb9e".equals( encryption ) ); }