• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Subscription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.ligoj.app.model.Subscription的典型用法代码示例。如果您正苦于以下问题:Java Subscription类的具体用法?Java Subscription怎么用?Java Subscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Subscription类属于org.ligoj.app.model包,在下文中一共展示了Subscription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getActivities

import org.ligoj.app.model.Subscription; //导入依赖的package包/类
/**
 * Return activities associates by given a subscription.
 */
private ActivitiesComputations getActivities(final int subscription, final boolean global) throws Exception {
	// Get users from other LDAP subscriptions
	final Subscription main = subscriptionResource.checkVisibleSubscription(subscription);
	final List<Subscription> subscriptions = subscriptionRepository.findAllOnSameProject(subscription);
	final Set<UserOrg> users = global ? getMembersOfAllSubscription(subscriptions) : getMembersOfSubscription(main);

	// Get the activities from each subscription of the same project,
	final ActivitiesComputations result = new ActivitiesComputations();
	result.setUsers(users);
	final List<String> userLogins = users.stream().map(UserOrg::getId).collect(Collectors.toList());
	final Map<String, Map<String, Activity>> activities = new HashMap<>();
	final Set<INamableBean<String>> nodes = new LinkedHashSet<>();
	for (final Subscription projectSubscription : subscriptions) {
		final ServicePlugin resource = servicePluginLocator.getResource(projectSubscription.getNode().getId());
		addSubscriptionActivities(activities, userLogins, projectSubscription, resource, nodes);
	}
	result.setNodes(nodes);
	result.setActivities(activities);
	return result;
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:24,代码来源:LdapPluginResource.java


示例2: 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();
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:21,代码来源:LdapPluginResourceTest.java


示例3: 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);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:22,代码来源:LdapPluginResourceTest.java


示例4: 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);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:29,代码来源:LdapPluginResourceTest.java


示例5: 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);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:29,代码来源:LdapPluginResourceTest.java


示例6: 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);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:28,代码来源:LdapPluginResourceTest.java


示例7: 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);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:29,代码来源:LdapPluginResourceTest.java


示例8: 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"));
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:23,代码来源:LdapPluginResourceTest.java


示例9: 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"));
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:27,代码来源:LdapPluginResourceTest.java


示例10: checkAndSaveSchedule

import org.ligoj.app.model.Subscription; //导入依赖的package包/类
private VmSchedule checkAndSaveSchedule(final VmScheduleVo schedule, final VmSchedule entity) {
	// Check the subscription is visible
	final Subscription subscription = subscriptionResource.checkVisibleSubscription(schedule.getSubscription());

	if (schedule.getCron().split(" ").length == 6) {
		// Add the missing "seconds" part
		schedule.setCron(schedule.getCron() + " *");
	}
	// Check expressions first
	if (!CronExpression.isValidExpression(schedule.getCron())) {
		throw new ValidationJsonException("cron", "vm-cron");
	}

	// Every second is not accepted
	if (schedule.getCron().startsWith("* ")) {
		throw new ValidationJsonException("cron", "vm-cron-second");
	}

	entity.setSubscription(subscription);
	entity.setOperation(schedule.getOperation());
	entity.setCron(schedule.getCron());

	// Persist the new schedules for each provided CRON
	vmScheduleRepository.saveAndFlush(entity);
	return entity;
}
 
开发者ID:ligoj,项目名称:plugin-vm,代码行数:27,代码来源:VmResource.java


示例11: 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());
}
 
开发者ID:ligoj,项目名称:plugin-vm,代码行数:25,代码来源:VmResourceTest.java


示例12: getTerraformLog

import org.ligoj.app.model.Subscription; //导入依赖的package包/类
/**
 * Get the log of the current or last Terraform execution of a given
 * subscription.
 * 
 * @param subscription
 *            The related subscription.
 * @return the streaming {@link Response} with output.
 * @throws IOException
 *             When Terraform content cannot be written.
 */
@GET
@Produces(MediaType.TEXT_HTML)
@Path("{subscription:\\d+}/terraform.log")
public Response getTerraformLog(@PathParam("subscription") final int subscription) throws IOException {
	final Subscription entity = subscriptionResource.checkVisibleSubscription(subscription);
	final File log = toFile(entity, MAIN_LOG);

	// Check there is a log file
	if (log.exists()) {
		final StreamingOutput so = o -> FileUtils.copyFile(toFile(entity, MAIN_LOG), o);
		return Response.ok().entity(so).build();
	}

	// No log file for now
	return Response.status(Status.NOT_FOUND).build();
}
 
开发者ID:ligoj,项目名称:plugin-prov,代码行数:27,代码来源:TerraformResource.java


示例13: createNoCatalog

import org.ligoj.app.model.Subscription; //导入依赖的package包/类
@Test(expected = BusinessException.class)
public void createNoCatalog() throws Exception {
	final Subscription subscription = new Subscription();
	subscription.setNode(em.find(Subscription.class, this.subscription).getNode());
	subscription.setProject(em.find(Subscription.class, this.subscription).getProject());
	em.persist(subscription);
	qsRepository.deleteAll();
	qiRepository.deleteAll();
	ipRepository.deleteAll();
	iptRepository.deleteAll();
	itRepository.deleteAll();
	spRepository.deleteAll();
	stRepository.deleteAll();
	icsRepository.deleteAll();
	repository.deleteAll();
	locationRepository.deleteAll();
	em.flush();
	em.clear();
	resource.create(subscription.getId());
}
 
