ArrayUtils { public static boolean keysPresentInColumns(String[] keys, String[] columns) { boolean allKeysPresent = true; for (String key : keys) { if (!containsKey(columns, key)) { allKeysPresent = false; } } return allKeysPresent; }  static T[] mergeArrays(T[] one, T[] two); static boolean keysPresentInColumns(String[] keys, String[] columns); static String[] convertStringKeyToArray(String keys, String delimiter); static String[] convertStringKeyToArray(String keys); static int[] getCompareColumnsPosition(String[] columns, String[] keyColumns); static List<Integer> getColumnsPosition(String[] columns, String[] keyColumns); static boolean isIndexOfLastArrayElement(String[] array, int elementIndex);  }
@Test public void testCheckKeyColumnsWithMatchingRecords() throws Exception { List<String> key = new ArrayList<String>(); key.add("test1"); key.add("test2"); List<String> columns = new ArrayList<String>(); columns.add("test1"); columns.add("test2"); boolean test = ArrayUtils.keysPresentInColumns(key.toArray(new String[] {}), columns.toArray(new String[] {})); Assert.assertTrue(test); }
@Test public void testCheckKeyColumnsWithMatchingWithMissingKey() throws Exception { List<String> key = new ArrayList<String>(); key.add("test1"); key.add("test2"); List<String> columns = new ArrayList<String>(); columns.add("test1"); boolean test = ArrayUtils.keysPresentInColumns(key.toArray(new String[] {}), columns.toArray(new String[] {})); Assert.assertFalse(test); }