use of org.apache.cloudstack.api.command.user.project.CreateProjectCmd in project cloudstack by apache.
the class NetworkProviderTest method createProject.
public void createProject(String name) {
BaseCmd cmd = new CreateProjectCmd();
BaseCmd proxy = ComponentContext.inject(cmd);
Account system = _accountMgr.getSystemAccount();
ManagementServerMock.setParameter(proxy, "accountName", BaseCmd.CommandType.STRING, system.getAccountName());
ManagementServerMock.setParameter(proxy, "domainId", BaseCmd.CommandType.LONG, Domain.ROOT_DOMAIN);
ManagementServerMock.setParameter(proxy, "name", BaseCmd.CommandType.STRING, name);
ManagementServerMock.setParameter(proxy, "displayText", BaseCmd.CommandType.STRING, name);
try {
((CreateProjectCmd) proxy).create();
((CreateProjectCmd) proxy).execute();
} catch (Exception e) {
s_logger.debug("CreateProjectCmd exception: " + e);
e.printStackTrace();
fail("create project cmd failed");
}
DomainVO domain = _domainDao.findById(Domain.ROOT_DOMAIN);
try {
net.juniper.contrail.api.types.Domain vncDomain = (net.juniper.contrail.api.types.Domain) _api.findById(net.juniper.contrail.api.types.Domain.class, domain.getUuid());
if (_api.findByName(net.juniper.contrail.api.types.Project.class, vncDomain, name) == null) {
fail("create project failed in vnc");
}
} catch (Exception e) {
e.printStackTrace();
fail("Exception while creating a project in vnc");
}
}
Aggregations