/** * Tests the {@link CommonUtils#toStringArray(ArrayList)} method. */ @Test public void toStringArray() { class TestCase { String[] mExpected; public TestCase(String... strings) { mExpected = strings; } } List<TestCase> testCases = new ArrayList<>(); testCases.add(new TestCase()); testCases.add(new TestCase("foo")); testCases.add(new TestCase("foo", "bar")); for (TestCase testCase : testCases) { ArrayList<String> input = new ArrayList<>(); Collections.addAll(input, testCase.mExpected); String[] got = CommonUtils.toStringArray(input); assertEquals(testCase.mExpected.length, got.length); for (int k = 0; k < got.length; k++) { assertEquals(testCase.mExpected[k], got[k]); } } }
hosts.add(addr.getHost()); blockLocations.add(new BlockLocation(CommonUtils.toStringArray(names), CommonUtils.toStringArray(hosts), offset, info.getBlockInfo().getLength()));