AssetExternalMigrationStep implements MigrationStep<A> { @Override public void migrate(A artifact) { for (Asset asset : artifact.getAssets()) { asset.setExternal(isAssetURL(asset.getName())); logger.info( format("[MIGRATION] Asset <%s> with id <%s> has been identified as %s (external property was introduced in 1.2)", asset.getName(), asset.getId(), (asset.isExternal() ? "external" : "internal"))); } }  @Override void migrate(A artifact); static boolean isAssetURL(String name);  }
@Test public void should_migrate_artifact_assets() throws Exception { AssetExternalMigrationStep<Page> migrationStep = new AssetExternalMigrationStep<>(); Page page = aPage() .withAsset(anAsset() .withName("bonita.jpg")) .withAsset(anAsset() .withName("http: .build(); migrationStep.migrate(page); assertThat(page.getAssets()) .extracting("name", "external") .containsOnly( tuple("bonita.jpg", false), tuple("http: }
@Test public void should_not_change_an_asset_external_property() throws Exception { AssetExternalMigrationStep<Page> migrationStep = new AssetExternalMigrationStep<>(); Page page = aPage() .withAsset(anAsset() .withExternal(false).withName("bonita.jpg")) .withAsset(anAsset() .withExternal(true).withName("https: .build(); migrationStep.migrate(page); assertThat(page.getAssets()) .extracting("name", "external") .containsOnly( tuple("bonita.jpg", false), tuple("https: }