@Test
public void shouldSerializeEagerFetchedToOneUnauthorizedEntity() {
CrysonSerializer serializer = givenCrysonSerializer();
CrysonTestChildEntity testChildEntity = new CrysonTestChildEntity();
testChildEntity.setId(100L);
CrysonTestEntity unauthorizedTestEntity = new CrysonTestEntity();
unauthorizedTestEntity.setId(1L);
unauthorizedTestEntity.setVersion(1L);
unauthorizedTestEntity.setName("test");
unauthorizedTestEntity.setChildEntities(Sets.newLinkedHashSet(Arrays.asList(testChildEntity)));
unauthorizedTestEntity.setShouldBeReadable(false);
testChildEntity.setParent(unauthorizedTestEntity);
String serializedEntity = serializer.serialize(testChildEntity, Sets.newHashSet("parent"));
assertEquals("{\"id\":100,\"parent\":{\"id\":1,\"crysonEntityClass\":\"CrysonTestEntity\",\"crysonUnauthorized\":true},\"crysonEntityClass\":\"CrysonTestChildEntity\"}", serializedEntity);
}