@Test
public void should_upload_a_local_asset() 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());
    Page page = mockPageOfId("my-page");
    Asset expectedAsset = anAsset().withId("assetId").active().withName("myfile.js").withOrder(2).withScope(PAGE)
            .withType(AssetType.JAVASCRIPT).build();
    when(pageAssetService.upload(file, page, "js")).thenReturn(expectedAsset);
    mockMvc.perform(fileUpload("/rest/pages/my-page/assets/js").file(file))
            .andExpect(status().isCreated())
            .andExpect(jsonPath("$.id").value("assetId"))
            .andExpect(jsonPath("$.name").value("myfile.js"))
            .andExpect(jsonPath("$.scope").value(PAGE.toString()))
            .andExpect(jsonPath("$.type").value("js"))
            .andExpect(jsonPath("$.order").value(2));
    verify(pageAssetService).upload(file, page, "js");
}