@PostMapping("/apps/{appId}/clusters/{clusterName}/namespaces")
  public NamespaceDTO create(@PathVariable("appId") String appId,
                             @PathVariable("clusterName") String clusterName,
                             @Valid @RequestBody NamespaceDTO dto) {
    Namespace entity = BeanUtils.transform(Namespace.class, dto);
    Namespace managedEntity = namespaceService.findOne(appId, clusterName, entity.getNamespaceName());
    if (managedEntity != null) {
      throw BadRequestException.namespaceAlreadyExists(entity.getNamespaceName());
    }

    entity = namespaceService.save(entity);

    return BeanUtils.transform(NamespaceDTO.class, entity);
  }
@Test
  public void create() {
    try {
      NamespaceDTO namespaceDTO = new NamespaceDTO();
      namespaceDTO.setClusterName("cluster");
      namespaceDTO.setNamespaceName("invalid name");
      namespaceDTO.setAppId("whatever");
      restTemplate.postForEntity(
          url("/apps/{appId}/clusters/{clusterName}/namespaces"),
          namespaceDTO, NamespaceDTO.class, namespaceDTO.getAppId(), namespaceDTO.getClusterName());
      Assert.fail("Should throw");
    } catch (HttpClientErrorException e) {
      Assert.assertThat(new String(e.getResponseBodyAsByteArray()), containsString(InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE));
    }
  }