private void expectInvalidPattern(String pattern, String errorMessage) { try { Joda.forPattern(pattern); fail("Pattern " + pattern + " should have thrown an exception but did not"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString(errorMessage)); } }
@Test() public void shouldRejectInvalidExtraType() { try { IntentBuilder.build("intent action", new Pair<>("CustomThing", new CustomThing())); Assert.fail("Exception not thrown"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("Illegal parameter type")); } }
@Test public void testCreateInstanceWithoutHttpHandler() throws Exception { try { new RestfitClient.Builder().userAgent("RestfitTest/1.0").build(); fail("never reached"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("No httpStack specified")); } }
@Test public void testCreateInstanceWithoutUserAgent() throws Exception { try { new RestfitClient.Builder().httpStack(new DummyHttpStack()).build(); fail("never reached"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("No userAgent specified")); } }