InterceptorCore { protected String handleIteration(final String input) { String response = ""; boolean inSequence = false; char activeChar = ' '; int activeCharLength = 0; for (int i = 0; i < input.length(); i++) { if (!inSequence) { activeChar = input.charAt(i); activeCharLength = 1; inSequence = true; } else { if (activeChar == input.charAt(i)) { activeCharLength++; } else { response = response + activeCharLength + activeChar; activeChar = input.charAt(i); activeCharLength = 1; } } } if (input.length() > 0) { response = response + activeCharLength + activeChar; } return response; }    }
@Test public void testMinimumCall() { String response = underTest.handleIteration(""); assertTrue(response.length() == 0); }
@Test public void test1() { String response = underTest.handleIteration("1"); assertTrue("11".equals(response)); }
@Test public void test11() { String response = underTest.handleIteration("11"); assertTrue("21".equals(response)); }
@Test public void test21() { String response = underTest.handleIteration("21"); assertTrue("1211".equals(response)); }
@Test public void test1211() { String response = underTest.handleIteration("1211"); assertTrue("111221".equals(response)); }
@Test public void test1971() { String response = underTest.handleIteration("1971"); assertTrue("11191711".equals(response)); }