1 /* 2 * Copyright (C) 2009 The Guava Authors 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 */ 16 17 package com.google.common.collect; 18 19 /** 20 * Tests {@link ForwardingTable}. 21 * 22 * @author Gregory Kick 23 */ 24 public class ForwardingTableTest extends ForwardingTestCase { 25 26 private Table<String, Integer, Boolean> forward; 27 28 @Override public void setUp() throws Exception { 29 super.setUp(); 30 /* 31 * Class parameters must be raw, so we can't create a proxy with generic 32 * type arguments. The created proxy only records calls and returns null, so 33 * the type is irrelevant at runtime. 34 */ 35 @SuppressWarnings("unchecked") 36 final Table<String, Integer, Boolean> table = 37 createProxyInstance(Table.class); 38 forward = new ForwardingTable<String, Integer, Boolean>() { 39 @Override protected Table<String, Integer, Boolean> delegate() { 40 return table; 41 } 42 }; 43 } 44 45 public void testHashCode() { 46 forward.hashCode(); 47 assertEquals("[hashCode]", getCalls()); 48 } 49 50 public void testCellSet() { 51 forward.cellSet(); 52 assertEquals("[cellSet]", getCalls()); 53 } 54 55 public void testClear() { 56 forward.clear(); 57 assertEquals("[clear]", getCalls()); 58 } 59 60 public void testColumn() { 61 forward.column(1); 62 assertEquals("[column(Object)]", getCalls()); 63 } 64 65 public void testColumnKeySet() { 66 forward.columnKeySet(); 67 assertEquals("[columnKeySet]", getCalls()); 68 } 69 70 public void testColumnMap() { 71 forward.columnMap(); 72 assertEquals("[columnMap]", getCalls()); 73 } 74 75 public void testContains() { 76 forward.contains("blah", 1); 77 assertEquals("[contains(Object,Object)]", getCalls()); 78 } 79 80 public void testContainsColumn() { 81 forward.containsColumn(1); 82 assertEquals("[containsColumn(Object)]", getCalls()); 83 } 84 85 public void testContainsRow() { 86 forward.containsRow("blah"); 87 assertEquals("[containsRow(Object)]", getCalls()); 88 } 89 90 public void testContainsValue() { 91 forward.containsValue(false); 92 assertEquals("[containsValue(Object)]", getCalls()); 93 } 94 95 public void testGet() { 96 forward.get("blah", 1); 97 assertEquals("[get(Object,Object)]", getCalls()); 98 } 99 100 public void testIsEmpty() { 101 forward.isEmpty(); 102 assertEquals("[isEmpty]", getCalls()); 103 } 104 105 public void testPut() { 106 forward.put("blah", 1, false); 107 assertEquals("[put(Object,Object,Object)]", getCalls()); 108 } 109 110 public void testPutAll() { 111 forward.putAll(HashBasedTable.<String, Integer, Boolean>create()); 112 assertEquals("[putAll(Table)]", getCalls()); 113 } 114 115 public void testRemove() { 116 forward.remove("blah", 1); 117 assertEquals("[remove(Object,Object)]", getCalls()); 118 } 119 120 public void testRow() { 121 forward.row("String"); 122 assertEquals("[row(Object)]", getCalls()); 123 } 124 125 public void testRowKeySet() { 126 forward.rowKeySet(); 127 assertEquals("[rowKeySet]", getCalls()); 128 } 129 130 public void testRowMap() { 131 forward.rowMap(); 132 assertEquals("[rowMap]", getCalls()); 133 } 134 135 public void testSize() { 136 forward.size(); 137 assertEquals("[size]", getCalls()); 138 } 139 140 public void testValues() { 141 forward.values(); 142 assertEquals("[values]", getCalls()); 143 } 144 145 public void testEqualsObject() { 146 forward.equals(null); 147 assertEquals("[equals(Object)]", getCalls()); 148 } 149 150 } 151