@Test public void deserializeWrongValue() throws IOException { server.enqueue(new MockResponse().setBody("<myObject><foo/><bar/></myObject>")); Call<?> call = service.get(); try { call.execute(); fail(); } catch (RuntimeException e) { assertThat(e.getCause()).isInstanceOf(ElementException.class) .hasMessageStartingWith("Element 'foo' does not have a match in class retrofit2.converter.simplexml.MyObject"); } }
public void testRedundantElementOrder() throws Exception { ElementEntry entry = new ElementEntry("a", "b", "c"); Persister persister = new Persister(); boolean exception = false; try { validate(entry, persister); }catch(ElementException e) { e.printStackTrace(); exception = true; } assertTrue(exception); }