开发者ID:ligoj,项目名称:plugin-prov,代码行数:21,代码来源:ProvResourceTest.java


示例14: applyTerraformError

import org.ligoj.app.model.Subscription; //导入依赖的package包/类
/**
 * IOException during the asynchronous execution
 */
@Test
public void applyTerraformError() {
	final TerraformResource resource = new TerraformResource() {

		@Override
		protected File applyTerraform(final Subscription entity, final Terraforming terra, final QuoteVo configuration)
				throws IOException, InterruptedException {
			throw new IOException();
		}
	};
	super.applicationContext.getAutowireCapableBeanFactory().autowireBean(resource);

	// Mock to disable inner transactions for this test
	resource.resource = Mockito.mock(ProvResource.class);
	final ServicePluginLocator locator = Mockito.mock(ServicePluginLocator.class);

	// Replace the plugin locator
	resource.locator = locator;
	Mockito.when(locator.getResource("service:prov:test:account", Terraforming.class)).thenReturn(Mockito.mock(Terraforming.class));
	resource.applyTerraform(subscription);
}
 
开发者ID:ligoj,项目名称:plugin-prov,代码行数:25,代码来源:TerraformResourceTest.java


示例15: toFile

import org.ligoj.app.model.Subscription; //导入依赖的package包/类
@Test
public void toFile() throws IOException {
	ThreadClassLoaderScope scope = null;
	try {
		final PluginsClassLoader classLoader = Mockito.mock(PluginsClassLoader.class);
		scope = new ThreadClassLoaderScope(new URLClassLoader(new URL[0], classLoader));
		final File file = new File("");
		final Subscription entity = new Subscription();
		entity.setId(15);
		Mockito.when(classLoader.toFile(entity, "15", "some")).thenReturn(file);
		Assert.assertSame(file, resource.toFile(entity, "some"));
		Assert.assertNotNull(PluginsClassLoader.getInstance());
	} finally {
		IOUtils.closeQuietly(scope);
	}
}
 
开发者ID:ligoj,项目名称:plugin-prov,代码行数:17,代码来源:TerraformResourceTest.java


示例16: 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());
}
 
开发者ID:ligoj,项目名称:plugin-km-confluence,代码行数:24,代码来源:KmResourceTest.java


示例17: 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());
}
 
开发者ID:ligoj,项目名称:plugin-qa-sonarqube,代码行数:23,代码来源:QaResourceTest.java


示例18: 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());
}
 
开发者ID:ligoj,项目名称:plugin-qa-sonarqube,代码行数:24,代码来源:QaResourceTest.java


示例19: writeTerraform

import org.ligoj.app.model.Subscription; //导入依赖的package包/类
/**
 * Write Terraform content from a quote instance.
 * 
 * @param writer
 *            Target output of Terraform content.
 * @param quote
 *            quote instance
 * @param subscription
 *            The related subscription.
 * @throws IOException
 *             When Terraform content cannot be written.
 */
public void writeTerraform(final Writer writer, final QuoteVo quote, final Subscription subscription) throws IOException {
	final String projectName = subscription.getProject().getName();
	writeProvider(writer);
	if (!quote.getInstances().isEmpty()) {
		writePublicKey(writer);
		writeNetwork(writer, projectName,
				quote.getInstances().stream().map(ProvQuoteInstance::getInternet).collect(Collectors.toSet()));
		writeSecurityGroup(writer, projectName);
		writeKeyPair(writer, projectName);
		final Set<VmOs> osToSearch = new HashSet<>();
		for (final ProvQuoteInstance instance : quote.getInstances()) {
			writeInstance(writer, quote, instance, projectName);
			osToSearch.add(instance.getPrice().getOs());
		}

		// AMI part
		final String account = subscriptionResource.getParameters(subscription.getId()).get(ProvAwsPluginResource.PARAMETER_ACCOUNT);
		for (final VmOs os : osToSearch) {
			writeAmiSearch(writer, os, account);
		}
	}
	writeStandaloneStorages(writer, projectName, quote.getStorages());
}
 
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:36,代码来源:ProvAwsTerraformService.java


示例20: prepareData

import org.ligoj.app.model.Subscription; //导入依赖的package包/类
@Before
public void prepareData() throws IOException {
	persistSystemEntities();
	persistEntities("csv",
			new Class[] { Node.class, Project.class, CacheCompany.class, CacheUser.class, DelegateNode.class, Parameter.class,
					ProvLocation.class, ProvStorageType.class, Subscription.class, ParameterValue.class, ProvQuote.class },
			StandardCharsets.UTF_8.name());
	this.subscription = getSubscription("gStack");

	// Disable inner transaction
	this.resource = new ProvAwsPriceImportResource();
	applicationContext.getAutowireCapableBeanFactory().autowireBean(resource);
	this.resource.initSpotToNewRegion();
	this.resource.initEbsToApi();
	this.resource.importCatalogResource = new ImportCatalogResource();
	applicationContext.getAutowireCapableBeanFactory().autowireBean(this.resource.importCatalogResource);
	initSpringSecurityContext(DEFAULT_USER);
	resetImportTask();
}
 
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:20,代码来源:ProvAwsPriceImportResourceTest.java



注:本文中的org.ligoj.app.model.Subscription类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileWatchdog类代码示例发布时间:2022-05-22
下一篇:
Java SingleSignOnService类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap