### Question:
BodyParserXML implements BodyParser { public <T> T invoke(Context context, Class<T> classOfT) { return invoke(context, classOfT, null); }  T invoke(Context context, Class<T> classOfT); @Override T invoke(Context context, Class<T> classOfT, Type genericType); @Override T invoke(byte[] bytes, Class<T> classOfT); List<String> getContentTypes();  }### Answer:
@Test public void testParsing() { FakeContext context = new FakeContext().setBody( "<Data>" + "<name>wisdom</name>" + "<age>2</age>" + "<friends>" + "<friend>clement</friend>" + "<friend>jonathan</friend>" + "</friends>" + "</Data>"); Data data = parser.invoke(context, Data.class); assertThat(data.getName()).isEqualTo("wisdom"); assertThat(data.getFriends()).containsExactly("clement", "jonathan"); assertThat(data.getAge()).isEqualTo(2); }
@Test public void testParsingWithGenericType() throws NoSuchFieldException { Type type = this.getClass().getDeclaredField("tmp").getGenericType(); FakeContext context = new FakeContext().setBody( "<List><Data>" + "<name>wisdom</name>" + "<age>2</age>" + "<friends>" + "<friend>clement</friend>" + "<friend>jonathan</friend>" + "</friends>" + "</Data></List>"); List<Data> list = parser.invoke(context, List.class, type); assertThat(list).hasSize(1); assertThat(list.get(0)).isInstanceOf(Data.class); Data data = list.get(0); assertThat(data.getName()).isEqualTo("wisdom"); assertThat(data.getFriends()).containsExactly("clement", "jonathan"); assertThat(data.getAge()).isEqualTo(2); }
@Test public void testParsingError() { FakeContext context = new FakeContext().setBody( "<Data>" + "<name>wisdom</name>" + "<age>2</age>" + "<friends>" + "<friend>clement</friend>" + "<friend>jonathan</friend>" + "<friends>" + "</Data>"); assertThat(parser.invoke(context, Data.class)).isNull(); }