@Test public void When_Method_Has_Not_Params_Then_Get_Response() throws Throwable { Method method = Providers.class.getMethod("noParams"); Object[] args = {}; String response = (String) mockeryProxy.invoke(null, method, args); assertThat(response, is(RESPONSE)); }
@Test public void When_Mockery_Params_Pass_Validation_Then_Get_Response() throws Throwable { Method method = Providers.class.getMethod("mockeryPass", String.class, String.class); Object[] args = {"s1", "s2"}; String response = (String) mockeryProxy.invoke(null, method, args); assertThat(response, is(RESPONSE)); }
@Test public void When_Param_Type_Is_Not_Supported_Then_Get_Exception() throws Throwable { Method method = Providers.class.getMethod("notSupportedTypeParam", Object.class); Object[] args = {}; exception.expect(RuntimeException.class); mockeryProxy.invoke(null, method, args); }
@Test public void When_Method_Type_Is_Not_Supported_Then_Get_Exception() throws Throwable { Method method = Providers.class.getMethod("notSupportedTypeMethod"); Object[] args = {}; exception.expect(RuntimeException.class); mockeryProxy.invoke(null, method, args); }
@Test public void When_Mockery_Params_Do_Not_Pass_Validation_Then_Get_Assertion_Error() throws Throwable { Method method = Providers.class.getMethod("mockeryNotPass", String.class, String.class); Object[] args = {"s1", "s2"}; try { mockeryProxy.invoke(null, method, args); fail(); } catch (AssertionError e) { assertThat(e.getMessage(), is(RESPONSE_ERROR)); } }
@Test public void When_No_Mockery_Params_Then_Get_Exception() throws Throwable { Method method = Providers.class.getMethod("noMockery", String.class, Integer.class); Object[] args = {"s1", 1}; try { mockeryProxy.invoke(null, method, args); fail(); } catch (RuntimeException e) { assertThat(e.getMessage(), is("When checking method Providers#noMockery \n" + "No @Mockery annotation for param with position 2 was found.\n" + "To fix it, annotate this param with one.\n")); } }