UniqueIDGenerator { public String createAccordionID(String name) { StringBuilder randomString = new StringBuilder(); Random random = new Random(); for (int i = 0; i < 5; i++) { randomString.append(random.nextInt(26)); } return name.replaceAll("\\s", "") + randomString.toString(); }  String createContainerID(); String createRowID(String containerID); String createColumnID(String rowID); String createAccordionID(String name);  }
@Test public void testCreateAccordionID() { String accordionID = "accordionID"; String accordionID1 = idGenerator.createAccordionID(accordionID); String accordionID2 = idGenerator.createAccordionID(accordionID); assertNotEquals(accordionID, accordionID2); assertNotEquals(accordionID1, accordionID2); }
@Test public void testCreateAccordionIDShouldRemoveSpaces() { String accordionID = "accordionID"; String accordionID1 = idGenerator.createAccordionID(accordionID); assertTrue(accordionID1.contains(accordionID)); accordionID = "accordion ID"; accordionID1 = idGenerator.createAccordionID(accordionID); assertTrue(!accordionID1.contains(accordionID)); }