use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.
the class DelegateNodeResource method findAll.
/**
* Retrieve all elements with pagination
*
* @param uriInfo
* pagination data.
* @param criteria
* Optional text to match.
* @return all elements with pagination.
*/
@GET
public TableItem<DelegateNode> findAll(@Context final UriInfo uriInfo, @QueryParam(DataTableAttributes.SEARCH) final String criteria) {
final PageRequest pageRequest = paginationJson.getPageRequest(uriInfo, ORDERED_COLUMNS);
final Page<DelegateNode> findAll = repository.findAll(securityHelper.getLogin(), StringUtils.trimToNull(criteria), pageRequest);
// apply pagination and prevent lazy initialization issue
return paginationJson.applyPagination(uriInfo, findAll, Function.identity());
}
use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.
the class DelegateNodeResourceTest method createNotExistsUser.
@Test
public void createNotExistsUser() {
initSpringSecurityContext("any");
final DelegateNode delegate = new DelegateNode();
delegate.setNode("service");
delegate.setReceiver("user1");
Assertions.assertThrows(NotFoundException.class, () -> {
resource.create(delegate);
});
}
use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.
the class DelegateNodeResourceTest method createNoRightAtThisLevel2.
@Test
public void createNoRightAtThisLevel2() {
initSpringSecurityContext("user1");
final DelegateNode delegate = new DelegateNode();
delegate.setNode("");
delegate.setReceiver("user1");
Assertions.assertThrows(NotFoundException.class, () -> {
resource.create(delegate);
});
}
use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.
the class DelegateNodeResourceTest method findAllCriteriaUser.
@Test
public void findAllCriteriaUser() {
final TableItem<DelegateNode> items = resource.findAll(newUriInfo(), "junit");
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("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());
}
use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.
the class DelegateNodeResourceTest method createNoRightAtThisLevel.
@Test
public void createNoRightAtThisLevel() {
initSpringSecurityContext("user1");
final DelegateNode delegate = new DelegateNode();
delegate.setNode("service:build");
delegate.setReceiver("user1");
Assertions.assertThrows(NotFoundException.class, () -> {
resource.create(delegate);
});
}
Aggregations