KeyUtils { public static String userToken(String type, Integer uid) { Preconditions.checkNotNull(type); Preconditions.checkNotNull(uid); return String.format("account:%s:%d", type, uid); }  static String userToken(String type, Integer uid);  }
@Test(expected = NullPointerException.class) public void userTokenWithNullType() { KeyUtils.userToken(null, 0); }
@Test(expected = NullPointerException.class) public void userTokenWithNullUid() { KeyUtils.userToken(new String(), null); }
@Test(expected = NullPointerException.class) public void userTokenWithNullTypeAndUid() { KeyUtils.userToken(null, null); }
@Test public void userToken() { String type = "type"; Integer uid = 1; String result = KeyUtils.userToken(type, uid); assertNotNull(result); assertFalse(result.isEmpty()); assertTrue(result.startsWith("account:")); assertTrue(result.contains(type)); assertTrue(result.contains(String.valueOf(uid))); }