StyleAddModalContainerPropertiesMigrationStep implements MigrationStep<Page> { @Override public void migrate(Page artifact) { for (Asset asset : artifact.getAssets()) { if (asset.getName().equals("style.css")) { try { String pageStyleCssContent = assetService.getAssetContent(artifact, asset); assetService.save(artifact, asset, getMigratedAssetContent(pageStyleCssContent)); logger.info(format( "[MIGRATION] Adding modalContainer classes in asset [%s] to %s [%s] (introduced in 1.8.28)", asset.getName(), artifact.getType(), artifact.getName())); } catch (IOException e) { logger.error("An error occurred during migration",e); } } } } @Inject  StyleAddModalContainerPropertiesMigrationStep(@Named("pageAssetService") AssetService<Page> assetService); @Override void migrate(Page artifact);  }
@Test public void should_migrate_style_asset_to_add_new_modal_container_css_classes() throws Exception { Asset style = anAsset().withType(CSS).withName("style.css").build(); String initContent = ".my-content {background: red}"; Page page = aPage() .withVersion("1.7.9").withAsset(style).build(); when(pageAssetService.getAssetContent(page, style)).thenReturn(initContent); InputStream is = this.getClass().getClassLoader().getResourceAsStream("templates/migration/assets/css/styleAddModalContainerProperties.css"); String content = initContent.concat(IOUtils.toString(is)); step.migrate(page); verify(pageAssetService).save(page, expectedAsset("style.css"), content.getBytes()); }