@Test
public void should_save_asset() throws Exception {

    Page page = aPage().withId("page-id").build();
    Asset asset = aFilledAsset(page);
    Path fileExpected = pagesPath.resolve("assets").resolve("js").resolve(asset.getName());
    assertThat(fileExpected.toFile()).doesNotExist();
    when(pageRepository.resolvePathFolder("page-id")).thenReturn(pagesPath);
    when(pageRepository.get(asset.getComponentId())).thenReturn(page);
    assetRepository.save(asset, "My example with special characters réè@# \ntest".getBytes(Charset.forName("UTF-8")));
    //A json file has to be created in the repository
    assertThat(fileExpected.toFile()).exists();
    assertThat(Files.readFirstLine(fileExpected.toFile(), Charset.forName("UTF-8"))).isEqualTo("My example with special characters réè@# ");
}