@Override public Set<Relation> relations() { return subNode().relations().stream() .map(relation -> new DynamicRelation(dynamicAtlas(), relation.getIdentifier())) .collect(Collectors.toSet()); }
/** * Create a full copy of the given node. * * @param node * the {@link Node} to deep copy * @return the new {@link CompleteNode} */ public static CompleteNode from(final Node node) { return new CompleteNode(node.getIdentifier(), node.getLocation(), node.getTags(), node.inEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new)), node.outEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new)), node.relations().stream().map(Relation::getIdentifier).collect(Collectors.toSet())); }
@Test public void testFull() { final Atlas atlas = this.rule.getAtlas(); final Node source = atlas.node(1); final CompleteNode result = CompleteNode.from(source); Assert.assertEquals(source.getIdentifier(), result.getIdentifier()); Assert.assertEquals(source.bounds(), result.bounds()); Assert.assertEquals(source.getLocation(), result.getLocation()); Assert.assertEquals( source.inEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new)), result.inEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new))); Assert.assertEquals( source.outEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new)), result.outEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new))); Assert.assertEquals(source.getTags(), result.getTags()); Assert.assertEquals( source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet()), result.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet())); }
Assert.assertEquals(outEdgeIdentifiers, result.outEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new))); result.withRelationIdentifiers(source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet())); Assert.assertEquals( source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet()), result.relations().stream().map(Relation::getIdentifier)
@Test public void addTurnRestrictions() { resetAndChange("addTurnRestrictions", new AtlasChangeGeneratorAddTurnRestrictions()); final Node via = this.changeAtlas.node(3985226613000000L); final Relation restriction = via.relations().iterator().next(); Assert.assertNotNull(restriction); final RelationBean members = new RelationBean(); members.addItem(221434099000002L, "from", ItemType.EDGE); members.addItem(via.getIdentifier(), "via", ItemType.NODE); members.addItem(634444999000000L, "to", ItemType.EDGE); members.addItem(-634444999000000L, "to", ItemType.EDGE); Assert.assertEquals(members, restriction.members().asBean()); }
mergeRelationMembers(node.relations(), relationIdentifier)))); result.add(FeatureChange.add(CompleteEdge.shallowFrom(outEdge) .withRelationIdentifiers(mergeRelationMembers(outEdge.relations(),
resourceWithRelation); Assert.assertTrue(!multiAtlas.node(1L).relations().isEmpty());