Search in sources :

Example 21 with Project

use of org.ligoj.app.model.Project in project plugin-vm by ligoj.

the class VmResourceTest method delete.

@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);
    Assertions.assertEquals(1, subscriptionRepository.findAllByProject(project.getId()).size());
    em.flush();
    em.clear();
    resource.delete(subscription.getId(), false);
    subscriptionRepository.delete(subscription);
    em.flush();
    em.clear();
    Assertions.assertEquals(0, subscriptionRepository.findAllByProject(project.getId()).size());
    Assertions.assertEquals(0, vmScheduleRepository.findBySubscription(subscription.getId()).size());
    Assertions.assertEquals(0, vmExecutionRepository.findAllBy("subscription.id", subscription.getId()).size());
}
Also used : Project(org.ligoj.app.model.Project) Subscription(org.ligoj.app.model.Subscription) Test(org.junit.jupiter.api.Test) AbstractServerTest(org.ligoj.app.AbstractServerTest)

Aggregations

Project (org.ligoj.app.model.Project)21 Test (org.junit.jupiter.api.Test)12 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)9 Subscription (org.ligoj.app.model.Subscription)6 SubscriptionVo (org.ligoj.app.resource.subscription.SubscriptionVo)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Node (org.ligoj.app.model.Node)2 Parameter (org.ligoj.app.model.Parameter)2 ParameterValue (org.ligoj.app.model.ParameterValue)2 EventVo (org.ligoj.app.resource.node.EventVo)2 Comparator (java.util.Comparator)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 DELETE (javax.ws.rs.DELETE)1