### Question:
ClusterController { @PutMapping @Secured(action = ActionTypes.WRITE) public String update(HttpServletRequest request) throws Exception { String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, Constants.DEFAULT_NAMESPACE_ID); String clusterName = WebUtils.required(request, CommonParams.CLUSTER_NAME); String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME); String healthChecker = WebUtils.required(request, "healthChecker"); String metadata = WebUtils.optional(request, "metadata", StringUtils.EMPTY); String checkPort = WebUtils.required(request, "checkPort"); String useInstancePort4Check = WebUtils.required(request, "useInstancePort4Check"); Service service = serviceManager.getService(namespaceId, serviceName); if (service == null) { throw new NacosException(NacosException.INVALID_PARAM, "service not found:" + serviceName); } Cluster cluster = service.getClusterMap().get(clusterName); if (cluster == null) { Loggers.SRV_LOG.warn("[UPDATE-CLUSTER] cluster not exist, will create it: {}, service: {}", clusterName, serviceName); cluster = new Cluster(clusterName, service); } cluster.setDefCkport(NumberUtils.toInt(checkPort)); cluster.setUseIPPort4Check(BooleanUtils.toBoolean(useInstancePort4Check)); JSONObject healthCheckObj = JSON.parseObject(healthChecker); AbstractHealthChecker abstractHealthChecker; String type = healthCheckObj.getString("type"); Class<AbstractHealthChecker> healthCheckClass = HealthCheckType.ofHealthCheckerClass(type); if(healthCheckClass == null){ throw new NacosException(NacosException.INVALID_PARAM, "unknown health check type:" + healthChecker); } abstractHealthChecker = JSON.parseObject(healthChecker, healthCheckClass); cluster.setHealthChecker(abstractHealthChecker); cluster.setMetadata(UtilsAndCommons.parseMetadata(metadata)); cluster.init(); service.getClusterMap().put(clusterName, cluster); service.setLastModifiedMillis(System.currentTimeMillis()); service.recalculateChecksum(); service.validate(); serviceManager.addOrReplaceService(service); return "ok"; }  @PutMapping @Secured(action = ActionTypes.WRITE) String update(HttpServletRequest request);  }### Answer:
@Test public void testUpdate() throws Exception { Service service = new Service(TEST_SERVICE_NAME); service.setNamespaceId("test-namespace"); when(serviceManager.getService(Constants.DEFAULT_NAMESPACE_ID, TEST_SERVICE_NAME)).thenReturn(service); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.put(UtilsAndCommons.NACOS_NAMING_CONTEXT + "/cluster") .param("clusterName", TEST_CLUSTER_NAME) .param("serviceName", TEST_SERVICE_NAME) .param("healthChecker", "{\"type\":\"HTTP\"}") .param("checkPort", "1") .param("useInstancePort4Check", "true"); Assert.assertEquals("ok", mockmvc.perform(builder).andReturn().getResponse().getContentAsString()); Cluster expectedCluster = new Cluster(TEST_CLUSTER_NAME, service); Cluster actualCluster = service.getClusterMap().get(TEST_CLUSTER_NAME); Assert.assertEquals(expectedCluster, actualCluster); Assert.assertEquals(1, actualCluster.getDefCkport()); Assert.assertTrue(actualCluster.isUseIPPort4Check()); }