Java 类org.springframework.test.context.jdbc.Sql 实例源码

项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-public-dc-override.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicConfigWithDataCenterFoundAndOverride() throws Exception {
  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}",
          ApolloConfig.class,
          getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace, someDC);
  ApolloConfig result = response.getBody();

  assertEquals(
      "TEST-RELEASE-KEY6" + ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR + "TEST-RELEASE-KEY4",
      result.getReleaseKey());
  assertEquals(someAppId, result.getAppId());
  assertEquals(someDC, result.getCluster());
  assertEquals(somePublicNamespace, result.getNamespaceName());
  assertEquals("override-someDC-v1", result.getConfigurations().get("k1"));
  assertEquals("someDC-v2", result.getConfigurations().get("k2"));
}
项目:apollo-custom    文件:NotificationControllerIntegrationTest.java   
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWthPublicNamespaceAndDataCenter() throws Exception {
  String publicAppId = "somePublicAppId";
  String someDC = "someDC";

  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(publicAppId, someDC, somePublicNamespace), stop);

  ResponseEntity<ApolloConfigNotification> result = restTemplate
      .getForEntity(
          "{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}&dataCenter={dataCenter}",
          ApolloConfigNotification.class,
          getHostUrl(), someAppId, someCluster, somePublicNamespace, someDC);

  stop.set(true);

  ApolloConfigNotification notification = result.getBody();
  assertEquals(HttpStatus.OK, result.getStatusCode());
  assertEquals(somePublicNamespace, notification.getNamespaceName());
  assertNotEquals(0, notification.getNotificationId());
}
项目:embedded-database-spring-test    文件:EmptyDatabaseIntegrationTest.java   
@Test
@Sql(statements = "create schema if not exists test")
@Sql(scripts = {
        "/db/migration/V0001_1__create_person_table.sql",
        "/db/migration/V0002_1__rename_surname_column.sql"
})
public void loadDefaultMigrations() throws Exception {
    assertThat(dataSource).isNotNull();

    List<Map<String, Object>> persons = jdbcTemplate.queryForList(SQL_SELECT_PERSONS);
    assertThat(persons).isNotNull().hasSize(1);

    Map<String, Object> person = persons.get(0);
    assertThat(person).containsExactly(
            entry("id", 1L),
            entry("first_name", "Dave"),
            entry("last_name", "Syer"));
}
项目:embedded-database-spring-test    文件:EmptyDatabaseIntegrationTest.java   
@Test
@Sql(statements = "create schema if not exists test")
@Sql(scripts = {
        "/db/migration/V0001_1__create_person_table.sql",
        "/db/migration/V0002_1__rename_surname_column.sql",
        "/db/test_migration/appendable/V1000_1__create_test_data.sql"
})
public void loadAppendableTestMigrations() throws Exception {
    assertThat(dataSource).isNotNull();

    List<Map<String, Object>> persons = jdbcTemplate.queryForList(SQL_SELECT_PERSONS);
    assertThat(persons).isNotNull().hasSize(2);

    assertThat(persons).extracting("id", "first_name", "last_name").containsExactlyInAnyOrder(
            tuple(1L, "Dave", "Syer"),
            tuple(2L, "Tom", "Hanks"));
}
项目:embedded-database-spring-test    文件:EmptyDatabaseIntegrationTest.java   
@Test
@Sql(statements = "create schema if not exists test")
@Sql(scripts = {
        "/db/migration/V0001_1__create_person_table.sql",
        "/db/test_migration/dependent/V0001_2__add_full_name_column.sql",
        "/db/migration/V0002_1__rename_surname_column.sql"
})
public void loadDependentTestMigrations() throws Exception {
    assertThat(dataSource).isNotNull();

    List<Map<String, Object>> persons = jdbcTemplate.queryForList(SQL_SELECT_PERSONS);
    assertThat(persons).isNotNull().hasSize(1);

    Map<String, Object> person = persons.get(0);
    assertThat(person).containsExactly(
            entry("id", 1L),
            entry("first_name", "Dave"),
            entry("last_name", "Syer"),
            entry("full_name", "Dave Syer"));
}
项目:embedded-database-spring-test    文件:EmptyDatabaseIntegrationTest.java   
@Test
@Sql(statements = "create schema if not exists test")
@Sql(scripts = {
        "/db/test_migration/separated/V1000_1__create_test_person_table.sql"
})
public void loadIndependentTestMigrations() throws Exception {
    assertThat(dataSource).isNotNull();

    List<Map<String, Object>> persons = jdbcTemplate.queryForList(SQL_SELECT_PERSONS);
    assertThat(persons).isNotNull().hasSize(1);

    Map<String, Object> person = persons.get(0);
    assertThat(person).containsExactly(
            entry("id", 1L),
            entry("first_name", "Tom"),
            entry("last_name", "Hanks"));
}
项目:apollo-custom    文件:NamespaceBranchServiceTest.java   
@Test
@Sql(scripts = "/sql/namespace-branch-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testUpdateRulesReleaseIdWithOldRuleExist() {

  GrayReleaseRule rule = instanceGrayReleaseRule();
  namespaceBranchService.updateBranchGrayRules(testApp, testCluster, testNamespace, testBranchName, rule);

  long latestReleaseId = 100;

  namespaceBranchService
      .updateRulesReleaseId(testApp, testCluster, testNamespace, testBranchName, latestReleaseId, operator);

  GrayReleaseRule
      activeRule =
      namespaceBranchService.findBranchGrayRules(testApp, testCluster, testNamespace, testBranchName);

  Assert.assertNotNull(activeRule);
  Assert.assertEquals(Long.valueOf(latestReleaseId), activeRule.getReleaseId());
  Assert.assertEquals(rule.getRules(), activeRule.getRules());
  Assert.assertEquals(NamespaceBranchStatus.ACTIVE, activeRule.getBranchStatus());
}
项目:apollo-custom    文件:RolePermissionServiceTest.java   
@Test
@Sql(scripts = "/sql/permission/insert-test-permissions.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testCreateRoleWithPermissions() throws Exception {
  String someRoleName = "someRoleName";
  Role role = assembleRole(someRoleName);

  Set<Long> permissionIds = Sets.newHashSet(990L, 991L);

  Role created = rolePermissionService.createRoleWithPermissions(role, permissionIds);

  Role createdFromDB = roleRepository.findOne(created.getId());
  List<RolePermission> rolePermissions =
      rolePermissionRepository.findByRoleIdIn(Sets.newHashSet(createdFromDB.getId()));

  Set<Long> rolePermissionIds =
      FluentIterable.from(rolePermissions)
          .transform(RolePermission::getPermissionId).toSet();

  assertEquals(someRoleName, createdFromDB.getRoleName());
  assertEquals(2, rolePermissionIds.size());
  assertTrue(rolePermissionIds.containsAll(permissionIds));
}
项目:apollo-custom    文件:RolePermissionServiceTest.java   
@Test
@Sql(scripts = "/sql/permission/insert-test-roles.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testAssignRoleToUsers() throws Exception {
  String someRoleName = "someRoleName";
  String someUser = "someUser";
  String anotherUser = "anotherUser";
  String operator = "operator";

  Set<String> users = Sets.newHashSet(someUser, anotherUser);

  rolePermissionService
      .assignRoleToUsers(someRoleName, users, operator);

  List<UserRole> userRoles = userRoleRepository.findByRoleId(990);

  Set<String> usersWithRole = Sets.newHashSet();
  for (UserRole userRole : userRoles) {
    assertEquals(operator, userRole.getDataChangeCreatedBy());
    assertEquals(operator, userRole.getDataChangeLastModifiedBy());
    usersWithRole.add(userRole.getUserId());
  }

  assertEquals(2, usersWithRole.size());
  assertTrue(usersWithRole.containsAll(users));
}
项目:apollo-custom    文件:RolePermissionServiceTest.java   
@Test
@Sql(scripts = "/sql/permission/insert-test-roles.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/permission/insert-test-userroles.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testRemoveRoleFromUsers() throws Exception {
  String someRoleName = "someRoleName";
  String someUser = "someUser";
  String anotherUser = "anotherUser";
  String operator = "operator";

  Set<String> users = Sets.newHashSet(someUser, anotherUser);

  List<UserRole> userRoles = userRoleRepository.findByRoleId(990);
  assertFalse(userRoles.isEmpty());

  rolePermissionService.removeRoleFromUsers(someRoleName, users, operator);

  List<UserRole> userRolesAfterRemoval = userRoleRepository.findByRoleId(990);
  assertTrue(userRolesAfterRemoval.isEmpty());
}
项目:apollo-custom    文件:RolePermissionServiceTest.java   
@Test
@Sql(scripts = "/sql/permission/insert-test-roles.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/permission/insert-test-permissions.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/permission/insert-test-userroles.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/permission/insert-test-rolepermissions.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testUserHasPermission() throws Exception {
  String someTargetId = "someTargetId";
  String anotherTargetId = "anotherTargetId";
  String somePermissionType = "somePermissionType";
  String anotherPermissionType = "anotherPermissionType";
  String someUser = "someUser";
  String anotherUser = "anotherUser";
  String someUserWithNoPermission = "someUserWithNoPermission";

  assertTrue(rolePermissionService.userHasPermission(someUser, somePermissionType, someTargetId));
  assertTrue(rolePermissionService.userHasPermission(someUser, anotherPermissionType, anotherTargetId));
  assertTrue(rolePermissionService.userHasPermission(anotherUser, somePermissionType, someTargetId));
  assertTrue(rolePermissionService.userHasPermission(anotherUser, anotherPermissionType, anotherTargetId));

  assertFalse(rolePermissionService.userHasPermission(someUserWithNoPermission, somePermissionType, someTargetId));
  assertFalse(rolePermissionService.userHasPermission(someUserWithNoPermission, anotherPermissionType, anotherTargetId));

}
项目:apollo-custom    文件:FavoriteServiceTest.java   
@Test
@Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testAddNormalFavorite() {
  String testApp = "testApp";
  Favorite favorite = instanceOfFavorite(testUser, testApp);
  favoriteService.addFavorite(favorite);

  List<Favorite> createdFavorites = favoriteService.search(testUser, testApp, new PageRequest(0, 10));

  Assert.assertEquals(1, createdFavorites.size());

  Assert.assertEquals(FavoriteService.POSITION_DEFAULT, createdFavorites.get(0).getPosition());
  Assert.assertEquals(testUser, createdFavorites.get(0).getUserId());
  Assert.assertEquals(testApp, createdFavorites.get(0).getAppId());

}
项目:apollo-custom    文件:ConsumerRolePermissionServiceTest.java   
@Test
@Sql(scripts = "/sql/permission/insert-test-roles.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/permission/insert-test-permissions.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/permission/insert-test-consumerroles.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/permission/insert-test-rolepermissions.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testConsumerHasPermission() throws Exception {
  String someTargetId = "someTargetId";
  String anotherTargetId = "anotherTargetId";
  String somePermissionType = "somePermissionType";
  String anotherPermissionType = "anotherPermissionType";
  long someConsumerId = 1;
  long anotherConsumerId = 2;
  long someConsumerWithNoPermission = 3;

  assertTrue(consumerRolePermissionService.consumerHasPermission(someConsumerId, somePermissionType, someTargetId));
  assertTrue(consumerRolePermissionService.consumerHasPermission(someConsumerId, anotherPermissionType, anotherTargetId));
  assertTrue(consumerRolePermissionService.consumerHasPermission(anotherConsumerId, somePermissionType, someTargetId));
  assertTrue(consumerRolePermissionService.consumerHasPermission(anotherConsumerId, anotherPermissionType, anotherTargetId));

  assertFalse(consumerRolePermissionService.consumerHasPermission(someConsumerWithNoPermission, somePermissionType, someTargetId));
  assertFalse(consumerRolePermissionService.consumerHasPermission(someConsumerWithNoPermission, anotherPermissionType, anotherTargetId));

}
项目:apollo-custom    文件:ControllerIntegrationExceptionTest.java   
@Test
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testCreateFailed() {
  AppDTO dto = generateSampleDTOData();

  when(adminService.createNewApp(any(App.class))).thenThrow(new RuntimeException("save failed"));

  try {
    restTemplate.postForEntity(getBaseAppUrl(), dto, AppDTO.class);
  } catch (HttpStatusCodeException e) {
    @SuppressWarnings("unchecked")
    Map<String, String> attr = gson.fromJson(e.getResponseBodyAsString(), Map.class);
    Assert.assertEquals("save failed", attr.get("message"));
  }
  App savedApp = appService.findOne(dto.getAppId());
  Assert.assertNull(savedApp);
}
项目:apollo-custom    文件:AppControllerTest.java   
@Test
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testCheckIfAppIdUnique() {
  AppDTO dto = generateSampleDTOData();
  ResponseEntity<AppDTO> response =
      restTemplate.postForEntity(getBaseAppUrl(), dto, AppDTO.class);
  AppDTO result = response.getBody();
  Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
  Assert.assertEquals(dto.getAppId(), result.getAppId());
  Assert.assertTrue(result.getId() > 0);

  Boolean falseUnique =
      restTemplate.getForObject(getBaseAppUrl() + dto.getAppId() + "/unique", Boolean.class);
  Assert.assertFalse(falseUnique);
  Boolean trueUnique = restTemplate
      .getForObject(getBaseAppUrl() + dto.getAppId() + "true" + "/unique", Boolean.class);
  Assert.assertTrue(trueUnique);
}
项目:apollo-custom    文件:AppControllerTest.java   
@Test
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testCreateTwice() {
  AppDTO dto = generateSampleDTOData();
  ResponseEntity<AppDTO> response =
      restTemplate.postForEntity(getBaseAppUrl(), dto, AppDTO.class);
  AppDTO first = response.getBody();
  Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
  Assert.assertEquals(dto.getAppId(), first.getAppId());
  Assert.assertTrue(first.getId() > 0);

  App savedApp = appRepository.findOne(first.getId());
  Assert.assertEquals(dto.getAppId(), savedApp.getAppId());
  Assert.assertNotNull(savedApp.getDataChangeCreatedTime());

  try {
    restTemplate.postForEntity(getBaseAppUrl(), dto, AppDTO.class);
  }catch (HttpClientErrorException e){
    Assert.assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
  }

}
项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-gray-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryGrayConfigWithDefaultClusterAndDefaultNamespaceOK() throws Exception {
  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(someAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, ConfigConsts.NAMESPACE_APPLICATION),
      stop);

  TimeUnit.MILLISECONDS.sleep(500);

  stop.set(true);

  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}", ApolloConfig.class,
          getHostUrl(), someAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, ConfigConsts.NAMESPACE_APPLICATION, someClientIp);
  ApolloConfig result = response.getBody();

  assertEquals(HttpStatus.OK, response.getStatusCode());
  assertEquals("TEST-GRAY-RELEASE-KEY1", result.getReleaseKey());
  assertEquals("v1-gray", result.getConfigurations().get("k1"));
}
项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-gray-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryGrayConfigWithDefaultClusterAndDefaultNamespaceAndIncorrectCase() throws Exception {
  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(someAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, ConfigConsts.NAMESPACE_APPLICATION),
      stop);

  TimeUnit.MILLISECONDS.sleep(500);

  stop.set(true);

  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}", ApolloConfig.class,
          getHostUrl(), someAppId, ConfigConsts.CLUSTER_NAME_DEFAULT,
          ConfigConsts.NAMESPACE_APPLICATION.toUpperCase(), someClientIp);
  ApolloConfig result = response.getBody();

  assertEquals(HttpStatus.OK, response.getStatusCode());
  assertEquals("TEST-GRAY-RELEASE-KEY1", result.getReleaseKey());
  assertEquals("v1-gray", result.getConfigurations().get("k1"));
}
项目:apollo-custom    文件:ConfigFileControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-public-dc-override.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicConfigAsProperties() throws Exception {
  ResponseEntity<String> response =
      restTemplate
          .getForEntity(
              "{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}",
              String.class,
              getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace, someDC);

  String result = response.getBody();

  assertEquals(HttpStatus.OK, response.getStatusCode());
  assertTrue(result.contains("k1=override-someDC-v1"));
  assertTrue(result.contains("k2=someDC-v2"));
}
项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-gray-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicGrayConfigWithNoOverride() throws Exception {
  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(somePublicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace),
      stop);

  TimeUnit.MILLISECONDS.sleep(500);

  stop.set(true);

  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}", ApolloConfig.class,
          getHostUrl(), someAppId, someCluster, somePublicNamespace, someClientIp);
  ApolloConfig result = response.getBody();

  assertEquals(HttpStatus.OK, response.getStatusCode());
  assertEquals("TEST-GRAY-RELEASE-KEY2", result.getReleaseKey());
  assertEquals("gray-v1", result.getConfigurations().get("k1"));
  assertEquals("gray-v2", result.getConfigurations().get("k2"));
}
项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicConfigWithDataCenterFoundAndNoOverride() throws Exception {
  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}",
          ApolloConfig.class,
          getHostUrl(), someAppId, someCluster, somePublicNamespace, someDC);
  ApolloConfig result = response.getBody();

  assertEquals("TEST-RELEASE-KEY4", result.getReleaseKey());
  assertEquals(someAppId, result.getAppId());
  assertEquals(someCluster, result.getCluster());
  assertEquals(somePublicNamespace, result.getNamespaceName());
  assertEquals("someDC-v1", result.getConfigurations().get("k1"));
  assertEquals("someDC-v2", result.getConfigurations().get("k2"));
}
项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicConfigWithDataCenterNotFoundAndNoOverride() throws Exception {
  String someDCNotFound = "someDCNotFound";
  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}",
          ApolloConfig.class,
          getHostUrl(), someAppId, someCluster, somePublicNamespace, someDCNotFound);
  ApolloConfig result = response.getBody();

  assertEquals("TEST-RELEASE-KEY3", result.getReleaseKey());
  assertEquals(someAppId, result.getAppId());
  assertEquals(someCluster, result.getCluster());
  assertEquals(somePublicNamespace, result.getNamespaceName());
  assertEquals("default-v1", result.getConfigurations().get("k1"));
  assertEquals("default-v2", result.getConfigurations().get("k2"));
}
项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-public-default-override.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-gray-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicGrayConfigWithOverride() throws Exception {
  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(somePublicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace),
      stop);

  TimeUnit.MILLISECONDS.sleep(500);

  stop.set(true);

  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}", ApolloConfig.class,
          getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace, someClientIp);
  ApolloConfig result = response.getBody();

  assertEquals(HttpStatus.OK, response.getStatusCode());
  assertEquals(
      "TEST-RELEASE-KEY5" + ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR + "TEST-GRAY-RELEASE-KEY2",
      result.getReleaseKey());
  assertEquals("override-v1", result.getConfigurations().get("k1"));
  assertEquals("gray-v2", result.getConfigurations().get("k2"));
}
项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-public-default-override.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-gray-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicGrayConfigWithIncorrectCaseAndOverride() throws Exception {
  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(somePublicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace),
      stop);

  TimeUnit.MILLISECONDS.sleep(500);

  stop.set(true);

  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}?ip={clientIp}", ApolloConfig.class,
          getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace.toUpperCase(), someClientIp);
  ApolloConfig result = response.getBody();

  assertEquals(HttpStatus.OK, response.getStatusCode());
  assertEquals(
      "TEST-RELEASE-KEY5" + ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR + "TEST-GRAY-RELEASE-KEY2",
      result.getReleaseKey());
  assertEquals("override-v1", result.getConfigurations().get("k1"));
  assertEquals("gray-v2", result.getConfigurations().get("k2"));
}
项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPrivateConfigFileWithPublicNamespaceExists() throws Exception {
  String namespaceName = "anotherNamespace";
  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}",
          ApolloConfig.class,
          getHostUrl(), someAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespaceName);
  ApolloConfig result = response.getBody();

  assertEquals("TEST-RELEASE-KEY6", result.getReleaseKey());
  assertEquals(someAppId, result.getAppId());
  assertEquals(ConfigConsts.CLUSTER_NAME_DEFAULT, result.getCluster());
  assertEquals(namespaceName, result.getNamespaceName());
  assertEquals("v1-file", result.getConfigurations().get("k1"));
  assertEquals(null, result.getConfigurations().get("k2"));
}
项目:apollo-custom    文件:ConfigControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicConfigForNoAppIdPlaceHolder() throws Exception {
  ResponseEntity<ApolloConfig> response = restTemplate
      .getForEntity("{baseurl}/configs/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}",
          ApolloConfig.class,
          getHostUrl(), ConfigConsts.NO_APPID_PLACEHOLDER, someCluster, somePublicNamespace, someDC);
  ApolloConfig result = response.getBody();

  assertEquals("TEST-RELEASE-KEY4", result.getReleaseKey());
  assertEquals(ConfigConsts.NO_APPID_PLACEHOLDER, result.getAppId());
  assertEquals(someCluster, result.getCluster());
  assertEquals(somePublicNamespace, result.getNamespaceName());
  assertEquals("someDC-v1", result.getConfigurations().get("k1"));
  assertEquals("someDC-v2", result.getConfigurations().get("k2"));
}
项目:apollo-custom    文件:NotificationControllerIntegrationTest.java   
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithDefaultNamespace() throws Exception {
  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(someAppId, someCluster, defaultNamespace), stop);

  ResponseEntity<ApolloConfigNotification> result = restTemplate.getForEntity(
      "{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}",
      ApolloConfigNotification.class,
      getHostUrl(), someAppId, someCluster, defaultNamespace);

  stop.set(true);

  ApolloConfigNotification notification = result.getBody();
  assertEquals(HttpStatus.OK, result.getStatusCode());
  assertEquals(defaultNamespace, notification.getNamespaceName());
  assertNotEquals(0, notification.getNotificationId());
}
项目:apollo-custom    文件:NotificationControllerIntegrationTest.java   
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithDefaultNamespaceAsFile() throws Exception {
  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(someAppId, someCluster, defaultNamespace), stop);

  ResponseEntity<ApolloConfigNotification> result = restTemplate.getForEntity(
      "{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}",
      ApolloConfigNotification.class,
      getHostUrl(), someAppId, someCluster, defaultNamespace + ".properties");

  stop.set(true);

  ApolloConfigNotification notification = result.getBody();
  assertEquals(HttpStatus.OK, result.getStatusCode());
  assertEquals(defaultNamespace, notification.getNamespaceName());
  assertNotEquals(0, notification.getNotificationId());
}
项目:apollo-custom    文件:NotificationControllerIntegrationTest.java   
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithPrivateNamespaceAsFile() throws Exception {
  String namespace = "someNamespace.xml";
  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(someAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, namespace), stop);

  ResponseEntity<ApolloConfigNotification> result = restTemplate
      .getForEntity(
          "{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}",
          ApolloConfigNotification.class,
          getHostUrl(), someAppId, someCluster, namespace);

  stop.set(true);

  ApolloConfigNotification notification = result.getBody();
  assertEquals(HttpStatus.OK, result.getStatusCode());
  assertEquals(namespace, notification.getNamespaceName());
  assertNotEquals(0, notification.getNotificationId());
}
项目:apollo-custom    文件:NotificationControllerIntegrationTest.java   
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-message.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithDefaultNamespaceWithNotificationIdOutDated() throws Exception {
  long someOutDatedNotificationId = 1;
  ResponseEntity<ApolloConfigNotification> result = restTemplate.getForEntity(
      "{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}&notificationId={notificationId}",
      ApolloConfigNotification.class,
      getHostUrl(), someAppId, someCluster, defaultNamespace, someOutDatedNotificationId);

  ApolloConfigNotification notification = result.getBody();
  assertEquals(HttpStatus.OK, result.getStatusCode());
  assertEquals(defaultNamespace, notification.getNamespaceName());
  assertEquals(10, notification.getNotificationId());
}
项目:apollo-custom    文件:NotificationControllerIntegrationTest.java   
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWthPublicNamespaceAndNoDataCenter() throws Exception {
  String publicAppId = "somePublicAppId";

  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(publicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace), stop);

  ResponseEntity<ApolloConfigNotification> result = restTemplate
      .getForEntity(
          "{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}",
          ApolloConfigNotification.class,
          getHostUrl(), someAppId, someCluster, somePublicNamespace);

  stop.set(true);

  ApolloConfigNotification notification = result.getBody();
  assertEquals(HttpStatus.OK, result.getStatusCode());
  assertEquals(somePublicNamespace, notification.getNamespaceName());
  assertNotEquals(0, notification.getNotificationId());
}
项目:apollo-custom    文件:NotificationControllerIntegrationTest.java   
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWthPublicNamespaceAsFile() throws Exception {
  String publicAppId = "somePublicAppId";
  String someDC = "someDC";

  AtomicBoolean stop = new AtomicBoolean();
  periodicSendMessage(executorService, assembleKey(publicAppId, someDC, somePublicNamespace), stop);

  ResponseEntity<ApolloConfigNotification> result = restTemplate
      .getForEntity(
          "{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}&dataCenter={dataCenter}",
          ApolloConfigNotification.class,
          getHostUrl(), someAppId, someCluster, somePublicNamespace + ".properties", someDC);

  stop.set(true);

  ApolloConfigNotification notification = result.getBody();
  assertEquals(HttpStatus.OK, result.getStatusCode());
  assertEquals(somePublicNamespace, notification.getNamespaceName());
  assertNotEquals(0, notification.getNotificationId());
}
项目:apollo-custom    文件:NotificationControllerIntegrationTest.java   
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-message.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithPublicNamespaceWithNotificationIdOutDated() throws Exception {
  long someOutDatedNotificationId = 1;
  ResponseEntity<ApolloConfigNotification> result = restTemplate.getForEntity(
      "{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}&notificationId={notificationId}",
      ApolloConfigNotification.class,
      getHostUrl(), someAppId, someCluster, somePublicNamespace, someOutDatedNotificationId);

  ApolloConfigNotification notification = result.getBody();
  assertEquals(HttpStatus.OK, result.getStatusCode());
  assertEquals(somePublicNamespace, notification.getNamespaceName());
  assertEquals(20, notification.getNotificationId());
}
项目:apollo-custom    文件:NotificationControllerV2IntegrationTest.java   
@Test(timeout = 5000L)
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWthPublicNamespaceAndNoDataCenter() throws Exception {
  String publicAppId = "somePublicAppId";

  AtomicBoolean stop = new AtomicBoolean();
  String key = assembleKey(publicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace);
  periodicSendMessage(executorService, key, stop);

  ResponseEntity<List<ApolloConfigNotification>> result = restTemplate.exchange(
      "{baseurl}/notifications/v2?appId={appId}&cluster={clusterName}&notifications={notifications}",
      HttpMethod.GET, null, typeReference,
      getHostUrl(), someAppId, someCluster,
      transformApolloConfigNotificationsToString(somePublicNamespace, ConfigConsts.NOTIFICATION_ID_PLACEHOLDER));

  stop.set(true);

  List<ApolloConfigNotification> notifications = result.getBody();
  assertEquals(HttpStatus.OK, result.getStatusCode());
  assertEquals(1, notifications.size());
  assertEquals(somePublicNamespace, notifications.get(0).getNamespaceName());
  assertNotEquals(0, notifications.get(0).getNotificationId());

  ApolloNotificationMessages messages = result.getBody().get(0).getMessages();
  assertEquals(1, messages.getDetails().size());
  assertTrue(messages.has(key));
  assertNotEquals(ConfigConsts.NOTIFICATION_ID_PLACEHOLDER, messages.get(key).longValue());
}
项目:apollo-custom    文件:ConfigFileControllerIntegrationTest.java   
@Test
@Sql(scripts = "/integration-test/test-release.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/test-release-public-dc-override.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testQueryPublicConfigAsJsonWithIncorrectCase() throws Exception {
  ResponseEntity<String> response =
      restTemplate
          .getForEntity(
              "{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?dataCenter={dateCenter}",
              String.class,
              getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace.toUpperCase(), someDC);

  Map<String, String> configs = gson.fromJson(response.getBody(), mapResponseType);

  assertEquals(HttpStatus.OK, response.getStatusCode());
  assertEquals("override-someDC-v1", configs.get("k1"));
  assertEquals("someDC-v2", configs.get("k2"));
}
项目:apollo-custom    文件:NamespaceBranchServiceTest.java   
@Test
@Sql(scripts = "/sql/namespace-branch-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testFindBranch() {
  Namespace branch = namespaceBranchService.findBranch(testApp, testCluster, testNamespace);

  Assert.assertNotNull(branch);
  Assert.assertEquals(testBranchName, branch.getClusterName());
}
项目:apollo-custom    文件:NamespaceBranchServiceTest.java   
@Test
@Sql(scripts = "/sql/namespace-branch-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testUpdateBranchGrayRulesWithUpdateOnce() {
  GrayReleaseRule rule = instanceGrayReleaseRule();

  namespaceBranchService.updateBranchGrayRules(testApp, testCluster, testNamespace, testBranchName, rule);

  GrayReleaseRule
      activeRule =
      namespaceBranchService.findBranchGrayRules(testApp, testCluster, testNamespace, testBranchName);

  Assert.assertNotNull(activeRule);
  Assert.assertEquals(rule.getAppId(), activeRule.getAppId());
  Assert.assertEquals(rule.getRules(), activeRule.getRules());
  Assert.assertEquals(Long.valueOf(0), activeRule.getReleaseId());

  Page<ReleaseHistory> releaseHistories = releaseHistoryService.findReleaseHistoriesByNamespace
      (testApp, testCluster, testNamespace, pageable);

  ReleaseHistory releaseHistory = releaseHistories.getContent().get(0);

  Assert.assertEquals(1, releaseHistories.getTotalElements());
  Assert.assertEquals(ReleaseOperation.APPLY_GRAY_RULES, releaseHistory.getOperation());
  Assert.assertEquals(0, releaseHistory.getReleaseId());
  Assert.assertEquals(0, releaseHistory.getPreviousReleaseId());
  Assert.assertTrue(releaseHistory.getOperationContext().contains(rule.getRules()));
}
项目:apollo-custom    文件:NamespaceBranchServiceTest.java   
@Test
@Sql(scripts = "/sql/namespace-branch-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testUpdateRulesReleaseIdWithOldRuleNotExist() {
  long latestReleaseId = 100;

  namespaceBranchService
      .updateRulesReleaseId(testApp, testCluster, testNamespace, testBranchName, latestReleaseId, operator);

  GrayReleaseRule
      activeRule =
      namespaceBranchService.findBranchGrayRules(testApp, testCluster, testNamespace, testBranchName);

  Assert.assertNull(activeRule);
}
项目:apollo-custom    文件:NamespaceBranchServiceTest.java   
@Test
@Sql(scripts = "/sql/namespace-branch-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testDeleteBranch() {

  GrayReleaseRule rule = instanceGrayReleaseRule();
  namespaceBranchService.updateBranchGrayRules(testApp, testCluster, testNamespace, testBranchName, rule);

  namespaceBranchService.deleteBranch(testApp, testCluster, testNamespace, testBranchName, NamespaceBranchStatus.DELETED, operator);

  Namespace branch = namespaceBranchService.findBranch(testApp, testCluster, testNamespace);
  Assert.assertNull(branch);

  GrayReleaseRule latestRule = namespaceBranchService.findBranchGrayRules(testApp, testCluster, testNamespace, testBranchName);

  Assert.assertNotNull(latestRule);
  Assert.assertEquals(NamespaceBranchStatus.DELETED, latestRule.getBranchStatus());
  Assert.assertEquals("[]", latestRule.getRules());

  Page<ReleaseHistory> releaseHistories = releaseHistoryService.findReleaseHistoriesByNamespace
      (testApp, testCluster, testNamespace, pageable);

  ReleaseHistory firstReleaseHistory = releaseHistories.getContent().get(1);
  ReleaseHistory secondReleaseHistory = releaseHistories.getContent().get(0);

  Assert.assertEquals(2, releaseHistories.getTotalElements());
  Assert.assertEquals(ReleaseOperation.APPLY_GRAY_RULES, firstReleaseHistory.getOperation());
  Assert.assertEquals(ReleaseOperation.ABANDON_GRAY_RELEASE, secondReleaseHistory.getOperation());

}
项目:apollo-custom    文件:NamespaceServiceIntegrationTest.java   
@Test
@Sql(scripts = "/sql/namespace-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testDeleteNamespace() {

  Namespace namespace = new Namespace();
  namespace.setAppId(testApp);
  namespace.setClusterName(testCluster);
  namespace.setNamespaceName(testPrivateNamespace);
  namespace.setId(1);

  namespaceService.deleteNamespace(namespace, testUser);

  List<Item> items = itemService.findItemsWithoutOrdered(testApp, testCluster, testPrivateNamespace);
  List<Commit> commits = commitService.find(testApp, testCluster, testPrivateNamespace, new PageRequest(0, 10));
  AppNamespace appNamespace = appNamespaceService.findOne(testApp, testPrivateNamespace);
  List<Cluster> childClusters = clusterService.findChildClusters(testApp, testCluster);
  InstanceConfig instanceConfig = instanceConfigRepository.findOne(1L);
  List<Release> parentNamespaceReleases = releaseService.findActiveReleases(testApp, testCluster,
                                                                            testPrivateNamespace,
                                                                            new PageRequest(0, 10));
  List<Release> childNamespaceReleases = releaseService.findActiveReleases(testApp, testChildCluster,
                                                                           testPrivateNamespace,
                                                                           new PageRequest(0, 10));
  Page<ReleaseHistory> releaseHistories =
      releaseHistoryService
          .findReleaseHistoriesByNamespace(testApp, testCluster, testPrivateNamespace, new PageRequest(0, 10));

  assertEquals(0, items.size());
  assertEquals(0, commits.size());
  assertNotNull(appNamespace);
  assertEquals(0, childClusters.size());
  assertEquals(0, parentNamespaceReleases.size());
  assertEquals(0, childNamespaceReleases.size());
  assertTrue(!releaseHistories.hasContent());
  assertNull(instanceConfig);
}