package com.akiban.ais.util;

import static junit.framework.Assert.assertEquals;

import org.junit.Test;

import com.akiban.ais.model.AISBuilder;
import com.akiban.ais.model.AkibaInformationSchema;

public final class DDLGeneratorTest {

    @Test
    public void testCreateTable() throws Exception {
        AISBuilder builder = new AISBuilder();
        builder.userTable("schema", "table");
        builder.column("schema", "table", "col", 0, "decimal unsigned", 11L, 3L, true, false, null, null);
        builder.basicSchemaIsComplete();
        builder.createGroup("myGroup", "akiba_objects", "_group0");
        builder.addTableToGroup("myGroup", "schema", "table");
        builder.groupingIsComplete();

        AkibaInformationSchema ais = builder.akibaInformationSchema();
        DDLGenerator generator = new DDLGenerator();

        assertEquals("group table",
                "create table `akiba_objects`.`_group0`(`table$col` decimal(11, 3) unsigned, `table$__akiban_pk` bigint ,  key group_index_0(`table$__akiban_pk`)) engine=akibandb",
                generator.createTable(ais.getGroup("myGroup").getGroupTable()));
    }
}

package com.akiban.ais.util;

import static junit.framework.Assert.assertEquals;

import org.junit.Test;

import com.akiban.ais.model.AISBuilder;
import com.akiban.ais.model.AkibaInformationSchema;

public final class DDLGeneratorTest {

    @Test
    public void testCreateTable() throws Exception {
        AISBuilder builder = new AISBuilder();
        builder.userTable("schema", "table");
        builder.column("schema", "table", "col", 0, "decimal unsigned", 11L, 3L, true, false, null, null);
        builder.basicSchemaIsComplete();
        builder.createGroup("myGroup", "akiba_objects", "_group0");
        builder.addTableToGroup("myGroup", "schema", "table");
        builder.groupingIsComplete();

        AkibaInformationSchema ais = builder.akibaInformationSchema();
        DDLGenerator generator = new DDLGenerator();

        assertEquals("group table",
                "create table `akiba_objects`.`_group0`(`table$col` decimal(11, 3) unsigned, `table$__akiban_pk` bigint ,  key table$__akiban_pk(`table$__akiban_pk`)) engine=akibandb",
                generator.createTable(ais.getGroup("myGroup").getGroupTable()));
    }
}

Fix index name in DDLGeneratorTest. 'group_index_0' is now 'table'