diff options
| author | Brian S. O'Neill <bronee@gmail.com> | 2006-11-04 00:27:28 +0000 | 
|---|---|---|
| committer | Brian S. O'Neill <bronee@gmail.com> | 2006-11-04 00:27:28 +0000 | 
| commit | ba6161a7d971dbcc4f3bc44ef8ce4c2b3963a955 (patch) | |
| tree | f78dcf13ff21af15bd8309cf7ed2d9c1c01cba52 | |
| parent | 5677066e44c31c26f939770dc5231e0e48670750 (diff) | |
Fixed exception when printing join plan with blank parameters.
| -rw-r--r-- | src/test/java/com/amazon/carbonado/filter/TestFilterSuppliedValues.java | 120 | 
1 files changed, 120 insertions, 0 deletions
diff --git a/src/test/java/com/amazon/carbonado/filter/TestFilterSuppliedValues.java b/src/test/java/com/amazon/carbonado/filter/TestFilterSuppliedValues.java new file mode 100644 index 0000000..ff12948 --- /dev/null +++ b/src/test/java/com/amazon/carbonado/filter/TestFilterSuppliedValues.java @@ -0,0 +1,120 @@ +/*
 + * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
 + * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
 + * of Amazon Technologies, Inc. or its affiliates.  All rights reserved.
 + *
 + * Licensed under the Apache License, Version 2.0 (the "License");
 + * you may not use this file except in compliance with the License.
 + * You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +
 +package com.amazon.carbonado.filter;
 +
 +import junit.framework.TestCase;
 +import junit.framework.TestSuite;
 +
 +import com.amazon.carbonado.stored.Order;
 +
 +/**
 + * 
 + *
 + * @author Brian S O'Neill
 + */
 +public class TestFilterSuppliedValues extends TestCase {
 +    public static void main(String[] args) {
 +        junit.textui.TestRunner.run(suite());
 +    }
 +
 +    public static TestSuite suite() {
 +        return new TestSuite(TestFilterSuppliedValues.class);
 +    }
 +
 +    public TestFilterSuppliedValues(String name) {
 +        super(name);
 +    }
 +
 +    public void testSuppliedValuesFor() {
 +        Filter<Order> open = Filter.getOpenFilter(Order.class);
 +        Filter<Order> f1 = open.and("orderTotal", RelOp.EQ);
 +        Filter<Order> f2 = open.and("orderNumber", RelOp.EQ, "20");
 +
 +        Filter<Order> f = f1.and(f2).bind();
 +        FilterValues<Order> fv = f.initialFilterValues();
 +
 +        Object[] values = fv.getSuppliedValuesFor(f);
 +        assertEquals(0, values.length);
 +
 +        values = fv.with(10).getSuppliedValuesFor(f);
 +        assertEquals(1, values.length);
 +        assertEquals(new Integer(10), values[0]);
 +
 +        // Again, with reverse arrangement.
 +        f = f2.and(f1).bind();
 +        fv = f.initialFilterValues();
 +
 +        values = fv.getSuppliedValuesFor(f);
 +        assertEquals(0, values.length);
 +
 +        values = fv.with(10).getSuppliedValuesFor(f);
 +        assertEquals(1, values.length);
 +        assertEquals(new Integer(10), values[0]);
 +
 +        // Now test with some values set and some blank.
 +        Filter<Order> f3 = open.and("orderComments", RelOp.GT);
 +
 +        f = f1.and(f2).and(f3).bind();
 +        fv = f.initialFilterValues();
 +
 +        values = fv.getSuppliedValuesFor(f);
 +        assertEquals(0, values.length);
 +
 +        values = fv.with(10).getSuppliedValuesFor(f);
 +        assertEquals(1, values.length);
 +        assertEquals(new Integer(10), values[0]);
 +
 +        values = fv.with(10).with("hello").getSuppliedValuesFor(f);
 +        assertEquals(2, values.length);
 +        assertEquals(new Integer(10), values[0]);
 +        assertEquals("hello", values[1]);
 +
 +        // Arrange differently.
 +        f = f2.and(f1).and(f3).bind();
 +        fv = f.initialFilterValues();
 +
 +        values = fv.getSuppliedValuesFor(f);
 +        assertEquals(0, values.length);
 +
 +        values = fv.with(10).getSuppliedValuesFor(f);
 +        assertEquals(1, values.length);
 +        assertEquals(new Integer(10), values[0]);
 +
 +        values = fv.with(10).with("hello").getSuppliedValuesFor(f);
 +        assertEquals(2, values.length);
 +        assertEquals(new Integer(10), values[0]);
 +        assertEquals("hello", values[1]);
 +
 +        // Arrange differently again.
 +        f = f3.and(f1).and(f2).bind();
 +        fv = f.initialFilterValues();
 +
 +        values = fv.getSuppliedValuesFor(f);
 +        assertEquals(0, values.length);
 +
 +        values = fv.with("hello").getSuppliedValuesFor(f);
 +        assertEquals(1, values.length);
 +        assertEquals("hello", values[0]);
 +
 +        values = fv.with("hello").with(5).getSuppliedValuesFor(f);
 +        assertEquals(2, values.length);
 +        assertEquals("hello", values[0]);
 +        assertEquals(new Integer(5), values[1]);
 +    }
 +}
  | 
