本文整理汇总了Java中org.ligoj.app.model.Subscription.setProject方法的典型用法代码示例。如果您正苦于以下问题:Java Subscription.setProject方法的具体用法?Java Subscription.setProject怎么用?Java Subscription.setProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ligoj.app.model.Subscription
的用法示例。
在下文中一共展示了Subscription.setProject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteNoMoreGroup
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void deleteNoMoreGroup() throws Exception {
final Subscription subscription = new Subscription();
subscription.setProject(projectRepository.findByName("gStack"));
subscription.setNode(nodeRepository.findOneExpected("service:id:ldap:dig"));
em.persist(subscription);
// Attach the wrong group
setGroup(subscription, "any");
initSpringSecurityContext("fdaugan");
final Map<String, String> parameters = subscriptionResource.getParametersNoCheck(subscription.getId());
Assert.assertFalse(resource.checkSubscriptionStatus(parameters).getStatus().isUp());
resource.delete(subscription.getId(), true);
em.flush();
em.clear();
Assert.assertFalse(resource.checkSubscriptionStatus(parameters).getStatus().isUp());
subscriptionResource.getParametersNoCheck(subscription.getId()).isEmpty();
}
示例2: createAlreadyExist
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
/**
* Create a group with the same name.
*/
@Test
public void createAlreadyExist() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher(IdentityResource.PARAMETER_GROUP, "already-exist"));
// Attach the new group
final Subscription subscription = em.find(Subscription.class, this.subscription);
final Subscription subscription2 = new Subscription();
subscription2.setProject(newProject("sea-octopus"));
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, "sea-octopus");
setOu(subscription2, "sea");
basicCreate(subscription2);
}
示例3: createNotCompliantGroupForProject
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
/**
* Create a group for an existing project, but without reusing the pkey of this project.
*/
@Test
public void createNotCompliantGroupForProject() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher(IdentityResource.PARAMETER_GROUP, "pattern"));
// Preconditions
Assert.assertNotNull(getGroup().findById("sea-octopus"));
Assert.assertNull(getGroup().findById("sea-octopusZZ"));
Assert.assertNotNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("sea"));
// Attach the new group
final Subscription subscription = em.find(Subscription.class, this.subscription);
final Subscription subscription2 = new Subscription();
subscription2.setProject(newProject("sea-octopus"));
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, "sea-octopusZZ");
setOu(subscription2, "sea");
// Invoke link for an already linked entity, since for now
basicCreate(subscription2);
}
示例4: createNotCompliantGroupForProject2
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
/**
* Create a group for an existing project, reusing the pkey of this project and without suffix.
*/
@Test
public void createNotCompliantGroupForProject2() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher(IdentityResource.PARAMETER_GROUP, "pattern"));
// Preconditions
Assert.assertNotNull(getGroup().findById("sea-octopus"));
Assert.assertNull(getGroup().findById("sea-octopus-"));
Assert.assertNotNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("sea"));
// Attach the new group
final Subscription subscription = em.find(Subscription.class, this.subscription);
final Subscription subscription2 = new Subscription();
subscription2.setProject(newProject("sea-octopus"));
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, "sea-octopus-");
setOu(subscription2, "sea");
// Invoke link for an already linked entity, since for now
basicCreate(subscription2);
}
示例5: createNotCompliantGroupForOu
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
/**
* Create a group for an existing project, perfect match with the pkey, but without reusing the OU of this project.
*/
@Test
public void createNotCompliantGroupForOu() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher(IdentityResource.PARAMETER_GROUP, "pattern"));
// Preconditions
Assert.assertNull(getGroup().findById("sea-invalid-ou"));
Assert.assertNotNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("sea"));
// Attach the new group
final Subscription subscription = em.find(Subscription.class, this.subscription);
final Subscription subscription2 = new Subscription();
subscription2.setProject(newProject("sea-invalid-ou"));
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, "sea-invalid-ou");
setOu(subscription2, "gfi");
// Invoke link for an already linked entity, since for now
basicCreate(subscription2);
}
示例6: createNotExistingParentGroup
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
/**
* Create a group inside an existing group without reusing the name of the parent.
*/
@Test
public void createNotExistingParentGroup() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher(IdentityResource.PARAMETER_PARENT_GROUP, "unknown-id"));
// Preconditions
Assert.assertNotNull(getGroup().findById("sea-octopus"));
Assert.assertNull(getGroup().findById("sea-octopus-client"));
Assert.assertNotNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("sea"));
// Attach the new group
final Subscription subscription = em.find(Subscription.class, this.subscription);
final Subscription subscription2 = new Subscription();
subscription2.setProject(newProject("sea-orpahn"));
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, "sea-orpahn-any");
setParentGroup(subscription2, "sea-orpahn");
setOu(subscription2, "sea");
// Invoke link for an already linked entity, since for now
basicCreate(subscription2);
}
示例7: link
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void link() throws Exception {
prepareJiraServer();
final long initCount = importStatusRepository.count();
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
project.setTeamLeader(getAuthenticationName());
em.persist(project);
final Subscription subscription = new Subscription();
subscription.setProject(project);
subscription.setNode(nodeRepository.findOneExpected("service:bt:jira:6"));
em.persist(subscription);
addProjectParameters(subscription, 10074);
em.flush();
em.clear();
resource.link(subscription.getId());
em.flush();
Assert.assertEquals(initCount, importStatusRepository.count());
Assert.assertNull(resource.getTask(subscription.getId()));
}
示例8: delete
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void delete() throws SchedulerException {
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
em.persist(project);
final Subscription subscription = new Subscription();
subscription.setProject(project);
subscription.setNode(nodeRepository.findOneExpected("service:vm"));
em.persist(subscription);
Assert.assertEquals(1, subscriptionRepository.findAllByProject(project.getId()).size());
em.flush();
em.clear();
resource.delete(subscription.getId(), false);
subscriptionRepository.delete(subscription);
em.flush();
em.clear();
Assert.assertEquals(0, subscriptionRepository.findAllByProject(project.getId()).size());
Assert.assertEquals(0, vmScheduleRepository.findBySubscription(subscription.getId()).size());
Assert.assertEquals(0, vmExecutionRepository.findAllBy("subscription.id", subscription.getId()).size());
}
示例9: linkNotAdmin
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void linkNotAdmin() throws Exception {
final long initCount = importStatusRepository.count();
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
project.setTeamLeader(getAuthenticationName());
em.persist(project);
final Subscription subscription = new Subscription();
subscription.setProject(project);
subscription.setNode(nodeRepository.findOneExpected("service:bt:jira:6"));
em.persist(subscription);
addProjectParameters(subscription, 10074);
em.createQuery("DELETE ParameterValue v WHERE v.node.id = ?1 AND v.parameter.id = ?2")
.setParameter(2, JiraBaseResource.PARAMETER_ADMIN_USER).setParameter(1, "service:bt:jira:6").executeUpdate();
em.flush();
em.clear();
resource.link(subscription.getId());
em.flush();
Assert.assertEquals(initCount, importStatusRepository.count());
Assert.assertNull(resource.getTask(subscription.getId()));
}
示例10: delete
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void delete() throws Exception {
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
em.persist(project);
final Subscription subscription = new Subscription();
subscription.setProject(project);
subscription.setNode(nodeRepository.findOneExpected("service:qa"));
em.persist(subscription);
Assert.assertEquals(1, subscriptionRepository.findAllByProject(project.getId()).size());
em.flush();
em.clear();
resource.delete(subscription.getId(), false);
subscriptionRepository.delete(subscription);
em.flush();
em.clear();
Assert.assertEquals(0, subscriptionRepository.findAllByProject(project.getId()).size());
}
示例11: create
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void create() throws Exception {
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
em.persist(project);
em.flush();
final Subscription subscription = new Subscription();
subscription.setProject(project);
subscription.setNode(nodeRepository.findOneExpected("service:qa"));
em.persist(subscription);
em.flush();
em.clear();
resource.create(subscription.getId());
em.flush();
em.clear();
em.flush();
em.clear();
Assert.assertEquals(1, subscriptionRepository.findAllByProject(project.getId()).size());
}
示例12: createOrLink
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
public void createOrLink(final Consumer<Subscription> function) {
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
em.persist(project);
em.flush();
final Subscription subscription = new Subscription();
subscription.setProject(project);
subscription.setNode(nodeRepository.findOneExpected("service:bt"));
em.persist(subscription);
em.flush();
em.clear();
function.accept(subscription);
em.flush();
em.clear();
// Check SLA
final BugTrackerConfiguration configuration = repository.findBySubscriptionFetch(subscription.getId());
checkSla(configuration);
// Check calendar
final Calendar calendar = configuration.getCalendar();
Assert.assertNotNull(calendar);
Assert.assertEquals(44, calendar.getHolidays().size());
Assert.assertEquals("France", calendar.getName());
Assert.assertEquals("Jour de l'an", calendar.getHolidays().get(0).getName());
Assert.assertNotNull(calendar.getHolidays().get(0).getDate());
// Check default business hours
Assert.assertEquals(1, configuration.getBusinessHours().size());
Assert.assertEquals(8 * DateUtils.MILLIS_PER_HOUR, configuration.getBusinessHours().get(0).getStart());
Assert.assertEquals(18 * DateUtils.MILLIS_PER_HOUR, configuration.getBusinessHours().get(0).getEnd());
em.flush();
em.clear();
Assert.assertEquals(1, subscriptionRepository.findAllByProject(project.getId()).size());
}
示例13: createSubGroup
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
/**
* Create a group inside another group/ Both are created inside "sea" OU.
*
* @return the created {@link Subscription}.
*/
private Subscription createSubGroup(final Project newProject, final String parentGroup, final String subGroup) throws Exception {
// Preconditions
Assert.assertNotNull(getGroup().findById(parentGroup));
Assert.assertNull(getGroup().findById(subGroup));
Assert.assertNotNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("sea"));
// Attach the new group
final Subscription subscription = em.find(Subscription.class, this.subscription);
final Subscription subscription2 = new Subscription();
subscription2.setProject(newProject);
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, subGroup);
setParentGroup(subscription2, parentGroup);
setOu(subscription2, "sea");
basicCreate(subscription2);
// Checks
final GroupOrg groupLdap = getGroup().findById(subGroup);
Assert.assertNotNull(groupLdap);
Assert.assertEquals(subGroup, groupLdap.getName());
Assert.assertEquals("cn=" + subGroup + ",cn=" + parentGroup + ",ou=sea,ou=project,dc=sample,dc=com", groupLdap.getDn());
Assert.assertEquals(subGroup, groupLdap.getId());
Assert.assertEquals(1, groupLdap.getGroups().size());
Assert.assertTrue(groupLdap.getGroups().contains(parentGroup));
final GroupOrg groupLdapParent = getGroup().findById(parentGroup);
Assert.assertEquals(1, groupLdapParent.getSubGroups().size());
Assert.assertTrue(groupLdapParent.getSubGroups().contains(subGroup));
return subscription2;
}
示例14: linkInvalidDatabase
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test(expected = CannotGetJdbcConnectionException.class)
public void linkInvalidDatabase() throws Exception {
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
project.setTeamLeader(getAuthenticationName());
em.persist(project);
final Subscription subscription = new Subscription();
subscription.setProject(project);
subscription.setNode(nodeRepository.findOneExpected(JiraBaseResource.KEY));
em.persist(subscription);
final ParameterValue parameterValueEntity = new ParameterValue();
parameterValueEntity.setParameter(parameterRepository.findOne(JiraBaseResource.PARAMETER_JDBC_URL));
parameterValueEntity.setData("jdbc:hsqldb:mem:dataSource");
parameterValueEntity.setSubscription(subscription);
em.persist(parameterValueEntity);
final ParameterValue parameterValueEntity2 = new ParameterValue();
parameterValueEntity2.setParameter(parameterRepository.findOneExpected(JiraBaseResource.PARAMETER_JDBC_DRIVER));
parameterValueEntity2.setData("org.hsqldb.jdbc.JDBCDriver");
parameterValueEntity2.setSubscription(subscription);
em.persist(parameterValueEntity2);
final ParameterValue parameterValueEntity3 = new ParameterValue();
parameterValueEntity3.setParameter(parameterRepository.findOneExpected(JiraBaseResource.PARAMETER_JDBC_PASSSWORD));
parameterValueEntity3.setData("invalid");
parameterValueEntity3.setSubscription(subscription);
em.persist(parameterValueEntity3);
em.flush();
em.clear();
resource.link(subscription.getId());
}
示例15: createOrLink
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
public void createOrLink(final Consumer<Subscription> function) {
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
em.persist(project);
em.flush();
final Subscription subscription = new Subscription();
subscription.setProject(project);
subscription.setNode(nodeRepository.findOneExpected("service:bt"));
em.persist(subscription);
em.flush();
em.clear();
function.accept(subscription);
em.flush();
em.clear();
// Check SLA
final BugTrackerConfiguration configuration = repository.findBySubscriptionFetch(subscription.getId());
checkSla(configuration);
// Check calendar
final Calendar calendar = configuration.getCalendar();
Assert.assertNotNull(calendar);
Assert.assertEquals(66, calendar.getHolidays().size());
Assert.assertEquals("France", calendar.getName());
Assert.assertEquals("Jour de l'an", calendar.getHolidays().get(0).getName());
Assert.assertNotNull(calendar.getHolidays().get(0).getDate());
// Check default business hours
Assert.assertEquals(1, configuration.getBusinessHours().size());
Assert.assertEquals(8 * DateUtils.MILLIS_PER_HOUR, configuration.getBusinessHours().get(0).getStart());
Assert.assertEquals(18 * DateUtils.MILLIS_PER_HOUR, configuration.getBusinessHours().get(0).getEnd());
em.flush();
em.clear();
Assert.assertEquals(1, subscriptionRepository.findAllByProject(project.getId()).size());
}