### Question:
FaceQueueUtil { public static void connectQueues(FaceNode firstFace, FaceNode secondFace) { ValidateUtil.validateNotNull(firstFace.list(), "firstFace.list"); ValidateUtil.validateNotNull(secondFace.list(), "secondFace.list"); if (firstFace.list() == secondFace.list()) { if (!firstFace.isEnd() || !secondFace.isEnd()) { throw new IllegalStateException("try to connect the same list not on end nodes"); } if (firstFace.isQueueUnconnected() || secondFace.isQueueUnconnected()) { throw new IllegalStateException("can't close node queue not conected with edges"); } firstFace.queueClose(); return; } if (!firstFace.isQueueUnconnected() && !secondFace.isQueueUnconnected()) { throw new IllegalStateException("can't connect two diffrent queues if each of them is connected to edge"); } if (!firstFace.isQueueUnconnected()) { FaceQueue qLeft = secondFace.getFaceQueue(); moveNodes(firstFace, secondFace); qLeft.close(); } else { FaceQueue qRight = firstFace.getFaceQueue(); moveNodes(secondFace, firstFace); qRight.close(); } } private  FaceQueueUtil(); static void connectQueues(FaceNode firstFace, FaceNode secondFace);  }### Answer:
@Test public void test1() { FaceNode n1 = debugNewQueue("n1", true); FaceNode n2 = debugNewQueue("n2"); PathQueue<FaceNode> q1 = n1.list(); PathQueue<FaceNode> q2 = n2.list(); FaceQueueUtil.connectQueues(n1, n2); assertEquals(2, q1.size()); assertEquals(0, q2.size()); assertFalse(((FaceQueue) q1).isClosed()); assertTrue(((FaceQueue) q2).isClosed()); }
@Test public void test2() { FaceNode n1 = debugNewQueue("n1", true); FaceNode n2 = debugNode("n2"); n1.addPush(n2); PathQueue<FaceNode> q1 = n1.list(); PathQueue<FaceNode> q2 = n2.list(); FaceQueueUtil.connectQueues(n1, n2); assertEquals(2, q1.size()); assertEquals(q1, q2); assertTrue(((FaceQueue) q1).isClosed()); assertTrue(((FaceQueue) q2).isClosed()); }
@Test(expected = IllegalStateException.class) public void test3() { FaceNode n1 = debugNewQueue("n1", true); FaceNode n2 = debugNode("n2"); FaceNode n3 = debugNode("n3"); n1.addPush(n2); n2.addPush(n3); FaceQueueUtil.connectQueues(n1, n2); fail(); }
@Test(expected = IllegalStateException.class) public void test4() { FaceNode n1 = debugNewQueue("n1", true); FaceNode n2 = debugNewQueue("n2", true); FaceQueueUtil.connectQueues(n1, n2); fail(); }