
package com.exedio.cope.lib;

public class ReportTest extends DatabaseLibTest
{
	private static final String TABLE1 = "AttributeItem";
	private static final String TABLE1X = "AttributeItemX";
	private static final String COLUMN1 = "someInteger";
	private static final String COLUMN1X = "someIntegerX";
	
	public void testReport()
	{
		final String column1Type;
		{
			final Report report = model.reportDatabase();

			final ReportTable table = report.getTable(TABLE1);
			assertNotNull(table);
			assertEquals(null, table.getError());
			assertEquals(Report.COLOR_OK, table.getParticularColor());

			final ReportColumn column = table.getColumn(COLUMN1);
			assertEquals(null, column.getError());
			assertEquals(Report.COLOR_OK, column.getParticularColor());
			column1Type = column.getDatabaseType();
			assertNotNull(column1Type);
			
			column.renameTo(COLUMN1X);
		}
		{
			final Report report = model.reportDatabase();

			final ReportTable table = report.getTable(TABLE1);
			assertNotNull(table);
			assertEquals(null, table.getError());
			assertEquals(Report.COLOR_OK, table.getParticularColor());

			{
				final ReportColumn column = table.getColumn(COLUMN1);
				assertEquals("missing", column.getError());
				assertEquals(Report.COLOR_RED, column.getParticularColor());
				assertEquals(column1Type, column.getDatabaseType());
			}
			{
				final ReportColumn columnX = table.getColumn(COLUMN1X);
				assertEquals("not used", columnX.getError());
				assertEquals(Report.COLOR_YELLOW, columnX.getParticularColor());
				assertEquals(column1Type, columnX.getDatabaseType());

				columnX.renameTo(COLUMN1);
			}
		}
		{
			final Report report = model.reportDatabase();

			final ReportTable table = report.getTable(TABLE1);
			assertNotNull(table);
			assertEquals(null, table.getError());
			assertEquals(Report.COLOR_OK, table.getParticularColor());

			final ReportColumn column = table.getColumn(COLUMN1);
			assertEquals(null, column.getError());
			assertEquals(Report.COLOR_OK, column.getParticularColor());
			assertEquals(column1Type, column.getDatabaseType());
		}
	}
	
}

@@ -355,20 +355,28 @@
 n1Type;%0A
+%09%09// OK%0A
 %09%09%7B%0A
-
 %09%09%09final
@@ -870,24 +870,44 @@
 UMN1X);%0A%09%09%7D%0A
+%09%09// COLUMN RENAMED%0A
 %09%09%7B%0A%09%09%09final
@@ -1648,20 +1648,1020 @@
 );%0A%09%09%09%7D%0A
-
 %09%09%7D%0A
+%09%09// OK%0A%09%09%7B%0A%09%09%09final Report report = model.reportDatabase();%0A%0A%09%09%09final ReportTable table = report.getTable(TABLE1);%0A%09%09%09assertNotNull(table);%0A%09%09%09assertEquals(null, table.getError());%0A%09%09%09assertEquals(Report.COLOR_OK, table.getParticularColor());%0A%0A%09%09%09final ReportColumn column = table.getColumn(COLUMN1);%0A%09%09%09assertEquals(null, column.getError());%0A%09%09%09assertEquals(Report.COLOR_OK, column.getParticularColor());%0A%09%09%09assertEquals(column1Type, column.getDatabaseType());%0A%0A%09%09%09column.drop();%0A%09%09%7D%0A%09%09// COLUMN DROPPED%0A%09%09%7B%0A%09%09%09final Report report = model.reportDatabase();%0A%0A%09%09%09final ReportTable table = report.getTable(TABLE1);%0A%09%09%09assertNotNull(table);%0A%09%09%09assertEquals(null, table.getError());%0A%09%09%09assertEquals(Report.COLOR_OK, table.getParticularColor());%0A%0A%09%09%09final ReportColumn column = table.getColumn(COLUMN1);%0A%09%09%09assertEquals(%22missing%22, column.getError());%0A%09%09%09assertEquals(Report.COLOR_RED, column.getParticularColor());%0A%09%09%09assertEquals(column1Type, column.getDatabaseType());%0A%0A%09%09%09column.create();%0A%09%09%7D%0A%09%09// OK%0A
 %09%09%7B%0A%09%09%09f

test dropped column