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());
}
Aggregations