怎样解决Original must not null

本文介绍了如何解决因Bean缺少SET方法而导致的问题,并提供了一种快速查找相关类的方法——使用Eclipse的快捷键Ctrl+Shift+T进行搜索。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原因是某个Bean缺少SET方法, 自己一个个找去。

 

 

ctrl+ shift +t Eclipse找类

 

``` public class GenericTests { // Implementations to test: static Dictionary<String, Integer> slowArray = null; static Dictionary<String, Integer> fastHashTable = null; static Dictionary<String, Integer> fastBST = null; static final int TEST_COUNT = 100; static Pair<String, Integer> [] array; static int index = 0; static Integer testValue; static boolean testResult; // One test method uses these: static Dictionary<Person,PhoneNumber> dict; static PhoneNumber foundValue = null; @BeforeAll static void allocateDataStructures() { try { slowArray = new KeyValueArray<>(25); fastHashTable = new KeyValueHashTable<>(25); fastBST = new KeyValueBSearchTree<>(); } catch (Exception e) { e.printStackTrace(); fail("Could not instantiate some of the Dictionary implementations"); } } @Test //@Timeout(value = 60, threadMode = Timeout.ThreadMode.SEPARATE_THREAD) @DisplayName("Tests KeyValueArray, slow linear array") void testSlowArray() { try { List<String> randomList = new ArrayList<>(); for (int index = 0; index < TEST_COUNT; index++) { randomList.add(String.valueOf(index)); } Collections.shuffle(randomList); for (index = 0; index < TEST_COUNT; index++) { assertDoesNotThrow( () -> slowArray.add(randomList.get(index), Integer.parseInt(randomList.get(index))), () -> "add must not throw"); } System.out.println(">> Testing key-value array with " + slowArray.size() + " entries"); assertEquals(TEST_COUNT, slowArray.size(), () -> "Inserted count must match"); for (index = 0; index < TEST_COUNT; index++) { assertDoesNotThrow( () -> testValue = slowArray.find(String.valueOf(index)), () -> "find must not throw."); assertEquals(testValue, index, () -> "Inserted and retrieved values must match"); } assertNull(slowArray.find("1999"), () -> "Must return null when element not in table"); assertDoesNotThrow(() -> array = slowArray.toSortedArray(), "toSortedArray must not throw"); assertTrue(isSorted(array), () -> "slowArray.toSortedArray() does not sort correctly"); assertEquals(randomList.size(), array.length, () -> "Test array and toSortedArray lengths do not match"); Object [] originalArray = randomList.toArray(); Arrays.sort(originalArray); for (int index = 0; index < TEST_COUNT; index++) { assertTrue(originalArray[index].equals(array[index].getKey()), () -> "Array elements do not match"); } int elements = slowArray.size(); assertDoesNotThrow(() -> slowArray.compress(), () -> "Compressing the storage should not throw"); assertEquals(elements, slowArray.size(), () -> "After compression must have same number of elements than before"); assertDoesNotThrow(() -> array = slowArray.toSortedArray(), "toSortedArray must not throw"); for (int index = 0; index < TEST_COUNT; index++) { assertTrue(originalArray[index].equals(array[index].getKey()), () -> "Array elements do not match"); } } catch (Exception e) { e.printStackTrace(); fail("Something went wrong in the test." + e.getMessage()); } }```这段代码测试未通过在哪修改
最新发布
03-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值