Package se.sperber.cryson.serialization

Examples of se.sperber.cryson.serialization.UnauthorizedEntity


      Criteria criteria = givenCriteria();
      when(criteria.list()).thenReturn(Arrays.asList(authorizedEntity, unauthorizedEntity));

      CrysonRepository crysonRepository = givenCrysonRepositoryWithCriteriaAndEntities(criteria, authorizedEntity, unauthorizedEntity);

      List expectedResult = Arrays.asList(authorizedEntity, new UnauthorizedEntity("CrysonTestEntity", 2L));
      assertThat(crysonRepository.findByIds(CrysonTestEntity.class.getName(), Arrays.asList(1L, 2L), new HashSet<String>()), is(expectedResult));
    }
View Full Code Here


      Criteria criteria = givenCriteria();
      when(criteria.uniqueResult()).thenReturn(unauthorizedEntity);

      CrysonRepository crysonRepository = givenCrysonRepositoryWithCriteriaAndEntities(criteria, unauthorizedEntity);

      Object expectedResult = new UnauthorizedEntity("CrysonTestEntity", 1L);
      assertThat(crysonRepository.findById(CrysonTestEntity.class.getName(), 1L, new HashSet<String>()), is(expectedResult));
    }
View Full Code Here

  private Object getEntityOrUnauthorizedEntity(Object entity) {
    if (entity instanceof Restrictable) {
      if (((Restrictable) entity).isReadableBy(SecurityContextHolder.getContext().getAuthentication())) {
        return entity;
      } else {
        return new UnauthorizedEntity(entity.getClass().getSimpleName(), reflectionHelper.getPrimaryKey(entity));
      }
    }
    return entity;
  }
View Full Code Here

TOP

Related Classes of se.sperber.cryson.serialization.UnauthorizedEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.