本文整理汇总了Java中org.ligoj.app.model.Subscription.setNode方法的典型用法代码示例。如果您正苦于以下问题:Java Subscription.setNode方法的具体用法?Java Subscription.setNode怎么用?Java Subscription.setNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ligoj.app.model.Subscription
的用法示例。
在下文中一共展示了Subscription.setNode方法的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: 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:km"));
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());
}
示例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: 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()));
}
示例5: 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);
}
示例6: addSubscriptionActivities
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void addSubscriptionActivities() throws Exception {
final LdapPluginResource resource = new LdapPluginResource();
final Map<String, Map<String, Activity>> activities = new HashMap<>();
final Subscription susbscription = new Subscription();
final Node service = new Node();
service.setId("J1");
susbscription.setNode(service);
susbscription.setId(1);
final SampleActivityProvider plugin = Mockito.mock(SampleActivityProvider.class);
final Map<String, Activity> activities1 = new HashMap<>();
final Activity activity2 = new Activity();
activities1.put(DEFAULT_USER, activity2);
Mockito.when(plugin.getActivities(1, null)).thenReturn(activities1);
final Set<INamableBean<String>> nodes = new HashSet<>();
resource.addSubscriptionActivities(activities, null, susbscription, plugin, nodes);
Assert.assertEquals(1, activities.size());
Assert.assertTrue(activities.containsKey(DEFAULT_USER));
Assert.assertEquals(1, activities.get(DEFAULT_USER).size());
Assert.assertTrue(activities.get(DEFAULT_USER).containsKey("J1"));
Assert.assertEquals(activity2, activities.get(DEFAULT_USER).get("J1"));
}
示例7: addSubscriptionActivitiesDuplicateUser
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void addSubscriptionActivitiesDuplicateUser() throws Exception {
final LdapPluginResource resource = new LdapPluginResource();
final Map<String, Map<String, Activity>> activities = new HashMap<>();
activities.put(DEFAULT_USER, new HashMap<>());
final Activity activity1 = new Activity();
activities.get(DEFAULT_USER).put("J0", activity1);
final Subscription susbscription = new Subscription();
final Node service = new Node();
service.setId("J1");
susbscription.setNode(service);
susbscription.setId(1);
final SampleActivityProvider plugin = Mockito.mock(SampleActivityProvider.class);
final Map<String, Activity> activities1 = new HashMap<>();
final Activity activity2 = new Activity();
activities1.put(DEFAULT_USER, activity2);
Mockito.when(plugin.getActivities(1, null)).thenReturn(activities1);
final Set<INamableBean<String>> nodes = new HashSet<>();
resource.addSubscriptionActivities(activities, null, susbscription, plugin, nodes);
Assert.assertEquals(1, activities.size());
Assert.assertTrue(activities.containsKey(DEFAULT_USER));
Assert.assertEquals(2, activities.get(DEFAULT_USER).size());
Assert.assertTrue(activities.get(DEFAULT_USER).containsKey("J1"));
Assert.assertEquals(activity1, activities.get(DEFAULT_USER).get("J0"));
Assert.assertEquals(activity2, activities.get(DEFAULT_USER).get("J1"));
}
示例8: 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());
}
示例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: create
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
/**
* Create a group in a existing OU "sea". Most Simple case. Group matches exactly to the pkey of the project.
*
* @return the created subscription.
*/
private Subscription create(final String groupAndProject) throws Exception {
// Preconditions
Assert.assertNull(getGroup().findById(groupAndProject));
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();
final Project newProject = newProject(groupAndProject);
subscription2.setProject(newProject);
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, groupAndProject);
setOu(subscription2, "sea");
basicCreate(subscription2);
// Checks
final GroupOrg groupLdap = getGroup().findById(groupAndProject);
Assert.assertNotNull(groupLdap);
Assert.assertEquals(groupAndProject, groupLdap.getName());
Assert.assertEquals(groupAndProject, groupLdap.getId());
Assert.assertEquals("cn=" + groupAndProject + ",ou=sea,ou=project,dc=sample,dc=com", groupLdap.getDn());
Assert.assertNotNull(projectCustomerLdapRepository.findAllNoCache("ou=project,dc=sample,dc=com").get("sea"));
Assert.assertNotNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("sea"));
return subscription2;
}
示例11: linkInvalidAdmin
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void linkInvalidAdmin() throws Exception {
thrown.expect(ValidationJsonException.class);
thrown.expect(MatcherUtil.validationMatcher(JiraBaseResource.PARAMETER_ADMIN_USER, "jira-admin"));
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);
// Set an invalid URL
em.createQuery("UPDATE ParameterValue v SET v.data = ?3 WHERE v.node.id = ?1 AND v.parameter.id = ?2")
.setParameter(1, JiraBaseResource.PARAMETER_URL).setParameter(2, "service:bt:jira:6").setParameter(3, "any")
.executeUpdate();
em.flush();
em.clear();
CacheManager.getInstance().getCache("subscription-parameters").removeAll();
try {
resource.link(subscription.getId());
} finally {
CacheManager.getInstance().getCache("subscription-parameters").removeAll();
}
}
示例12: createOuNotExists
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
/**
* Create a group inside a new organizational unit. Not an error, lazy creation. Exact match for group and pkey.
*/
@Test
public void createOuNotExists() throws Exception {
// Preconditions
Assert.assertNull(getGroup().findById("some-new-project"));
Assert.assertNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("some"));
// Attach the new group
final Subscription subscription = em.find(Subscription.class, this.subscription);
final Subscription subscription2 = new Subscription();
subscription2.setProject(newProject("some-new-project"));
subscription2.setNode(subscription.getNode());
em.persist(subscription2);
// Add parameters
setGroup(subscription2, "some-new-project");
setOu(subscription2, "some");
basicCreate(subscription2);
// Checks
final GroupOrg groupLdap = getGroup().findById("some-new-project");
Assert.assertNotNull(groupLdap);
Assert.assertEquals("some-new-project", groupLdap.getName());
Assert.assertEquals("cn=some-new-project,ou=some,ou=project,dc=sample,dc=com", groupLdap.getDn());
Assert.assertEquals("some-new-project", groupLdap.getId());
Assert.assertNotNull(projectCustomerLdapRepository.findAll("ou=project,dc=sample,dc=com").get("some"));
resource.delete(subscription2.getId(), true);
}
示例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: executeUnavailablePlugin
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void executeUnavailablePlugin() throws Exception {
final VmResource resource = new VmResource();
final Subscription entity = subscriptionRepository.findOneExpected(subscription);
final Node node = new Node();
node.setId("_deleted_plugin_");
node.setName("any");
nodeRepository.saveAndFlush(node);
entity.setNode(node);
subscriptionRepository.saveAndFlush(entity);
applicationContext.getAutowireCapableBeanFactory().autowireBean(resource);
resource.servicePluginLocator = mockServicePluginLocator;
resource.execute(entity, VmOperation.OFF);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.OFF);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.ON);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.REBOOT);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.RESET);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.SHUTDOWN);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.SUSPEND);
Assert.assertEquals(1, vmExecutionRepository.findAllBy("subscription.id", subscription).size());
final VmExecution execution = vmExecutionRepository.findBy("subscription.id", subscription);
Assert.assertFalse(execution.isSucceed());
Assert.assertEquals("fdaugan", execution.getTrigger());
Assert.assertEquals(VmOperation.OFF, execution.getOperation());
Assert.assertEquals("Plugin issue for _deleted_plugin_:Not found", execution.getError());
}
示例15: deleteSchedule
import org.ligoj.app.model.Subscription; //导入方法依赖的package包/类
@Test
public void deleteSchedule() throws Exception {
Assert.assertEquals(1, vmScheduleRepository.findAll().size());
final Subscription entity = subscriptionRepository.findOneExpected(subscription);
// Persist another VM schedule for another subscription
final Subscription otherEntity = new Subscription();
otherEntity.setProject(entity.getProject());
otherEntity.setNode(entity.getNode());
subscriptionRepository.saveAndFlush(otherEntity);
final VmScheduleVo schedule2 = newSchedule("0 0 0 1 1 ? 2050", VmOperation.OFF);
schedule2.setSubscription(otherEntity.getId());
final int schedule = resource.createSchedule(schedule2);
Assert.assertEquals(2, vmScheduleRepository.findAll().size());
resource.deleteSchedule(schedule);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.ON);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.OFF);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.REBOOT);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.RESET);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.SHUTDOWN);
Mockito.verify(mockVmTool, Mockito.never()).execute(subscription, VmOperation.SUSPEND);
Assert.assertEquals(1, vmScheduleRepository.findAll().size());
// Remove all triggers of the subscription
resource.unscheduleAll(subscription);
Assert.assertEquals(0, vmScheduleRepository.findAll().size());
}