0

I have a method that uses

public A setSomeProperties(){
//Call db repo
// call service
String a = aRepo.getValue();
BasicTextEncryptor b = new BasicTextEncryptor();
b.decrypt(a);
…
….
return new A(); 
}

So my issue is while writing junit test I am having issues with b.decrypt(a);

// org.jasypt.EncryptionOperationNotPossiblException

So I tried mocking BasicTextEncryptor but apparently its a final class so what would be my next step to fix this issue?

Brooklyn99
  • 987
  • 13
  • 24
  • If your method is doing `new`, then you are not using a mock. See https://stackoverflow.com/questions/74027324/why-are-my-mocked-methods-not-called-when-executing-a-unit-test for a detailed explanation. That said, if `BasicTextEncryptor` cannot be mocked directly, you could wrap it in your own class and mock that. – knittl Aug 16 '23 at 02:32

0 Answers0