* BAEL-7765: How to fix JsonParseException: Unexpected character (code 115) when parsing unquoted JSON in Jackson

* BAEL-7757: How to solve MockitoException: the existing mock registration must be deregistered
This commit is contained in:
ACHRAF TAITAI 2024-04-24 20:07:03 +02:00 committed by GitHub
parent f94b8d96ca
commit 5f0a95c784
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,40 @@
package com.baeldung.mockito.mockstatic;
import com.baeldung.mockito.mockedstatic.StaticUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mockStatic;
public class StaticMockRegistrationUnitTest {
private MockedStatic<StaticUtils> mockStatic;
@Before
public void setUp() {
// Registering a static mock for UserService before each test
mockStatic = mockStatic(StaticUtils.class);
}
@After
public void tearDown() {
// Closing the mockStatic after each test
mockStatic.close();
}
@Test
public void givenStaticMockRegistration_whenMocked_thenReturnsMockSuccessfully() {
// Ensure that the static mock for UserService is registered
assertTrue(Mockito.mockingDetails(StaticUtils.class).isMock());
}
@Test
public void givenAnotherStaticMockRegistration_whenMocked_thenReturnsMockSuccessfully() {
// Ensure that the static mock for UserService is registered
assertTrue(Mockito.mockingDetails(StaticUtils.class).isMock());
}
}