StyleUpdateInputRequiredLabelMigrationStep 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] Update content property in control-required css class in asset [%s] to %s [%s]", asset.getName(), artifact.getType(), artifact.getName())); } catch (IOException e) { logger.error("An error occurred during migration", e); } } } } @Inject  StyleUpdateInputRequiredLabelMigrationStep(@Named("pageAssetService") AssetService<Page> assetService); @Override void migrate(Page artifact);  }
@Test public void should_migrate_style_asset_to_only_update_control_label_required_content_property() throws Exception { Asset style = anAsset().withType(CSS).withName("style.css").build(); String initContent = "\n" + ".control-label--required:after {\n" + " content: \"*\";\n" + " color: #C00;\n" + "}" + "\".ping .pong {\n\" +\n" + " content: \"*\";\n\" +\n" + " color: #C00;\n\" +\n" + " \"}"; Page page = aPage() .withVersion("1.11.30").withAsset(style).build(); when(pageAssetService.getAssetContent(page, style)).thenReturn(initContent); String finalContent = "\n" + ".control-label--required:after {\n" + " content: \" *\";\n" + " color: #C00;\n" + "}" + "\".ping .pong {\n\" +\n" + " content: \"*\";\n\" +\n" + " color: #C00;\n\" +\n" + " \"}"; step.migrate(page); verify(pageAssetService).save(page, expectedAsset("style.css"), finalContent.getBytes()); }