@Test
public void should_list_page_assets_while_getting_a_page() throws Exception {

    Page page = mockPageOfId("my-page");
    Asset[] assets = new Asset[]{
            anAsset().withName("myCss.css").withType(AssetType.CSS).withScope(AssetScope.WIDGET).withComponentId("widget-id").build(),
            anAsset().withName("myJs.js").withType(AssetType.JAVASCRIPT).withScope(AssetScope.PAGE).build(),
            anAsset().withName("https://mycdn.com/myExternalJs.js").withType(AssetType.JAVASCRIPT).withScope(AssetScope.PAGE).build()
    };
    when(assetVisitor.visit(page)).thenReturn(Sets.newHashSet(assets));
    mockMvc.perform(get("/rest/pages/my-page"))
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.assets", hasSize(3)))
            .andExpect(jsonPath("$.assets[*].name", Matchers.containsInAnyOrder("https://mycdn.com/myExternalJs.js", "myJs.js", "myCss.css")))
            .andExpect(jsonPath("$.assets[*].type", Matchers.containsInAnyOrder("js", "js", "css")))
            .andExpect(jsonPath("$.assets[*].scope", Matchers.containsInAnyOrder("page", "page", "widget")))
            .andExpect(jsonPath("$.assets[*].componentId", Matchers.containsInAnyOrder("widget-id")));
}