@Before public void setup() { _context = new ClassPathXmlApplicationContext("metering-vnxfile-context.xml"); try { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/dbutils-conf.xml"); _dbClient = (DbClientImpl) ctx.getBean("dbclient"); _dbClient = Cassandraforplugin.returnDBClient(); final TenantOrg tenantorg = new TenantOrg(); tenantorg.setId(URIUtil.createId(TenantOrg.class)); tenantorg.setLabel("some org"); tenantorg.setParentTenant( new NamedURI(URIUtil.createId(TenantOrg.class), tenantorg.getLabel())); _logger.info("TenantOrg :" + tenantorg.getId()); _dbClient.persistObject(tenantorg); final Project proj = new Project(); proj.setId(URIUtil.createId(Project.class)); proj.setLabel("some name"); proj.setTenantOrg(new NamedURI(tenantorg.getId(), proj.getLabel())); _logger.info("Project :" + proj.getId()); _logger.info("TenantOrg-Proj :" + proj.getTenantOrg()); _dbClient.persistObject(proj); final FileShare fileShare = new FileShare(); fileShare.setId(URIUtil.createId(FileShare.class)); fileShare.setLabel("some fileshare"); fileShare.setNativeGuid("CELERRA+" + serialNumber); fileShare.setVirtualPool(URIUtil.createId(VirtualPool.class)); fileShare.setProject(new NamedURI(proj.getId(), fileShare.getLabel())); fileShare.setCapacity(12500L); _dbClient.persistObject(fileShare); } catch (final Exception ioEx) { _logger.error("Exception occurred while persisting objects in db {}", ioEx.getMessage()); _logger.error(ioEx.getMessage(), ioEx); } }
/** * Prepares and persists the Project/Tenant data. * * @throws Exception */ private void prepareProjectData() throws Exception { TenantOrg tenantOrg = new TenantOrg(); URI tenantOrgURI = URIUtil.createId(TenantOrg.class); tenantOrg.setId(tenantOrgURI); _dbClient.createObject(tenantOrg); Project proj = new Project(); projectURI = URIUtil.createId(Project.class); String projectLabel = "project"; proj.setId(projectURI); proj.setLabel(projectLabel); proj.setTenantOrg(new NamedURI(tenantOrgURI, projectLabel)); _dbClient.createObject(proj); }