NamespaceService { public List<Namespace> findPublicAppNamespaceAllNamespaces(String namespaceName, Pageable page) { AppNamespace publicAppNamespace = appNamespaceService.findPublicNamespaceByName(namespaceName); if (publicAppNamespace == null) { throw new BadRequestException( String.format("Public appNamespace not exists. NamespaceName = %s", namespaceName)); } List<Namespace> namespaces = namespaceRepository.findByNamespaceName(namespaceName, page); return filterChildNamespace(namespaces); } NamespaceService(
      final ReleaseHistoryService releaseHistoryService,
      final NamespaceRepository namespaceRepository,
      final AuditService auditService,
      final @Lazy AppNamespaceService appNamespaceService,
      final MessageSender messageSender,
      final @Lazy ItemService itemService,
      final CommitService commitService,
      final @Lazy ReleaseService releaseService,
      final @Lazy ClusterService clusterService,
      final @Lazy NamespaceBranchService namespaceBranchService,
      final NamespaceLockService namespaceLockService,
      final InstanceService instanceService); Namespace findOne(Long namespaceId); Namespace findOne(String appId, String clusterName, String namespaceName); Namespace findPublicNamespaceForAssociatedNamespace(String clusterName, String namespaceName); List<Namespace> findPublicAppNamespaceAllNamespaces(String namespaceName, Pageable page); int countPublicAppNamespaceAssociatedNamespaces(String publicNamespaceName); List<Namespace> findNamespaces(String appId, String clusterName); List<Namespace> findByAppIdAndNamespaceName(String appId, String namespaceName); Namespace findChildNamespace(String appId, String parentClusterName, String namespaceName); Namespace findChildNamespace(Namespace parentNamespace); Namespace findParentNamespace(String appId, String clusterName, String namespaceName); Namespace findParentNamespace(Namespace namespace); boolean isChildNamespace(String appId, String clusterName, String namespaceName); boolean isChildNamespace(Namespace namespace); boolean isNamespaceUnique(String appId, String cluster, String namespace); @Transactional void deleteByAppIdAndClusterName(String appId, String clusterName, String operator); @Transactional Namespace deleteNamespace(Namespace namespace, String operator); @Transactional Namespace save(Namespace entity); @Transactional Namespace update(Namespace namespace); @Transactional void instanceOfAppNamespaces(String appId, String clusterName, String createBy); Map<String, Boolean> namespacePublishInfo(String appId);  }
@Test(expected = BadRequestException.class) public void testFindPublicAppNamespaceWithWrongNamespace() { Pageable page = PageRequest.of(0, 10); when(appNamespaceService.findPublicNamespaceByName(testPublicAppNamespace)).thenReturn(null); namespaceService.findPublicAppNamespaceAllNamespaces(testPublicAppNamespace, page); }