@Test
public void should_download_page_asset() throws Exception {

    Path expectedFile = widgetRepositoryPath.resolve("pbLabel/pbLabel.js");
    when(pageAssetService.findAssetPath("page-id", "asset.js", AssetType.JAVASCRIPT.getPrefix())).thenReturn(expectedFile);
    mockMvc
            .perform(get("/rest/pages/page-id/assets/js/asset.js"))
            .andExpect(status().isOk())
            .andExpect(content().bytes(readAllBytes(expectedFile)))
            .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM_VALUE))
            .andExpect(header().string("Content-Length", String.valueOf(expectedFile.toFile().length())))
            .andExpect(header().string("Content-Disposition", "attachment; filename=\"pbLabel.js\""))
            .andExpect(content().encoding("UTF-8"));
}