Created
February 7, 2014 14:30
-
-
Save fappel/8863588 to your computer and use it in GitHub Desktop.
Mockito Templates for Eclipse
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="false" context="java-statements" deleted="false" description="Mockito doAnswer(answer).when(mock).call() construct" enabled="true" name="doAnswer">${a:importStatic(org.mockito.Mockito.doAnswer)}${b:import(org.mockito.stubbing.Answer, org.mockito.invocation.InvocationOnMock, java.lang.Throwable)}doAnswer( new Answer<${T}>() { | |
public ${T} answer( InvocationOnMock invocation ) throws Throwable { | |
${cursor} | |
return null; | |
} | |
} ).when( ${mock} ).${call};</template><template autoinsert="false" context="java-statements" deleted="false" description="Mockito doAnswer(answer).when(mock).call() construct that manipulates invocation argument" enabled="true" name="doAnswerOnArgument">${a:importStatic(org.mockito.Mockito.doAnswer)}${b:import(org.mockito.stubbing.Answer, org.mockito.invocation.InvocationOnMock, java.lang.Throwable)}doAnswer( new Answer<${T}>() { | |
public ${T} answer( InvocationOnMock invocation ) throws Throwable { | |
${ArgType} ${argument} = ( ${ArgType} )invocation.getArguments()[ ${i} ]; | |
${cursor} | |
return null; | |
} | |
} ).when( ${mock} ).${call};</template><template autoinsert="false" context="java-statements" deleted="false" description="Mockito doReturn(value).when(mock).call() construct" enabled="true" name="doReturn">${:importStatic(org.mockito.Mockito.doReturn)}doReturn( ${value} ).when( ${mock} ).${call};</template><template autoinsert="false" context="java-statements" deleted="false" description="Mockito doThrow(throwable).when(mock).call() construct" enabled="true" name="doThrow">${:importStatic(org.mockito.Mockito.doThrow)}doThrow( ${throwable} ).when( ${mock} ).${call};</template><template autoinsert="false" context="java-statements" deleted="false" description="Mockito ArgumentCaptor.forClass(Type.class) construct" enabled="true" name="forClass">${a:import(org.mockito.ArgumentCaptor)}ArgumentCaptor<${Type}> ${captor} = ${b:importStatic(org.mockito.ArgumentCaptor.forClass)}forClass( ${Type}.class );</template><template autoinsert="false" context="java-statements" deleted="false" description="Mockito when(mock.call()).thenAnswer(answer) construct" enabled="true" name="whenThenAnswer">${a:importStatic(org.mockito.Mockito.when)}${b:import(org.mockito.stubbing.Answer, org.mockito.invocation.InvocationOnMock, java.lang.Throwable)}when( ${mock}.${call} ).thenAnswer( new Answer<${T}>() { | |
public ${T} answer( InvocationOnMock invocation ) throws Throwable { | |
${cursor} | |
return null; | |
} | |
} );</template><template autoinsert="false" context="java-statements" deleted="false" description="Mockito when(mock.call()).thenAnswer(answer) construct that manipulates invocation argument" enabled="true" name="whenThenAnswerOnArgument">${a:importStatic(org.mockito.Mockito.when)}${b:import(org.mockito.stubbing.Answer, org.mockito.invocation.InvocationOnMock, java.lang.Throwable)}when( ${mock}.${call} ).thenAnswer( new Answer<${T}>() { | |
public ${T} answer( InvocationOnMock invocation ) throws Throwable { | |
${ArgType} ${argument} = ( ${ArgType} )invocation.getArguments()[ ${i} ]; | |
${cursor} | |
return null; | |
} | |
} );</template><template autoinsert="false" context="java-statements" deleted="false" description="Mockito when(mock.call()).thenReturn(value) construct" enabled="true" name="whenThenReturn">${:importStatic(org.mockito.Mockito.when)}when( ${mock}.${call} ).thenReturn( ${value} );</template><template autoinsert="false" context="java-statements" deleted="false" description="Mockito when(mock.call()).thenThrow(throwable) construct" enabled="true" name="whenThenThrow">${:importStatic(org.mockito.Mockito.when)}when( ${mock}.${call} ).thenThrow( ${throwable} );</template></templates> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment