Created
March 2, 2022 18:25
-
-
Save maciejwalkowiak/24ef8513b699bf6d181a190ec46d1f6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VatChecker { | |
static VatCheckResponse checkVat(String vat) { | |
return null; | |
} | |
} | |
class VatCheckResponse { | |
private VatCheckResponse() {} | |
boolean isValid() { | |
return true; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.jupiter.api.Test; | |
import org.mockito.MockedStatic; | |
import org.mockito.Mockito; | |
import static org.assertj.core.api.Assertions.assertThat; | |
import static org.mockito.ArgumentMatchers.any; | |
class VatCheckerTests { | |
@Test | |
void foo() { | |
try (MockedStatic<VatChecker> vatChecker = Mockito.mockStatic(VatChecker.class, Mockito.RETURNS_DEEP_STUBS)) { | |
vatChecker.when(() -> VatChecker.checkVat(any()).isValid()).thenReturn(false); | |
assertThat(VatChecker.checkVat("asd").isValid()).isFalse(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment