Code example for Column

Methods: equalsgetCanonicalNameisUnique

0
		assertNotNull(uniqueKey);
		 
		assertEquals(1, uniqueKey.getColumnSpan() );
		 
		Column keyCol = uniqueKey.getColumn(0);
		assertTrue(keyCol.isUnique() );
		 
		assertSame(keyCol, table.getColumn(keyCol) );
		 
	} 
	 
	public void testWithIndex() { 
		 
		Table table = getTable(identifier("withIndex") );
		 
		assertEqualIdentifiers("withIndex", table.getName() );
		 
		assertNull("there should be no pk", table.getPrimaryKey() );
		Iterator iterator = table.getIndexIterator();
	 
		 
		int cnt=0;
		while(iterator.hasNext() ) {
			iterator.next();
			cnt++;
		} 
		assertEquals(1, cnt);
		 
		Index index = table.getIndex(identifier("myIndex") );
		 
		assertNotNull("No index ?", index);
		assertEqualIdentifiers("myIndex", index.getName() );
		 
		assertEquals(2, index.getColumnSpan() );
		 
		assertSame(index.getTable(), table);
		Iterator cols = index.getColumnIterator();
		Column col1 = (Column) cols.next();
		Column col2 = (Column) cols.next();
		 
		assertEqualIdentifiers("first", col1.getName() );
		assertEqualIdentifiers("third", col2.getName() );
		 
		Column example = new Column();
		example.setName(col2.getName() );
		assertSame("column with same name should be same instance!", table.getColumn(example), col2);			
 
	} 
	 
	public static Test suite() {
		return new TestSuite(IndexTest.class);
	} 
} 
Experience pair programming with AI  Get Codota for Java