Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @Mock(serializable = true) for parameterized types. #3007

Merged
merged 1 commit into from May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -26,7 +26,7 @@ public class CreationSettings<T> implements MockCreationSettings<T>, Serializabl
private static final long serialVersionUID = -6789800638070123629L;

protected Class<T> typeToMock;
protected Type genericTypeToMock;
protected transient Type genericTypeToMock;
protected Set<Class<?>> extraInterfaces = new LinkedHashSet<>();
protected String name;
protected Object spiedInstance;
Expand Down
Expand Up @@ -13,6 +13,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Observable;
import java.util.function.Supplier;

import org.assertj.core.api.Assertions;
import org.junit.Test;
Expand Down Expand Up @@ -53,6 +54,9 @@ public class MocksSerializationForAnnotationTest extends TestBase implements Ser
serializable = true)
IMethods imethodsWithExtraInterfacesMock;

@Mock(serializable = true)
Supplier<Object> parameterizedSupplier;

@Test
public void should_allow_throws_exception_to_be_serializable() throws Exception {
// given
Expand All @@ -68,6 +72,11 @@ public void should_allow_mock_to_be_serializable() throws Exception {
serializeAndBack(imethodsMock);
}

@Test
public void should_allow_mock_of_parameterized_type_to_be_serializable() throws Exception {
serializeAndBack(parameterizedSupplier);
}

@Test
public void should_allow_mock_and_boolean_value_to_serializable() throws Exception {
// given
Expand Down