Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void testMethodCallPointingToToStringMethod_ShouldReturnOriginalValue() throws Exception {
- Object originalObject = new Object();
- Object[] args = null;
- Method methodMock = mock(Method.class);
- when(methodMock.getName()).thenReturn("toString");
- when(methodMock.invoke(originalObject, args)).thenReturn("TestValue");
- ProxyObjectMethodMirror proxyObjectMethodMirror = new ProxyObjectMethodMirror(objectMock, methodMock, args);
- assertTrue(proxyObjectMethodMirror.isMethodObjectMethod());
- assertEquals("TestValue",proxyObjectMethodMirror.executeMethod());
- }
- @Test
- public void testMethodCallPointingToWaitMethod_ShouldCallOriginalWaitMethod() throws Exception {
- Object originalObject = new Object();
- Object[] args = new Object[]{ 12 };
- Method methodMock = mock(Method.class);
- when(methodMock.getName()).thenReturn("toString");
- ProxyObjectMethodMirror proxyObjectMethodMirror = new ProxyObjectMethodMirror(objectMock, methodMock, args);
- assertTrue(proxyObjectMethodMirror.isMethodObjectMethod());
- proxyObjectMethodMirror.executeMethod(args);
- verify(methodMock).invoke(originalObject, args);
- }
- @Test
- public void testMethodCallPointingToNonObjectMethod_shouldReturnFalseOnIsMethodObjectMethod() throws Exception {
- Object originalObject = new Object();
- Object[] args = null;
- Method methodMock = mock(Method.class);
- when(methodMock.getName()).thenReturn("anythingElse");
- ProxyObjectMethodMirror proxyObjectMethodMirror = new ProxyObjectMethodMirror(objectMock, methodMock, args);
- assertFalse(proxyObjectMethodMirror.isMethodObjectMethod());
- }
Add Comment
Please, Sign In to add comment