PageRenderTime 25ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tst/org/diffkit/diff/conf/tst/TestAutomaticTableComparison.groovy

http://diffkit.googlecode.com/
Groovy | 61 lines | 37 code | 6 blank | 18 comment | 4 complexity | 0986a0bebfebf9dca7282ae0d6a38270 MD5 | raw file
 1/**
 2 * Copyright 2010-2011 Joseph Panico
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 *   http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.diffkit.diff.conf.tst
17
18import org.diffkit.diff.conf.DKAutomaticTableComparison;
19import org.diffkit.diff.engine.DKColumnModel
20import org.diffkit.diff.engine.DKDiff;
21import org.diffkit.diff.engine.DKTableModel 
22import org.diffkit.diff.sns.DKFileSource 
23
24import groovy.util.GroovyTestCase
25
26
27/**
28 * @author jpanico
29 */
30public class TestAutomaticTableComparison extends GroovyTestCase {
31	
32	public void testDefault(){
33		def lhsFileResourcePath = 'org/diffkit/diff/conf/tst/test.lhs.csv'
34		def rhsFileResourcePath = 'org/diffkit/diff/conf/tst/test.rhs.csv'
35		DKColumnModel column1 = [0, 'column1', DKColumnModel.Type.STRING]
36		DKColumnModel column2 = [1, 'column2', DKColumnModel.Type.STRING]
37		DKColumnModel column3 = [2, 'column3', DKColumnModel.Type.INTEGER]
38		DKColumnModel column4 = [3, 'column4', DKColumnModel.Type.STRING]
39		DKColumnModel[] columns = [column1, column2, column3, column4]
40		int[] key = [0,3]
41		DKTableModel lhsTable = ['lhs.table', columns, key]
42		DKTableModel rhsTable = ['rhs.table', columns, key]
43		DKFileSource lhsFileSource = [lhsFileResourcePath, lhsTable, null, "\\,"]
44		DKFileSource rhsFileSource = [rhsFileResourcePath, rhsTable, null, "\\,"]
45		
46		def defaultComparison = new DKAutomaticTableComparison( lhsFileSource, rhsFileSource, DKDiff.Kind.BOTH, null, null, null, Long.MAX_VALUE, null, null).standardComparison
47		println "defaultComparison->${defaultComparison.description}"
48		assert defaultComparison
49		def map = defaultComparison.map
50		assert map
51		assert map.size()== 4
52		map.each { assert (it._lhsColumn == it._rhsColumn) }
53		def diffIndexes = defaultComparison.diffIndexes
54		assert diffIndexes
55		assert diffIndexes == [1,2]
56		def displayIndexes = defaultComparison.displayIndexes
57		assert displayIndexes
58		assert displayIndexes == [[0,3],[0,3]]
59		assert defaultComparison.maxDiffs == Long.MAX_VALUE
60	}
61}