### Question:
ContainmentAcceptorControlImpl extends AbstractAcceptorControl implements ContainmentAcceptorControl<AbstractCanvasHandler> { static boolean areInSameParent(final Element parent, final Node[] children) { return Stream.of(children) .map(GraphUtils::getParent) .noneMatch(childParent -> !Objects.equals(parent, childParent)); } @Inject  ContainmentAcceptorControlImpl(final CanvasCommandFactory<AbstractCanvasHandler> canvasCommandFactory,
                                          final CanvasHighlight canvasHighlight); @Override boolean allow(final Element parent,
                         final Node[] children); @Override boolean accept(final Element parent,
                          final Node[] children);  }### Answer:
@Test public void testIsSameParent() { Node parent = new NodeImpl<>("parentUUID"); Node child1 = new NodeImpl<>("child1"); setAsChild(parent, child1); Node child2 = new NodeImpl<>("child2"); setAsChild(parent, child2); Node[] children = {child1, child2}; boolean isSameParent = ContainmentAcceptorControlImpl.areInSameParent(parent, children); assertTrue(isSameParent); }
@Test public void testIsNotSameParent1() { Node parent = new NodeImpl<>("parentUUID"); Node child1 = new NodeImpl<>("child1"); Node child2 = new NodeImpl<>("child2"); setAsChild(parent, child2); Node[] children = {child1, child2}; boolean isSameParent = ContainmentAcceptorControlImpl.areInSameParent(parent, children); assertFalse(isSameParent); }
@Test public void testIsNotSameParent2() { Node parent = new NodeImpl<>("parentUUID"); Node child1 = new NodeImpl<>("child1"); setAsChild(parent, child1); Node child2 = new NodeImpl<>("child2"); Node[] children = {child1, child2}; boolean isSameParent = ContainmentAcceptorControlImpl.areInSameParent(parent, children); assertFalse(isSameParent); }
@Test public void testIsNotSameParentAll() { Node parent = new NodeImpl<>("parentUUID"); Node child1 = new NodeImpl<>("child1"); Node child2 = new NodeImpl<>("child2"); Node[] children = {child1, child2}; boolean isSameParent = ContainmentAcceptorControlImpl.areInSameParent(parent, children); assertFalse(isSameParent); }
@Test public void testIsNotSameParentNull() { Node parent = new NodeImpl<>("parentUUID"); Node child1 = new NodeImpl<>("child1"); setAsChild(parent, child1); Node child2 = new NodeImpl<>("child2"); setAsChild(parent, child2); Node[] children = {child1, child2}; boolean isSameParent = ContainmentAcceptorControlImpl.areInSameParent(null, children); assertFalse(isSameParent); }