public NamespaceBO loadNamespaceBO(String appId, Env env, String clusterName,
      String namespaceName, boolean includeDeletedItems) {
    NamespaceDTO namespace = namespaceAPI.loadNamespace(appId, env, clusterName, namespaceName);
    if (namespace == null) {
      throw BadRequestException.namespaceNotExists(appId, clusterName, namespaceName);
    }
    return transformNamespace2BO(env, namespace, includeDeletedItems);
  }
@Test
  public void testLoadNamespaceBO() {
    String branchName = "branch";
    NamespaceDTO namespaceDTO = createNamespace(testAppId, branchName, testNamespaceName);
    when(namespaceAPI.loadNamespace(any(), any(), any(), any())).thenReturn(namespaceDTO);

    ReleaseDTO releaseDTO = new ReleaseDTO();
    releaseDTO.setConfigurations("{\"k1\":\"k1\",\"k2\":\"k2\", \"k3\":\"\"}");
    when(releaseService.loadLatestRelease(any(), any(), any(), any())).thenReturn(releaseDTO);

    List<ItemDTO> itemDTOList = Lists.newArrayList();
    ItemDTO itemDTO1 = new ItemDTO();
    itemDTO1.setId(1);
    itemDTO1.setNamespaceId(1);
    itemDTO1.setKey("k1");
    itemDTO1.setValue(String.valueOf(1));
    itemDTOList.add(itemDTO1);

    ItemDTO itemDTO2 = new ItemDTO();
    itemDTO2.setId(2);
    itemDTO2.setNamespaceId(2);
    itemDTO2.setKey("k2");
    itemDTO2.setValue(String.valueOf(2));
    itemDTOList.add(itemDTO2);
    when(itemService.findItems(any(), any(), any(), any())).thenReturn(itemDTOList);

    List<ItemDTO> deletedItemDTOList = Lists.newArrayList();
    ItemDTO deletedItemDTO = new ItemDTO();
    deletedItemDTO.setId(3);
    deletedItemDTO.setNamespaceId(3);
    deletedItemDTO.setKey("k3");
    deletedItemDTOList.add(deletedItemDTO);
    when(itemService.findDeletedItems(any(), any(), any(), any())).thenReturn(deletedItemDTOList);

    NamespaceBO namespaceBO1 = namespaceService.loadNamespaceBO(testAppId, testEnv, testClusterName, testNamespaceName);
    List<String> namespaceKey1 = namespaceBO1.getItems().stream().map(s -> s.getItem().getKey()).collect(Collectors.toList());
    assertThat(namespaceBO1.getItemModifiedCnt()).isEqualTo(3);
    assertThat(namespaceBO1.getItems().size()).isEqualTo(3);
    assertThat(namespaceKey1).isEqualTo(Arrays.asList("k1", "k2", "k3"));

    NamespaceBO namespaceBO2 = namespaceService.loadNamespaceBO(testAppId, testEnv, testClusterName, testNamespaceName, false);
    List<String> namespaceKey2 = namespaceBO2.getItems().stream().map(s -> s.getItem().getKey()).collect(Collectors.toList());
    assertThat(namespaceBO2.getItemModifiedCnt()).isEqualTo(2);
    assertThat(namespaceBO2.getItems().size()).isEqualTo(2);
    assertThat(namespaceKey2).isEqualTo(Arrays.asList("k1", "k2"));
  }