use of com.enonic.xp.core.impl.content.serializer.ComponentDataSerializer.COMPONENTS in project xp by enonic.
the class PageDataSerializerTest method page_deserialize_custom_order_of_components.
@Test
public void page_deserialize_custom_order_of_components() {
final Page page = createPage();
final PropertyTree pageAsData = new PropertyTree();
pageDataSerializer.toData(page, pageAsData.getRoot());
final List<PropertySet> componentsAsData = pageAsData.getRoot().getProperties(COMPONENTS).stream().filter(Property::hasNotNullValue).map(item -> item.getSet()).collect(Collectors.toList());
final List<PropertySet> customOrdercomponentsAsData = new ArrayList<>();
customOrdercomponentsAsData.add(componentsAsData.get(7));
customOrdercomponentsAsData.add(componentsAsData.get(11));
customOrdercomponentsAsData.add(componentsAsData.get(4));
customOrdercomponentsAsData.add(componentsAsData.get(3));
customOrdercomponentsAsData.add(componentsAsData.get(1));
customOrdercomponentsAsData.add(componentsAsData.get(10));
customOrdercomponentsAsData.add(componentsAsData.get(5));
customOrdercomponentsAsData.add(componentsAsData.get(6));
customOrdercomponentsAsData.add(componentsAsData.get(8));
customOrdercomponentsAsData.add(componentsAsData.get(2));
customOrdercomponentsAsData.add(componentsAsData.get(0));
customOrdercomponentsAsData.add(componentsAsData.get(9));
final PropertySet root = new PropertySet();
customOrdercomponentsAsData.forEach(componentData -> root.addSet(COMPONENTS, componentData));
final Page parsedPage = pageDataSerializer.fromData(root);
assertEquals(page, parsedPage);
}
Aggregations