### Question:
CustomUserInfoEngineClient { public CustomUserInfoDefinition createDefinition(CustomUserInfoDefinitionCreator creator) { try { return identity.createCustomUserInfoDefinition(creator); } catch (CreationException e) { throw new APIException(new _("An error occurred while creating a definition"), e); } } CustomUserInfoEngineClient(IdentityAPI identity); CustomUserInfoDefinition createDefinition(CustomUserInfoDefinitionCreator creator); void deleteDefinition(long id); List<CustomUserInfoDefinition> listDefinitions(int startIndex, int maxResult); long countDefinitions(); List<CustomUserInfo> listCustomInformation(long userId, int startIndex, int maxResult); SearchResult<CustomUserInfoValue> searchCustomUserInfoValues(SearchOptions options); CustomUserInfoValue setCustomUserInfoValue(long definitionId, long userId, String value);  }### Answer:
@Test public void should_create_a_given_definition() throws Exception { given(engine.createCustomUserInfoDefinition(any(CustomUserInfoDefinitionCreator.class))) .willReturn(new EngineCustomUserInfoDefinition(1L, "foo", "bar")); CustomUserInfoDefinition definition = client.createDefinition(new CustomUserInfoDefinitionCreator("foo")); assertThat(definition.getName()).isEqualTo("foo"); }
@Test(expected = APIException.class) public void should_fail_to_create_a_given_definition_when_engine_throw_an_exception() throws Exception { given(engine.createCustomUserInfoDefinition(any(CustomUserInfoDefinitionCreator.class))) .willThrow(new CreationException("failure")); client.createDefinition(new CustomUserInfoDefinitionCreator("foo")); }