Skip to content

Commit

Permalink
Add back accidentally removed test method
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Jun 19, 2024
1 parent c153217 commit 06a7f82
Showing 1 changed file with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,75 @@ void test() {
);
}

@Test
void whenMixedArgumentMatcher() {
//language=java
rewriteRun(
java(
"""
import java.util.List;
class MyObject {
public String getSomeField(String s, String s2, String s3, long l1) {
return "X";
}
}
"""
),
java(
"""
import java.util.ArrayList;
import java.util.List;
import mockit.Expectations;
import mockit.Mocked;
import mockit.integration.junit5.JMockitExtension;
import org.junit.jupiter.api.extension.ExtendWith;
import static org.junit.jupiter.api.Assertions.assertNull;
@ExtendWith(JMockitExtension.class)
class MyTest {
@Mocked
MyObject myObject;
void test() {
String bazz = "bazz";
new Expectations() {{
myObject.getSomeField("foo", anyString, bazz, 10L);
result = null;
}};
assertNull(myObject.getSomeField("foo", "bar", bazz, 10L));
}
}
""",
"""
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
class MyTest {
@Mock
MyObject myObject;
void test() {
String bazz = "bazz";
when(myObject.getSomeField(eq("foo"), anyString(), eq(bazz), eq(10L))).thenReturn(null);
assertNull(myObject.getSomeField("foo", "bar", bazz, 10L));
}
}
"""
)
);
}

@Test
void whenSetupStatements() {
//language=java
Expand Down

0 comments on commit 06a7f82

Please sign in to comment.