@Test
public void should_not_allow_to_create_a_widget_with_an_existing_name() throws Exception {

    Widget customLabel = aWidget().name("alreadyExistingName").build();
    when(widgetRepository.create(customLabel)).thenThrow(new NotAllowedException("already existing name"));
    mockMvc
            .perform(post("/rest/widgets")
                    .contentType(MediaType.APPLICATION_JSON_VALUE)
                    .content(convertObjectToJsonBytes(customLabel)))
            .andExpect(status().isForbidden());
}