Skip to content

Commit

Permalink
Fix @Mock(serializable = true) for parameterized types (#3007)
Browse files Browse the repository at this point in the history
Fixes #2979
  • Loading branch information
cpovirk committed May 8, 2023
1 parent 6e0c228 commit 7d53c57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit 7d53c57

Please sign in to comment.