@Test public void testCreateRepository() { Repository createRepo = new Repository(); createRepo.setRepositoryName("testNewRepo-cmsServer"); Repository repo = server.createRepository(CMSPriority.NON_CRITICAL, createRepo); Assert.assertNotNull(server.getRepository(CMSPriority.NON_CRITICAL, repo.getRepositoryName())); IBranch branch = server.getBranch(CMSPriority.NON_CRITICAL, repo.getRepositoryName(), IBranch.DEFAULT_BRANCH, entityContext); Assert.assertNotNull(branch); }
@Test public void testDeleteRepository() { Map<String, Object> newConfigs = new HashMap<String, Object>(); newConfigs.put(CMSDBConfig.SYS_ALLOW_REPOSITORY_DELETE, false); server.config(newConfigs); Repository createRepo = new Repository(); String repositoryName = "testDeleteRepo-cmsServer"; createRepo.setRepositoryName(repositoryName); server.createRepository(CMSPriority.NON_CRITICAL, createRepo); Repository getRepo = server.getRepository(CMSPriority.NEUTRAL, repositoryName); Assert.assertNotNull(getRepo); try { server.deleteRepository(CMSPriority.NEUTRAL, repositoryName); Assert.fail(); } catch (Exception e) { // expected as the configuration "SysAllowRepositoryDelete" should // be false } newConfigs = new HashMap<String, Object>(); newConfigs.put(CMSDBConfig.SYS_ALLOW_REPOSITORY_DELETE, true); server.config(newConfigs); server.deleteRepository(CMSPriority.NEUTRAL, repositoryName); try { server.getRepository(CMSPriority.NEUTRAL, repositoryName); Assert.fail(); } catch (RepositoryNotExistsException rnee) { // expected } }
@Test public void testRepositoryConvert() { String repositoryName = "name"; Repository repo = new Repository(); repo.setRepositoryName(repositoryName); Date now = new Date(); repo.setCreateTime(now); repo.setState(Repository.StateEnum.normal); ObjectConverter<Repository> c = new ObjectConverter<Repository>(); String json = c.toJson(repo); Repository repo1 = c.fromJson(json, Repository.class); Assert.assertEquals(repo1.getRepositoryName(), repo.getRepositoryName()); Assert.assertEquals(repo1.getCreateTime(), repo.getCreateTime()); // Assert.assertEquals(repo1.getDeletedTime(), repo.getDeletedTime()); // Assert.assertEquals(repo1.getDeletingTime(), repo.getDeletingTime()); }
repository.setRepositoryName(RAPTOR_REPO); RepositoryOption repositoryOption = new RepositoryOption(); repositoryOption.setMaxIndexedArraySize(3);