use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class TestAbstractConfiguredServicePlugin method checkVisibility.
@Test
public void checkVisibility() {
final Subscription subscription = new Subscription();
final Node node = new Node();
node.setId("service:s:t:i");
subscription.setNode(node);
Assertions.assertSame(subscription, resource.checkVisibility(subscription, "service:s"));
Assertions.assertSame(subscription, resource.checkVisibility(subscription, "service:s:t"));
Assertions.assertSame(subscription, resource.checkVisibility(subscription, "service:s:t:i"));
}
use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class ProjectResourceTest method findByIdNoParameter.
/**
* Test {@link ProjectResource#findById(int)} when a subscription has no parameter.
*/
@Test
public void findByIdNoParameter() {
// Pre check
initSpringSecurityContext("fdaugan");
Assertions.assertEquals(1, resource.findById(testProject.getId()).getSubscriptions().size());
em.flush();
em.clear();
final Subscription subscription = new Subscription();
subscription.setProject(testProject);
subscription.setNode(nodeRepository.findOneExpected("service:build:jenkins"));
subscriptionRepository.saveAndFlush(subscription);
em.flush();
em.clear();
// Post check
final List<SubscriptionVo> subscriptions = resource.findById(testProject.getId()).getSubscriptions();
Assertions.assertEquals(2, subscriptions.size());
Assertions.assertEquals("service:bt:jira:4", subscriptions.get(0).getNode().getId());
Assertions.assertEquals("service:build:jenkins", subscriptions.get(1).getNode().getId());
Assertions.assertEquals(0, subscriptions.get(1).getParameters().size());
}
use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class SubscriptionResourceTest method assertDelete.
private void assertDelete() throws Exception {
final Subscription one = repository.findOne(subscription);
final int project = one.getProject().getId();
Assertions.assertEquals(1, repository.findAllByProject(project).size());
em.clear();
resource.delete(subscription);
em.flush();
em.clear();
Assertions.assertTrue(repository.findAllByProject(project).isEmpty());
Assertions.assertNull(repository.findOne(subscription));
}
use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class SubscriptionResourceTest method deleteNotVisibleProject.
@Test
public void deleteNotVisibleProject() {
final Subscription one = repository.findOne(subscription);
final int project = one.getProject().getId();
Assertions.assertEquals(1, repository.findAllByProject(project).size());
em.clear();
initSpringSecurityContext("any");
Assertions.assertThrows(EntityNotFoundException.class, () -> {
resource.delete(subscription);
});
}
use of org.ligoj.app.model.Subscription in project ligoj-api by ligoj.
the class SubscriptionResourceTest method toStringTest.
@Test
public void toStringTest() {
final Subscription subscription = repository.findOneExpected(this.subscription);
final String subscriptionStr = subscription.toString();
Assertions.assertTrue(subscriptionStr.startsWith("Subscription(super=Entity of type org.ligoj.app.model.Subscription with id: "));
Assertions.assertTrue(subscriptionStr.endsWith(", node=AbstractNamedBusinessEntity(name=JIRA 4), project=AbstractNamedAuditedEntity(name=MDA))"));
Assertions.assertEquals("Subscription(super=Entity of type org.ligoj.app.model.Subscription with id: null, node=null, project=null)", new Subscription().toString());
}
Aggregations