@Test public void testExtractPrimaryKey() throws Exception { final String id = "id"; User user = new User(); user.setId(id); Serializable privaryKey = ParameterUtil.extractPrimaryKey(user); Assert.assertEquals(privaryKey, id); }
@Test @SuppressWarnings("unchecked") public void testObject() throws Exception { User user = new User(); user.setId("id"); user.setUsername("makersoft"); user.setPassword("password"); user.setAge(20); Object obj = ParameterUtil.resolve(user, shardId); Assert.assertTrue(obj instanceof Map); Map<String, Object> map = (Map<String, Object>) obj; Assert.assertEquals(PREFIX_VALUE, map.get(PREFIX)); Assert.assertEquals(SUFFIX_VALUE, map.get(SUFFIX)); Assert.assertEquals(user.getId(), map.get("id")); Assert.assertEquals(user.getUsername(), map.get("username")); Assert.assertEquals(user.getPassword(), map.get("password")); Assert.assertEquals(user.getAge(), map.get("age")); }