JsonFinder { protected ArrayList<SubText> getSubTexts(List<Integer> ints) { final ArrayList<SubText> subTexts = new ArrayList<>(); int startPosition = 0; int lastValue = 0; for (int i = 0; i < ints.size(); i++) { final int currentValue = ints.get(i); if (currentValue == 0 && lastValue > 0) { subTexts.add(new SubText(startPosition, i + 1)); } else if (currentValue > 0 && lastValue == 0) { startPosition = i; } lastValue = currentValue; } return subTexts; }  ArrayList<SubText> findJsonFragments(String string);  }
@Test(dataProvider = "testGetSubTexts") public void testGetSubTexts(String openParenthesisString, List<SubText> expected) throws Exception { List<Integer> openParenthesis = new ArrayList<>(); for (int i = 0; i < openParenthesisString.length(); i++) { openParenthesis.add(Integer.parseInt(openParenthesisString.substring(i,i+1))); } final ArrayList<SubText> actual = underTest.getSubTexts(openParenthesis); Assert.assertEquals(actual,expected); }