AppNamespaceController { @PostMapping("/apps/{appId}/appnamespaces") public AppNamespaceDTO create(@RequestBody AppNamespaceDTO appNamespace, @RequestParam(defaultValue = "false") boolean silentCreation) { AppNamespace entity = BeanUtils.transform(AppNamespace.class, appNamespace); AppNamespace managedEntity = appNamespaceService.findOne(entity.getAppId(), entity.getName()); if (managedEntity == null) { if (StringUtils.isEmpty(entity.getFormat())){ entity.setFormat(ConfigFileFormat.Properties.getValue()); } entity = appNamespaceService.createAppNamespace(entity); } else if (silentCreation) { appNamespaceService.createNamespaceForAppNamespaceInAllCluster(appNamespace.getAppId(), appNamespace.getName(), appNamespace.getDataChangeCreatedBy()); entity = managedEntity; } else { throw new BadRequestException("app namespaces already exist."); } return BeanUtils.transform(AppNamespaceDTO.class, entity); } AppNamespaceController(
      final AppNamespaceService appNamespaceService,
      final NamespaceService namespaceService); @PostMapping("/apps/{appId}/appnamespaces") AppNamespaceDTO create(@RequestBody AppNamespaceDTO appNamespace,
                                @RequestParam(defaultValue = "false") boolean silentCreation); @DeleteMapping("/apps/{appId}/appnamespaces/{namespaceName:.+}") void delete(@PathVariable("appId") String appId, @PathVariable("namespaceName") String namespaceName,
      @RequestParam String operator); @GetMapping("/appnamespaces/{publicNamespaceName}/namespaces") List<NamespaceDTO> findPublicAppNamespaceAllNamespaces(@PathVariable String publicNamespaceName, Pageable pageable); @GetMapping("/appnamespaces/{publicNamespaceName}/associated-namespaces/count") int countPublicAppNamespaceAssociatedNamespaces(@PathVariable String publicNamespaceName); @GetMapping("/apps/{appId}/appnamespaces") List<AppNamespaceDTO> getAppNamespaces(@PathVariable("appId") String appId);  }
@Test @Sql(scripts = "/controller/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) public void testCreate(){ String appId = "6666"; String name = "testnamespace"; String comment = "comment"; AppNamespaceDTO dto = new AppNamespaceDTO(); dto.setAppId(appId); dto.setName(name); dto.setComment(comment); dto.setDataChangeCreatedBy("apollo"); AppNamespaceDTO resultDto = restTemplate.postForEntity( String.format("http: Assert.assertEquals(appId, resultDto.getAppId()); Assert.assertTrue(resultDto.getId() > 0); AppNamespace savedAppNs = namespaceRepository.findByAppIdAndName(appId, name); Assert.assertNotNull(savedAppNs); Assert.assertNotNull(savedAppNs.getDataChangeCreatedTime()); Assert.assertNotNull(savedAppNs.getDataChangeLastModifiedTime()); Assert.assertNotNull(savedAppNs.getDataChangeLastModifiedBy()); Assert.assertNotNull(savedAppNs.getDataChangeCreatedBy()); }