Search in sources :

Example 6 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method findAllNoCriteriaOrder.

@Test
public void findAllNoCriteriaOrder() {
    final UriInfo uriInfo = Mockito.mock(UriInfo.class);
    Mockito.when(uriInfo.getQueryParameters()).thenReturn(new MetadataMap<>());
    uriInfo.getQueryParameters().add("draw", "1");
    uriInfo.getQueryParameters().add("start", "0");
    uriInfo.getQueryParameters().add("length", "10");
    uriInfo.getQueryParameters().add("columns[0][data]", "receiver");
    uriInfo.getQueryParameters().add("order[0][column]", "0");
    uriInfo.getQueryParameters().add("order[0][dir]", "desc");
    final TableItem<DelegateNode> items = resource.findAll(uriInfo, " ");
    Assertions.assertEquals(3, items.getData().size());
    Assertions.assertEquals(3, items.getRecordsFiltered());
    Assertions.assertEquals(3, items.getRecordsTotal());
    final DelegateNode delegateNode = items.getData().get(1);
    Assertions.assertEquals("junit", delegateNode.getReceiver());
    Assertions.assertEquals(ReceiverType.USER, delegateNode.getReceiverType());
    Assertions.assertEquals("service", delegateNode.getName());
    Assertions.assertTrue(delegateNode.isCanAdmin());
    Assertions.assertTrue(delegateNode.isCanWrite());
    Assertions.assertTrue(delegateNode.isCanSubscribe());
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) UriInfo(javax.ws.rs.core.UriInfo) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Example 7 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method createSubNodeMiniRight.

@Test
public void createSubNodeMiniRight() {
    // Add a special right on for a node
    final DelegateNode delegate = new DelegateNode();
    delegate.setNode("service:build:jenkins");
    delegate.setReceiver("user2");
    delegate.setCanAdmin(true);
    repository.saveAndFlush(delegate);
    initSpringSecurityContext("user2");
    final DelegateNode newDelegate = new DelegateNode();
    newDelegate.setNode("service:build:jenkins:dig");
    newDelegate.setReceiver("user2");
    newDelegate.setCanAdmin(true);
    Assertions.assertTrue(resource.create(newDelegate) > 0);
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Example 8 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method createExactNode.

@Test
public void createExactNode() {
    initSpringSecurityContext("user1");
    final DelegateNode delegate = new DelegateNode();
    delegate.setNode("service:build:jenkins");
    delegate.setReceiver("user1");
    Assertions.assertTrue(resource.create(delegate) > 0);
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Example 9 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method createSubNodeMaxiRight.

@Test
public void createSubNodeMaxiRight() {
    initSpringSecurityContext("user1");
    final DelegateNode delegate = new DelegateNode();
    delegate.setNode("service:build:jenkins:dig");
    delegate.setCanAdmin(true);
    delegate.setCanWrite(true);
    delegate.setCanSubscribe(true);
    delegate.setReceiver("user1");
    Assertions.assertTrue(resource.create(delegate) > 0);
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Example 10 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method findAllCriteriaNode.

@Test
public void findAllCriteriaNode() {
    final TableItem<DelegateNode> items = resource.findAll(newUriInfo(), "jenkins");
    Assertions.assertEquals(1, items.getData().size());
    Assertions.assertEquals(1, items.getRecordsFiltered());
    Assertions.assertEquals(1, items.getRecordsTotal());
    final DelegateNode delegateNode = items.getData().get(0);
    Assertions.assertEquals("user1", delegateNode.getReceiver());
    Assertions.assertEquals(ReceiverType.USER, delegateNode.getReceiverType());
    Assertions.assertEquals("service:build:jenkins", delegateNode.getName());
    Assertions.assertTrue(delegateNode.isCanAdmin());
    Assertions.assertTrue(delegateNode.isCanWrite());
    Assertions.assertTrue(delegateNode.isCanSubscribe());
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Aggregations

DelegateNode (org.ligoj.app.model.DelegateNode)15 Test (org.junit.jupiter.api.Test)14 AbstractJpaTest (org.ligoj.bootstrap.AbstractJpaTest)14 GET (javax.ws.rs.GET)1 UriInfo (javax.ws.rs.core.UriInfo)1 PageRequest (org.springframework.data.domain.PageRequest)1