BondMigrationStep implements MigrationStep<T> { @Override public void migrate(AbstractPage page) { for (Component component : page.accept(componentVisitor)) { Widget widget = widgetRepository.get(component.getId()); for (Entry<String, PropertyValue> entry : component.getPropertyValues().entrySet()) { Property property = widget.getProperty(entry.getKey()); String formerType = entry.getValue().getType(); migrationStrategies .get(property != null ? property.getBond() : BondType.EXPRESSION) .migrate(property, entry.getValue()); logTypeChange(component.getId(), formerType, entry); } } for(Element element: page.accept(visitorFactory.createAnyContainerVisitor())) { for (Map.Entry<String, PropertyValue> entry : element.getPropertyValues().entrySet()) { migrationStrategies .get(BondType.EXPRESSION) .migrate(new Property(), entry.getValue()); logTypeChange(element.getClass().getSimpleName(), entry.getValue().getType(), entry); } } } BondMigrationStep(ComponentVisitor componentVisitor, WidgetRepository widgetRepository, VisitorFactory visitorFactory); @Override void migrate(AbstractPage page);  }
@Test public void should_migrate_constant_property() throws Exception { property.setBond(CONSTANT); property.setDefaultValue("baz"); bondMigrationStep.migrate(page); PropertyValue foo = component.getPropertyValues().get("foo"); assertThat(foo.getType()).isEqualTo("constant"); assertThat(foo.getValue()).isEqualTo("baz"); }
@Test public void should_migrate_interpolated_property() throws Exception { property.setBond(INTERPOLATION); bondMigrationStep.migrate(page); PropertyValue foo = component.getPropertyValues().get("foo"); assertThat(foo.getType()).isEqualTo("interpolation"); assertThat(foo.getValue()).isEqualTo("{{bar}}"); }
@Test public void should_migrate_expression_property() throws Exception { property.setBond(EXPRESSION); bondMigrationStep.migrate(page); PropertyValue foo = component.getPropertyValues().get("foo"); assertThat(foo.getType()).isEqualTo("expression"); assertThat(foo.getValue()).isEqualTo("bar"); }
@Test public void should_migrate_variable_property() throws Exception { property.setBond(VARIABLE); bondMigrationStep.migrate(page); PropertyValue foo = component.getPropertyValues().get("foo"); assertThat(foo.getType()).isEqualTo("variable"); assertThat(foo.getValue()).isEqualTo("bar"); }
@Test public void should_migrate_a_container_properties() throws Exception { property.setBond(VARIABLE); bondMigrationStep.migrate(page); PropertyValue foo = container.getPropertyValues().get("foo"); assertThat(foo.getType()).isEqualTo("expression"); assertThat(foo.getValue()).isEqualTo("bar"); }