AppNamespaceService { @Transactional public void createDefaultAppNamespace(String appId) { if (!isAppNamespaceNameUnique(appId, ConfigConsts.NAMESPACE_APPLICATION)) { throw new BadRequestException(String.format("App already has application namespace. AppId = %s", appId)); } AppNamespace appNs = new AppNamespace(); appNs.setAppId(appId); appNs.setName(ConfigConsts.NAMESPACE_APPLICATION); appNs.setComment("default app namespace"); appNs.setFormat(ConfigFileFormat.Properties.getValue()); String userId = userInfoHolder.getUser().getUserId(); appNs.setDataChangeCreatedBy(userId); appNs.setDataChangeLastModifiedBy(userId); appNamespaceRepository.save(appNs); } AppNamespaceService(
      final UserInfoHolder userInfoHolder,
      final AppNamespaceRepository appNamespaceRepository,
      final RoleInitializationService roleInitializationService,
      final @Lazy AppService appService,
      final RolePermissionService rolePermissionService); List<AppNamespace> findPublicAppNamespaces(); AppNamespace findPublicAppNamespace(String namespaceName); AppNamespace findByAppIdAndName(String appId, String namespaceName); List<AppNamespace> findByAppId(String appId); @Transactional void createDefaultAppNamespace(String appId); boolean isAppNamespaceNameUnique(String appId, String namespaceName); AppNamespace createAppNamespaceInLocal(AppNamespace appNamespace); @Transactional AppNamespace createAppNamespaceInLocal(AppNamespace appNamespace, boolean appendNamespacePrefix); @Transactional AppNamespace deleteAppNamespace(String appId, String namespaceName); void batchDeleteByAppId(String appId, String operator);  }
@Test @Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) public void testCreateDefaultAppNamespace() { appNamespaceService.createDefaultAppNamespace(APP); AppNamespace appNamespace = appNamespaceService.findByAppIdAndName(APP, ConfigConsts.NAMESPACE_APPLICATION); Assert.assertNotNull(appNamespace); Assert.assertEquals(ConfigFileFormat.Properties.getValue(), appNamespace.getFormat()); }