### Question:
CyclicRotationString { public static boolean isCyclicRotation(String a, String b) { if (a.length() != b.length()) return false; KMPplus kmp = new KMPplus(b); return kmp.search(a + a) != -1; }  static boolean isCyclicRotation(String a, String b);  }### Answer:
@Test public void basicTest() { Assert.assertTrue(CyclicRotationString.isCyclicRotation("abc", "bca")); Assert.assertTrue(CyclicRotationString.isCyclicRotation("abc", "cab")); Assert.assertTrue(CyclicRotationString.isCyclicRotation("abcd", "cdab")); Assert.assertFalse(CyclicRotationString.isCyclicRotation("abc", "bac")); Assert.assertFalse(CyclicRotationString.isCyclicRotation("abc", "ab")); }
@Test public void randomTest() { Random r = new Random(); for (int i = 100; i < 100000; i++) { int len = (int) Math.sqrt(i); String cur = RandomStringBuilder.randomStringLowerCase(len); if (r.nextBoolean()) { Assert.assertTrue(CyclicRotationString.isCyclicRotation(cur, cur.substring(len / 2) + cur.substring(0, len / 2))); } else { Assert.assertFalse(CyclicRotationString.isCyclicRotation(cur, RandomStringBuilder.randomStringLowerCase(len))); } } Assert.assertTrue(CyclicRotationString.isCyclicRotation("abc", "cab")); Assert.assertTrue(CyclicRotationString.isCyclicRotation("abcd", "cdab")); Assert.assertFalse(CyclicRotationString.isCyclicRotation("abc", "bac")); }