### Question:
UtilsAndCommons { public static int shakeUp(String string, int upperLimit) { if (upperLimit < 1) { throw new IllegalArgumentException("upper limit must be greater than 0"); } if (string == null) { return 0; } return (string.hashCode() & Integer.MAX_VALUE) % upperLimit; }  static Map<String, String> parseMetadata(String metadata); static String assembleFullServiceName(String namespaceId, String serviceName); static int shakeUp(String string, int upperLimit); static final String NACOS_SERVER_CONTEXT; static final String NACOS_SERVER_VERSION; static final String DEFAULT_NACOS_NAMING_CONTEXT; static final String NACOS_NAMING_CONTEXT; static final String NACOS_NAMING_CATALOG_CONTEXT; static final String NACOS_NAMING_INSTANCE_CONTEXT; static final String NACOS_NAMING_SERVICE_CONTEXT; static final String NACOS_NAMING_CLUSTER_CONTEXT; static final String NACOS_NAMING_HEALTH_CONTEXT; static final String NACOS_NAMING_RAFT_CONTEXT; static final String NACOS_NAMING_PARTITION_CONTEXT; static final String NACOS_NAMING_OPERATOR_CONTEXT; static final String NACOS_SERVER_HEADER; static final String NACOS_VERSION; static final String SUPER_TOKEN; static final String DOMAINS_DATA_ID_PRE; static final String IPADDRESS_DATA_ID_PRE; static final String SWITCH_DOMAIN_NAME; static final String CIDR_REGEX; static final String UNKNOWN_SITE; static final String DEFAULT_CLUSTER_NAME; static final String LOCALHOST_SITE; static final int RAFT_PUBLISH_TIMEOUT; static final String SERVER_VERSION; static final String SELF_SERVICE_CLUSTER_ENV; static final String CACHE_KEY_SPLITER; static final String LOCAL_HOST_IP; static final String IP_PORT_SPLITER; static final int MAX_PUBLISH_WAIT_TIME_MILLIS; static final String VERSION_STRING_SYNTAX; static final String API_UPDATE_SWITCH; static final String API_SET_ALL_WEIGHTS; static final String API_DOM; static final String NAMESPACE_SERVICE_CONNECTOR; static final String UPDATE_INSTANCE_ACTION_ADD; static final String UPDATE_INSTANCE_ACTION_REMOVE; static final String DATA_BASE_DIR; static final String RAFT_CACHE_FILE_SUFFIX; static final String RAFT_CACHE_FILE_PREFIX; static final String NUMBER_PATTERN; }### Answer:
@Test(expected = IllegalArgumentException.class) public void testShakeUpException() { UtilsAndCommons.shakeUp(null, 0); }
@Test public void testShakeUp() { Assert.assertEquals(0, UtilsAndCommons.shakeUp(null, 1)); char[] chars = new char[] {2325, 9, 30, 12, 2}; Assert.assertEquals(0, UtilsAndCommons.shakeUp(new String(chars), 1)); }