Search in sources :

Example 16 with Subscription

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"));
}
Also used : Node(org.ligoj.app.model.Node) Subscription(org.ligoj.app.model.Subscription) Test(org.junit.jupiter.api.Test)

Example 17 with Subscription

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());
}
Also used : Subscription(org.ligoj.app.model.Subscription) SubscriptionVo(org.ligoj.app.resource.subscription.SubscriptionVo) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 18 with Subscription

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));
}
Also used : Subscription(org.ligoj.app.model.Subscription) TaskSampleSubscription(org.ligoj.app.model.TaskSampleSubscription)

Example 19 with 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);
    });
}
Also used : Subscription(org.ligoj.app.model.Subscription) TaskSampleSubscription(org.ligoj.app.model.TaskSampleSubscription) Test(org.junit.jupiter.api.Test) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest)

Example 20 with 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());
}
Also used : Subscription(org.ligoj.app.model.Subscription) TaskSampleSubscription(org.ligoj.app.model.TaskSampleSubscription) Test(org.junit.jupiter.api.Test) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest)

Aggregations

Subscription (org.ligoj.app.model.Subscription)43 Test (org.junit.jupiter.api.Test)22 Path (javax.ws.rs.Path)10 Node (org.ligoj.app.model.Node)10 AbstractServerTest (org.ligoj.app.AbstractServerTest)9 IOException (java.io.IOException)7 GET (javax.ws.rs.GET)7 POST (javax.ws.rs.POST)7 HashMap (java.util.HashMap)6 Transactional (javax.transaction.Transactional)6 Produces (javax.ws.rs.Produces)6 Map (java.util.Map)5 Optional (java.util.Optional)5 PathParam (javax.ws.rs.PathParam)5 MediaType (javax.ws.rs.core.MediaType)5 Slf4j (lombok.extern.slf4j.Slf4j)5 File (java.io.File)4 Date (java.util.Date)4 Function (java.util.function.Function)4 DELETE (javax.ws.rs.DELETE)4