InstanceConfigController { @GetMapping("/by-namespace/count") public long getInstancesCountByNamespace(@RequestParam("appId") String appId, @RequestParam("clusterName") String clusterName, @RequestParam("namespaceName") String namespaceName) { Page<Instance> instances = instanceService.findInstancesByNamespace(appId, clusterName, namespaceName, PageRequest.of(0, 1)); return instances.getTotalElements(); } InstanceConfigController(final ReleaseService releaseService, final InstanceService instanceService); @GetMapping("/by-release") PageDTO<InstanceDTO> getByRelease(@RequestParam("releaseId") long releaseId,
                                           Pageable pageable); @GetMapping("/by-namespace-and-releases-not-in") List<InstanceDTO> getByReleasesNotIn(@RequestParam("appId") String appId,
                                              @RequestParam("clusterName") String clusterName,
                                              @RequestParam("namespaceName") String namespaceName,
                                              @RequestParam("releaseIds") String releaseIds); @GetMapping("/by-namespace") PageDTO<InstanceDTO> getInstancesByNamespace(
      @RequestParam("appId") String appId, @RequestParam("clusterName") String clusterName,
      @RequestParam("namespaceName") String namespaceName,
      @RequestParam(value = "instanceAppId", required = false) String instanceAppId,
      Pageable pageable); @GetMapping("/by-namespace/count") long getInstancesCountByNamespace(@RequestParam("appId") String appId,
                                          @RequestParam("clusterName") String clusterName,
                                          @RequestParam("namespaceName") String namespaceName);  }
@Test public void testGetInstancesCountByNamespace() throws Exception { String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someNamespaceName = "someNamespaceName"; Page<Instance> instances = new PageImpl<>(Collections.emptyList(), pageable, 2); when(instanceService.findInstancesByNamespace(eq(someAppId), eq(someClusterName), eq(someNamespaceName), any(Pageable.class))).thenReturn(instances); long result = instanceConfigController.getInstancesCountByNamespace(someAppId, someClusterName, someNamespaceName); assertEquals(2, result); }