Examples of CrysonTestEntity


Examples of se.sperber.cryson.testutil.CrysonTestEntity

    public void shouldSerialize() {
      CrysonSerializer crysonSerializer = givenCrysonSerializer();
     
      CrysonTestChildEntity testChildEntity = new CrysonTestChildEntity();
      testChildEntity.setId(100L);
      CrysonTestEntity testEntity = new CrysonTestEntity();
      testEntity.setId(1L);
      testEntity.setName("test");
      testEntity.setVersion(1L);
      testEntity.setChildEntities(Collections.singleton(testChildEntity));
      testChildEntity.setParent(testEntity);
     
      String serializedChildEntity = crysonSerializer.serialize(testChildEntity);
      String expectedSerializedChildEntity = "{\"id\":100,\"parent\":{\"id\":1,\"name\":\"test\",\"version\":1,\"crysonEntityClass\":\"CrysonTestEntity\",\"doubleId\":2,\"childEntities_cryson_ids\":[100]},\"crysonEntityClass\":\"CrysonTestChildEntity\"}";
      assertEquals(expectedSerializedChildEntity, serializedChildEntity);
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

      authorizedTestChildEntity.setShouldBeReadable(true);
      CrysonTestChildEntity unauthorizedTestChildEntity = new CrysonTestChildEntity();
      unauthorizedTestChildEntity.setId(200L);
      unauthorizedTestChildEntity.setShouldBeReadable(false);

      CrysonTestEntity testEntity = new CrysonTestEntity();
      testEntity.setId(1L);
      testEntity.setVersion(1L);
      testEntity.setName("test");
      testEntity.setChildEntities(Sets.newLinkedHashSet(Arrays.asList(authorizedTestChildEntity, unauthorizedTestChildEntity)));

      String serializedEntity = serializer.serialize(testEntity, Sets.newHashSet("childEntities"));
      assertEquals("{\"id\":1,\"name\":\"test\",\"version\":1,\"crysonEntityClass\":\"CrysonTestEntity\",\"doubleId\":2,\"childEntities\":[{\"id\":100,\"parent\":null,\"crysonEntityClass\":\"CrysonTestChildEntity\"},{\"id\":200,\"crysonEntityClass\":\"CrysonTestChildEntity\",\"crysonUnauthorized\":true}]}", serializedEntity);
    }
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

      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);
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

    public void shouldDeserializeWithToManyAssociation() throws Exception {
      CrysonSerializer crysonSerializer = givenCrysonSerializer();

      String serializedEntity = "{\"id\":1,\"childEntities_cryson_ids\":[100]}";

      CrysonTestEntity deserializedEntity = crysonSerializer.deserialize(serializedEntity, CrysonTestEntity.class, null);

      assertNotNull(deserializedEntity);
      assertEquals((Long)1l, deserializedEntity.getId());
      assertEquals(1, deserializedEntity.getChildEntities().size());
      assertEquals((Long)100l, deserializedEntity.getChildEntities().iterator().next().getId());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.