DataToVariableMigrationStep implements MigrationStep<T> { @Override public void migrate(T artifact) { logger.info(format( "[MIGRATION] Convert all data to variables in page [%s]", artifact.getName()) ); }  @Override void migrate(T artifact);  }
@Test public void should_migrate_page_with_data() throws Exception { Page pageWithData = aPage().withId("pageWithData").withData("myData", DataBuilder.aConstantData().value("default value").build()).build(); dataToVariableMigrationStep.migrate(pageWithData); assertThat(pageWithData.getVariables().get("myData").getValue()).isEqualTo(Arrays.asList("default value")); assertThat(pageWithData.getData()).isNull(); }
@Test public void should_migrate_page_with_data_with_null_value() throws Exception { Page pageWithData = aPage().withId("pageWithData").withData("myEmptyData", DataBuilder.aConstantData().exposed(true).build()).build(); dataToVariableMigrationStep.migrate(pageWithData); Variable variable = pageWithData.getVariables().get("myEmptyData"); assertThat(variable.getValue()).isEmpty(); assertThat(variable.isExposed()).isTrue(); assertThat(pageWithData.getData()).isNull(); }