本文整理汇总了Java中org.ligoj.app.model.Node.setId方法的典型用法代码示例。如果您正苦于以下问题:Java Node.setId方法的具体用法?Java Node.setId怎么用?Java Node.setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ligoj.app.model.Node
的用法示例。
在下文中一共展示了Node.setId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSubscriptionActivities
import org.ligoj.app.model.Node; //导入方法依赖的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"));
}
示例2: addSubscriptionActivitiesDuplicateUser
import org.ligoj.app.model.Node; //导入方法依赖的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"));
}
示例3: newLdap
import org.ligoj.app.model.Node; //导入方法依赖的package包/类
private void newLdap() {
final Node ldap = new Node();
ldap.setId("service:id:ldap:secondary");
ldap.setRefined(nodeRepository.findOneExpected("service:id:ldap"));
ldap.setName("LDAP Test");
nodeRepository.saveAndFlush(ldap);
persistParameter(ldap, LdapPluginResource.PARAMETER_URL, "ldap://localhost:34389/");
persistParameter(ldap, LdapPluginResource.PARAMETER_USER, "uid=admin,ou=system");
persistParameter(ldap, LdapPluginResource.PARAMETER_PASSWORD, "secret");
persistParameter(ldap, LdapPluginResource.PARAMETER_BASE_BN, "");
persistParameter(ldap, LdapPluginResource.PARAMETER_UID_ATTRIBUTE, "uid");
persistParameter(ldap, LdapPluginResource.PARAMETER_PEOPLE_DN, "dc=sample,dc=com");
persistParameter(ldap, LdapPluginResource.PARAMETER_DEPARTMENT_ATTRIBUTE, "departmentNumber");
persistParameter(ldap, LdapPluginResource.PARAMETER_LOCAL_ID_ATTRIBUTE, "employeeNumber");
persistParameter(ldap, LdapPluginResource.PARAMETER_PEOPLE_CLASS, "inetOrgPerson");
persistParameter(ldap, LdapPluginResource.PARAMETER_COMPANY_PATTERN, "gfi");
}
示例4: addSubscriptionActivitiesDuplicateNode
import org.ligoj.app.model.Node; //导入方法依赖的package包/类
@Test
public void addSubscriptionActivitiesDuplicateNode() throws Exception {
final Map<String, Map<String, Activity>> activities = new HashMap<>();
final LdapPluginResource resource = new LdapPluginResource();
final Subscription susbscription = new Subscription();
final Node service = new Node();
service.setId("J");
susbscription.setNode(service);
final SampleActivityProvider plugin = Mockito.mock(SampleActivityProvider.class);
final Set<INamableBean<String>> nodes = new HashSet<>();
nodes.add(service);
resource.addSubscriptionActivities(activities, null, susbscription, plugin, nodes);
Assert.assertTrue(activities.isEmpty());
}
示例5: acceptNotMatch
import org.ligoj.app.model.Node; //导入方法依赖的package包/类
@Test
public void acceptNotMatch() {
final Node ldap = new Node();
ldap.setId("service:id:ldap:test");
ldap.setRefined(nodeRepository.findOneExpected("service:id:ldap"));
ldap.setName("LDAP Test");
nodeRepository.saveAndFlush(ldap);
final ParameterValue parameterValue = new ParameterValue();
parameterValue.setNode(ldap);
parameterValue.setParameter(parameterRepository.findOneExpected("service:id:uid-pattern"));
parameterValue.setData("-nomatch-");
em.persist(parameterValue);
Assert.assertFalse(resource.accept(new UsernamePasswordAuthenticationToken("some", ""), "service:id:ldap:test"));
}
示例6: accept
import org.ligoj.app.model.Node; //导入方法依赖的package包/类
@Test
public void accept() {
final Node ldap = new Node();
ldap.setId("service:id:ldap:test");
ldap.setRefined(nodeRepository.findOneExpected("service:id:ldap"));
ldap.setName("LDAP Test");
nodeRepository.saveAndFlush(ldap);
persistParameter(ldap, IdentityResource.PARAMETER_UID_PATTERN, "some-.*-text");
Assert.assertTrue(resource.accept(new UsernamePasswordAuthenticationToken("some-awesome-text", ""), "service:id:ldap:test"));
}
示例7: executeUnavailablePlugin
import org.ligoj.app.model.Node; //导入方法依赖的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());
}
示例8: findAll
import org.ligoj.app.model.Node; //导入方法依赖的package包/类
@Test
public void findAll() {
final ImportCatalogResource resource = newResource();
// Add importable provider
resource.locator = Mockito.mock(ServicePluginLocator.class);
final ImportCatalogService service = Mockito.mock(ImportCatalogService.class);
Mockito.when(resource.locator.getResource("service:prov:test", ImportCatalogService.class)).thenReturn(service);
// Add not updatable provider node
final Node notImportNode = new Node();
notImportNode.setId("service:prov:any");
notImportNode.setName("Cannot import");
notImportNode.setRefined(nodeRepository.findOneExpected("service:prov"));
nodeRepository.saveAndFlush(notImportNode);
final List<CatalogVo> catalogs = resource.findAll();
Assert.assertEquals(3, catalogs.size());
// This provider does not support catalog update
Assert.assertEquals(0, catalogs.get(0).getStatus().getNbInstancePrices().intValue());
Assert.assertNull(catalogs.get(0).getStatus().getEnd());
Assert.assertNull(catalogs.get(0).getStatus().getStart());
Assert.assertEquals("service:prov:any", catalogs.get(0).getNode().getId());
Assert.assertFalse(catalogs.get(0).isCanImport());
Assert.assertEquals(0, catalogs.get(0).getNbQuotes());
// This provider supports catalog update
Assert.assertNotNull(catalogs.get(1).getStatus());
Assert.assertEquals("service:prov:test", catalogs.get(1).getNode().getId());
Assert.assertTrue(catalogs.get(1).isCanImport());
Assert.assertEquals(2, catalogs.get(1).getNbQuotes());
// This provider does not support catalog update
Assert.assertEquals("service:prov:x", catalogs.get(2).getNode().getId());
Assert.assertFalse(catalogs.get(2).isCanImport());
Assert.assertNull(catalogs.get(2).getStatus().getEnd());
Assert.assertNull(catalogs.get(2).getStatus().getStart());
Assert.assertEquals(1, catalogs.get(2).getNbQuotes());
final ImportCatalogStatus status = catalogs.get(1).getStatus();
Assert.assertEquals(DEFAULT_USER, status.getAuthor());
Assert.assertNull(status.getEnd());
Assert.assertNull(status.getLocation());
Assert.assertEquals("service:prov:test", status.getLocked().getId());
Assert.assertNotNull(status.getStart());
Assert.assertEquals(0, status.getDone());
Assert.assertEquals(0, status.getWorkload());
}