@Test
public void should_not_upload_an_asset_for_custom_widget() throws Exception {

    //We construct a mockfile (the first arg is the name of the property expected in the controller
    MockMultipartFile file = new MockMultipartFile("file", "myfile.js", "application/javascript", "foo".getBytes());
    Widget widget = aWidget().id("my-widget").build();
    when(widgetRepository.get("my-widget")).thenReturn(widget);
    doThrow(IllegalArgumentException.class).when(widgetAssetService).upload(file, widget, "js");
    mockMvc.perform(fileUpload("/rest/widgets/my-widget/assets/js").file(file))
            .andExpect(status().isBadRequest());
}