### Question:
CollaborativeStoreElementVisitor implements ElementVisitor { @Override public void visit(SessionContext context, ElementContext elementContext, Space space, CoreElement element) { elementCommandFactory.executeCommand(context, elementContext, space, element); setSubElementsHierarchyPosition(element); } private  CollaborativeStoreElementVisitor(); static CollaborativeStoreElementVisitor init(); @Override void visit(SessionContext context, ElementContext elementContext, Space space,
                    CoreElement element);  }### Answer:
@Test public void testVisitElementWithoutSubs() throws Exception { SessionContext context = TestUtils.createSessionContext(USER, "test"); ElementContext elementContext = new ElementContext(new Id(), new Id()); Space space = Space.PRIVATE; CoreElement element = new CoreElement(); visitor.visit(context, elementContext, space, element); verify(elementCommandFactoryMock).executeCommand(context, elementContext, space, element); }
@Test public void testVisitElementWithSubs() throws Exception { SessionContext context = TestUtils.createSessionContext(USER, "test"); ElementContext elementContext = new ElementContext(new Id(), new Id()); Space space = Space.PRIVATE; CoreElement element = new CoreElement(); element.setId(new Id()); element.setNamespace(Namespace.ROOT_NAMESPACE); element.setSubElements(Arrays.asList(new CoreElement(), new CoreElement(), new CoreElement())); visitor.visit(context, elementContext, space, element); verify(elementCommandFactoryMock).executeCommand(context, elementContext, space, element); element.getSubElements().forEach(subElement -> { Assert.assertEquals(subElement.getParentId(), element.getId()); Assert.assertEquals(subElement.getNamespace(), new Namespace(element.getNamespace(), element.getId())); }); }