/** Prints the simple insert statements that will be used in testing (for exporting purposes) */ @Test(groups = "doc") public void printCollectionSelectStatements() { String objective = "Collection Select Statements"; System.out.println(String.format("Printing %s...", objective)); for (String execute_string : COLLECTION_SELECT_STATEMENTS.values()) { System.out.println(execute_string); } System.out.println(String.format("\nEnd of %s\n\n", objective)); }
/** Test simple statement selects for all collection data types */ @SuppressWarnings("unchecked") public void collectionSelectTest() throws Throwable { HashMap<DataType, Object> sampleValueMap; String execute_string; DataType typeArgument1; DataType typeArgument2; Row row; for (DataType dataType : COLLECTION_SELECT_STATEMENTS.keySet()) { execute_string = COLLECTION_SELECT_STATEMENTS.get(dataType); row = session.execute(execute_string).one(); sampleValueMap = (HashMap<DataType, Object>) SAMPLE_COLLECTIONS.get(dataType); typeArgument1 = dataType.getTypeArguments().get(0); if (dataType.getName() == DataType.Name.MAP) { typeArgument2 = dataType.getTypeArguments().get(1); // Create a copy of the map that is being expected HashMap<DataType, Object> sampleMap = (HashMap<DataType, Object>) sampleValueMap.get(typeArgument1); Object mapKey = SAMPLE_DATA.get(sampleMap.keySet().iterator().next()); Object mapValue = sampleMap.values().iterator().next(); HashMap<Object, Object> expectedMap = new HashMap<Object, Object>(); expectedMap.put(mapKey, mapValue); assertEquals(TestUtils.getValue(row, "k", typeArgument2), SAMPLE_DATA.get(typeArgument2)); assertEquals(TestUtils.getValue(row, "v", dataType), expectedMap); } else { Object expectedValue = sampleValueMap.get(typeArgument1); assertEquals(TestUtils.getValue(row, "k", typeArgument1), SAMPLE_DATA.get(typeArgument1)); assertEquals(TestUtils.getValue(row, "v", dataType), expectedValue); } } assertEquals(SAMPLE_COLLECTIONS.size(), 255); assertEquals(COLLECTION_SELECT_STATEMENTS.keySet().size(), SAMPLE_COLLECTIONS.size()); }