<commit_before>/**
 * Copyright (C) 2011 Akiban Technologies Inc.
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses.
 */

package com.akiban.server.test.it.keyupdate;

import com.akiban.message.ErrorCode;
import com.akiban.server.IndexDef;
import com.akiban.server.InvalidOperationException;
import com.akiban.server.RowDef;
import com.akiban.server.api.dml.scan.NewRow;
import com.akiban.server.test.it.ITBase;
import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;

import static com.akiban.server.test.it.keyupdate.Schema.c_cid;
import static com.akiban.server.test.it.keyupdate.Schema.c_cx;
import static com.akiban.server.test.it.keyupdate.Schema.customerRowDef;
import static com.akiban.server.test.it.keyupdate.Schema.groupRowDef;
import static com.akiban.server.test.it.keyupdate.Schema.i_iid;
import static com.akiban.server.test.it.keyupdate.Schema.i_ix;
import static com.akiban.server.test.it.keyupdate.Schema.i_oid;
import static com.akiban.server.test.it.keyupdate.Schema.itemRowDef;
import static com.akiban.server.test.it.keyupdate.Schema.o_cid;
import static com.akiban.server.test.it.keyupdate.Schema.o_oid;
import static com.akiban.server.test.it.keyupdate.Schema.o_ox;
import static com.akiban.server.test.it.keyupdate.Schema.o_priority;
import static com.akiban.server.test.it.keyupdate.Schema.o_when;
import static com.akiban.server.test.it.keyupdate.Schema.orderRowDef;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;

public abstract class KeyUpdateBase extends ITBase {
    @Before
    public final void before() throws Exception
    {
        testStore = new TestStore(persistitStore());
        rowDefsToCounts = new TreeMap<Integer, Integer>();
        createSchema();
        confirmColumns();
        populateTables();
    }

    private void confirmColumns() {
        // TODO
    }

    @Test
    @SuppressWarnings("unused") // JUnit will invoke this
    public void testInitialState() throws Exception
    {
        checkDB();
        checkInitialState();
    }

    @Test
    @SuppressWarnings("unused") // JUnit will invoke this
    public void testOrderPriorityUpdate() throws Exception
    {
        // Set customer.priority = 80 for order 33
        TestRow oldOrderRow = testStore.find(new HKey(customerRowDef, 3L, orderRowDef, 33L));
        TestRow newOrderRow = copyRow(oldOrderRow);
        updateRow(newOrderRow, o_priority, 80L, null);
        dbUpdate(oldOrderRow, newOrderRow);
        checkDB();
    }

    @Test
    @SuppressWarnings("unused") // JUnit will invoke this
    public void testOrderPriorityUpdateCreatingDuplicate() throws Exception
    {
        // Set customer.priority = 81 for order 33. Duplicates are fine.
        TestRow oldOrderRow = testStore.find(new HKey(customerRowDef, 3L, orderRowDef, 33L));
        TestRow newOrderRow = copyRow(oldOrderRow);
        updateRow(newOrderRow, o_priority, 81L, null);
        dbUpdate(oldOrderRow, newOrderRow);
        checkDB();<commit_msg>Filling in confirmColumns()<commit_after>/**
 * Copyright (C) 2011 Akiban Technologies Inc.
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses.
 */

package com.akiban.server.test.it.keyupdate;

import com.akiban.message.ErrorCode;
import com.akiban.server.FieldDef;
import com.akiban.server.IndexDef;
import com.akiban.server.InvalidOperationException;
import com.akiban.server.RowDef;
import com.akiban.server.api.dml.scan.NewRow;
import com.akiban.server.test.it.ITBase;
import com.akiban.util.ArgumentValidation;
import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;

import static com.akiban.server.test.it.keyupdate.Schema.c_cid;
import static com.akiban.server.test.it.keyupdate.Schema.c_cx;
import static com.akiban.server.test.it.keyupdate.Schema.customerRowDef;
import static com.akiban.server.test.it.keyupdate.Schema.groupRowDef;
import static com.akiban.server.test.it.keyupdate.Schema.i_iid;
import static com.akiban.server.test.it.keyupdate.Schema.i_ix;
import static com.akiban.server.test.it.keyupdate.Schema.i_oid;
import static com.akiban.server.test.it.keyupdate.Schema.itemRowDef;
import static com.akiban.server.test.it.keyupdate.Schema.o_cid;
import static com.akiban.server.test.it.keyupdate.Schema.o_oid;
import static com.akiban.server.test.it.keyupdate.Schema.o_ox;
import static com.akiban.server.test.it.keyupdate.Schema.o_priority;
import static com.akiban.server.test.it.keyupdate.Schema.o_when;
import static com.akiban.server.test.it.keyupdate.Schema.orderRowDef;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;

public abstract class KeyUpdateBase extends ITBase {
    @Before
    public final void before() throws Exception
    {
        testStore = new TestStore(persistitStore());
        rowDefsToCounts = new TreeMap<Integer, Integer>();
        createSchema();
        confirmColumns();
        populateTables();
    }

    private void confirmColumns() {
        confirmColumn(customerRowDef, c_cid, "cid");
        confirmColumn(customerRowDef, c_cx, "cx");

        confirmColumn(orderRowDef, o_oid, "oid");
        confirmColumn(orderRowDef, o_cid, "cid");
        confirmColumn(orderRowDef, o_ox, "ox");
        confirmColumn(orderRowDef, o_priority, "priority");
        confirmColumn(orderRowDef, o_when, "when");

        confirmColumn(itemRowDef, i_iid, "iid");
        confirmColumn(itemRowDef, i_oid, "oid");
        confirmColumn(itemRowDef, i_ix, "ix");
    }

    private void confirmColumn(RowDef rowDef, Integer expectedId, String columnName) {
        assert columnName != null;
        assert rowDef != null;
        assertNotNull("column ID for " + columnName, expectedId);
        FieldDef fieldDef = rowDef.getFieldDef(expectedId);
        assertNotNull("no fieldDef with id="+expectedId + ", name="+columnName, fieldDef);
        assertEquals("fieldDef name", columnName, fieldDef.getName());
    }


    @Test
    @SuppressWarnings("unused") // JUnit will invoke this
    public void testInitialState() throws Exception
    {
        checkDB();
        checkInitialState();
    }

    @Test
    @SuppressWarnings("unused") // JUnit will invoke this
    public void testOrderPriorityUpdate() throws Exception
    {
        // Set customer.priority = 80 for order 33
        TestRow oldOrderRow = testStore.find(new HKey(customerRowDef, 3L, orderRowDef, 33L));
        TestRow newOrderRow = copyRow(oldOrderRow);
        updateRow(newOrderRow, o_priority, 80L, null);
        dbUpdate(oldOrderRow, newOrderRow);
        checkDB();
    }

    @Test
    @SuppressWarnings("unused") // JUnit will invoke this
    public void testOrderPriorityUpdateCreatingDuplicate() throws Exception
    {
        // Set customer.priority = 81 for order 33. Duplicates are fine.
        TestRow oldOrderRow = testStore.find(new HKey(customerRowDef, 3L, orderRowDef, 33L));
        TestRow newOrderRow = copyRow(oldOrderRow);
        updateRow(newOrderRow, o_priority, 81L, null);
        dbUpdate(oldOrderRow, newOrderRow);
        checkDB();
{'fraction_non_alphanumeric': 0.09966178128523112, 'fraction_numerical': 0.005186020293122886, 'mean_word_length': 3.9174057649667406, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1694842', 'n_tokens_mistral': 2688, 'n_tokens_neox': 2617, 'n_words': 668}