class PasswordEncoderImpl implements PasswordEncoder {

    @Override
    public String encode(@NonNull String rawPassword) {
        String encodedPassword = this.updatableBCrypt.hash(rawPassword, this.keyStore.decryptString(this.customPreference.getSalt(), Constants.ALIAS_SALT));
        return keyStore.encryptString(encodedPassword, Constants.ALIAS_PASSWORD_KEY);
    }

}

class PasswordEncoderImplTest {

    private static final String TESTABLE_PASSWORD;
    private static final String ENCODED_PASSWORD;
    private static final String SALT;
    private PasswordEncoderImpl passwordEncoder;
    @Mock
    private CustomPreference customPreference;
    @Mock
    private KeyStore keyStore;
    @Mock
    private UpdatableBCrypt updatableBCrypt;

    @Test
    public void encodeTestSuccess() {

        String result = passwordEncoder.encode(TESTABLE_PASSWORD);

        assertNotNull(result);
        assertEquals(ENCODED_PASSWORD, result);
    }

}