Package se.sperber.cryson.testutil

Examples of se.sperber.cryson.testutil.CrysonTestChildEntity


   
    @Test
    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


    @Test
    public void shouldSerializeEagerFetchedToManyUnauthorizedEntities() {
      CrysonSerializer serializer = givenCrysonSerializer();

      CrysonTestChildEntity authorizedTestChildEntity = new CrysonTestChildEntity();
      authorizedTestChildEntity.setId(100L);
      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");
View Full Code Here

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

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

      String serializedChildEntity = "{\"id\":100,\"parent_cryson_id\":1}";

      CrysonTestChildEntity deserializedChildEntity = crysonSerializer.deserialize(serializedChildEntity, CrysonTestChildEntity.class, null);

      assertNotNull(deserializedChildEntity);
      assertEquals((Long)100l, deserializedChildEntity.getId());
      assertEquals((Long)1l, deserializedChildEntity.getParent().getId());
    }
View Full Code Here

      CrysonSerializer crysonSerializer = givenCrysonSerializer();

      String serializedChildEntity = "{\"id\":100,\"parent_cryson_id\":1}";

      JsonElement childEntityJsonElement = crysonSerializer.parse(serializedChildEntity);
      CrysonTestChildEntity deserializedChildEntity = crysonSerializer.deserialize(childEntityJsonElement, CrysonTestChildEntity.class, null);

      assertNotNull(deserializedChildEntity);
      assertEquals((Long)100l, deserializedChildEntity.getId());
      assertEquals((Long)1l, deserializedChildEntity.getParent().getId());
    }
View Full Code Here

TOP

Related Classes of se.sperber.cryson.testutil.CrysonTestChildEntity

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.