Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed \#1967: Correctly handle mocks with limited life-cycle in liste…
…ners.
- Loading branch information
Showing
6 changed files
with
120 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
44 changes: 44 additions & 0 deletions
44
src/test/java/org/mockito/internal/configuration/MockAnnotationProcessorTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2020 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockito.internal.configuration; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.mockito.MockedStatic; | ||
import org.mockito.exceptions.base.MockitoException; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
public class MockAnnotationProcessorTest { | ||
|
||
@SuppressWarnings("unused") | ||
private MockedStatic<Void> nonGeneric; | ||
|
||
@SuppressWarnings("unused") | ||
private MockedStatic<List<?>> generic; | ||
|
||
@SuppressWarnings({"raw", "unused"}) | ||
private MockedStatic raw; | ||
|
||
@Test | ||
public void testNonGeneric() throws Exception{ | ||
Class<?> type = MockAnnotationProcessor.inferStaticMock( | ||
MockAnnotationProcessorTest.class.getDeclaredField("nonGeneric").getGenericType(), "nonGeneric"); | ||
assertThat(type).isEqualTo(Void.class); | ||
} | ||
|
||
@Test(expected = MockitoException.class) | ||
public void testGeneric() throws Exception{ | ||
MockAnnotationProcessor.inferStaticMock( | ||
MockAnnotationProcessorTest.class.getDeclaredField("generic").getGenericType(), "generic"); | ||
} | ||
|
||
@Test(expected = MockitoException.class) | ||
public void testRaw() throws Exception{ | ||
MockAnnotationProcessor.inferStaticMock( | ||
MockAnnotationProcessorTest.class.getDeclaredField("raw").getGenericType(), "raw"); | ||
} | ||
} |