@Test public void testGetRepositories() { Repository repository = new Repository("repo1"); repository.setAccessType(AccessType.Private); repositoryService.createRepository(repository); List<Repository> publics = repositoryService.getRepositories(AccessType.Public); Assert.assertTrue(publics.size() > 0); List<Repository> privates = repositoryService.getRepositories(AccessType.Private); Assert.assertTrue(privates.size() > 0); }
new MongoMetadataServiceImpl(new Mongo(), 0, 0, 1, 1, new Repository(), null); } catch (Exception e) { new MongoMetadataServiceImpl(new Mongo(), 1, 0, 1, 1, new Repository(), null); } catch (Exception e) { new MongoMetadataServiceImpl(new Mongo(), 1, 1, 1, 1, new Repository(), null); } catch (Exception e) {
@Test(expected=RepositoryExistsException.class) public void testRepositoryCreationException() { String repoName = "testRepoCreation"; try { repositoryService.getRepository(repoName); Assert.fail(); } catch (Exception e) { // expected } Repository r = null; r = repositoryService.createRepository(new Repository("r2")); Assert.assertEquals("r2", r.getRepositoryName()); r = repositoryService.createRepository(new Repository("r2")); }
@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 testGetAll() { List<Repository> repos = repositoryService.getRepositories(new MetadataContext()); String repoName1 = "testGetAll1"; String repoName2 = "testGetAll2"; repositoryService.createRepository(new Repository(repoName1)); repositoryService.createRepository(new Repository(repoName2)); List<Repository> newRepos = repositoryService.getRepositories(new MetadataContext()); Assert.assertEquals(repos.size() + 2, newRepos.size()); boolean found1 = false; boolean found2 = false; for (Repository r : newRepos) { if (r.getRepositoryName().equals(repoName1)) found1 = true; if (r.getRepositoryName().equals(repoName2)) found2 = true; } Assert.assertTrue(found1 && found2); }
@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 testBadReponameCreation() { String repoName = "test\"RepoCreation"; try { repositoryService.createRepository(new Repository(repoName)); Assert.fail(); } catch (MetaDataException e) { } //this repo name should not exist in the cms_sys db try { repositoryService.getRepository(repoName); Assert.fail(); } catch (Exception e) { e.printStackTrace(); } }
repoService.createRepository(new Repository(repo)); repository = repoService.getRepository(repo);
@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()); }
@Test public void testGetMetaClasses() { MetadataContext metaContext = new MetadataContext(); IMetadataService ms = repositoryService.getRepository("raptor-paas").getMetadataService(); List<MetaClass> metas = ms.getMetaClasses(metaContext); Assert.assertEquals(34, metas.size()); ms = repositoryService.getRepository("software-deployment").getMetadataService(); metas = ms.getMetaClasses(metaContext); Assert.assertEquals(16, metas.size()); ms = repositoryService.createRepository(new Repository("newCreatedForGetMetaClasses")).getMetadataService(); metas = ms.getMetaClasses(metaContext); Assert.assertEquals(2, metas.size()); }
@BeforeClass public static void createRepoService() { MongoDataSource ds = new MongoDataSource(getConnectionString()); MetadataDataLoader.getInstance(ds).loadTestDataFromResource(); repositoryService = RepositoryServiceFactory.createRepositoryService(ds, "localCMSServer"); repo = repositoryService.createRepository(new Repository(repoName)); }
@BeforeClass public static void createRepoService() { ds = new MongoDataSource(getConnectionString()); MetadataDataLoader.getInstance(ds).loadTestDataFromResource(); repositoryService = RepositoryServiceFactory.createRepositoryService(ds, "localCMSServer"); repo = repositoryService.createRepository(new Repository(repoName)); metaContext = new MetadataContext(); metaContext.setSourceIp("127.0.0.1"); metaContext.setSubject("unitTestUser"); Assert.assertEquals(repo, repo.getMetadataService().getRepository()); }
@Test public void testRepositoryCreation() { String repoName = "testRepoCreation"; try { repositoryService.getRepository(repoName); Assert.fail(); } catch (Exception e) { // expected } Repository r = repositoryService.createRepository(new Repository("r1")); Assert.assertEquals("r1", r.getRepositoryName()); Assert.assertNotNull(repositoryService.getRepository(r.getRepositoryName())); Assert.assertNotNull(repositoryService.getRepositories(new MetadataContext())); }
@BeforeClass public static void createRepoService() { dataSource = new MongoDataSource(getConnectionString()); MetadataDataLoader.getInstance(dataSource).loadTestDataFromResource(); repositoryService = RepositoryServiceFactory.createRepositoryService(dataSource, "localCMSServer"); repo = repositoryService.createRepository(new Repository(repoName)); metaService = repo.getMetadataService(); sequence = new MongoSequence(dataSource.getMongoInstance(), CMSConsts.SYS_DB, CMSConsts.SEQUENCE_COLL, CMSConsts.NEXT_FIELD_NAME_SEQ); Assert.assertEquals(repo, repo.getMetadataService().getRepository()); raptorMetaService = repositoryService.getRepository(RAPTOR_PAAS).getMetadataService(); }
@Test public void testRespositoryInitialization() { String repoName = "testRepoCreationInit"; try { repositoryService.getRepository(repoName); Assert.fail(); } catch (Exception e) { // expected } Repository r = repositoryService.createRepository(new Repository(repoName)); Assert.assertEquals(repoName, r.getRepositoryName()); Assert.assertNotNull(HistoryMetaClass.getMetaClass(r)); Assert.assertNotNull(BranchMetaClass.getMetaClass(r)); try { HistoryMetaClass.createHistoryMetaClass(r); BranchMetaClass.createBranchMetaClass(r); } catch (Exception e) { //1. create history/branch metadata class doesn't throw error when the metadata is already exsits Assert.fail(); } }
@Test public void testDelete() { String r1 = "testDelete"; repositoryService.createRepository(new Repository(r1)); Assert.assertNotNull(repositoryService.getRepository(r1)); MongoDataSource ds = new MongoDataSource(getConnectionString() + "," + getConnectionString()); IRepositoryService repositoryService2 = RepositoryServiceFactory.createRepositoryService(ds, "localCMSServer"); Assert.assertFalse(repositoryService == repositoryService2); Assert.assertNotNull(repositoryService2.getRepository(r1)); repositoryService.deleteRepository(r1); try { repositoryService.getRepository(r1); Assert.fail(); } catch (RepositoryNotExistsException e) { // expected } try { repositoryService2.getRepository(r1); Assert.fail(); } catch (RepositoryNotExistsException e) { // expected } }
String repoName = "testRepoUpdate"; String repoAdmin = "unit"; Repository repo = new Repository(repoName); AccessType oldAccessType = AccessType.Public; repo.setAccessType(oldAccessType);
repo = repositoryService.createRepository(new Repository(repoName));
Repository repository = new Repository(); repository.setRepositoryName(RAPTOR_REPO); RepositoryOption repositoryOption = new RepositoryOption();