Examples of CrysonTestEntity


Examples of se.sperber.cryson.testutil.CrysonTestEntity

  public static class WhenRequestingMultipleRestrictedEntities {

    @Test
    public void shouldIncludeUnauthorizedEntities() {
      CrysonTestEntity authorizedEntity = new CrysonTestEntity(1L);
      CrysonTestEntity unauthorizedEntity = new CrysonTestEntity(2L);
      unauthorizedEntity.setShouldBeReadable(false);

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

      CrysonRepository crysonRepository = givenCrysonRepositoryWithCriteriaAndEntities(criteria, authorizedEntity, unauthorizedEntity);
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

  public static class WhenRequestingASingleRestrictedEntity {

    @Test
    public void shouldReturnAnUnauthorizedEntity() {
      CrysonTestEntity unauthorizedEntity = new CrysonTestEntity(1L);
      unauthorizedEntity.setShouldBeReadable(false);

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

      CrysonRepository crysonRepository = givenCrysonRepositoryWithCriteriaAndEntities(criteria, unauthorizedEntity);
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

      assertThat(crysonRepository.findById(CrysonTestEntity.class.getName(), 1L, new HashSet<String>()), is(expectedResult));
    }

    @Test
    public void shouldReturnAnEntity() {
      CrysonTestEntity authorizedEntity = new CrysonTestEntity(1L);
      authorizedEntity.setShouldBeReadable(true);

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

      CrysonRepository crysonRepository = givenCrysonRepositoryWithCriteriaAndEntities(criteria, authorizedEntity);
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

    PutMethod entityPutMethod = new PutMethod("http://localhost:8789/cryson/CrysonTestEntity");
    entityPutMethod.setRequestEntity(new StringRequestEntity(serializedEntity, "application/json", "UTF-8"));
    assertEquals(200, httpClient.executeMethod(entityPutMethod));

    CrysonTestEntity testEntity = crysonSerializer.deserialize(entityPutMethod.getResponseBodyAsString(), CrysonTestEntity.class, null);
    String serializedChildEntity = "{\"id\":null,\"parent_cryson_id\":" + testEntity.getId() + "}";

    PutMethod childEntityPutMethod = new PutMethod("http://localhost:8789/cryson/CrysonTestChildEntity");
    childEntityPutMethod.setRequestEntity(new StringRequestEntity(serializedChildEntity, "application/json", "UTF-8"));
    assertEquals(200, httpClient.executeMethod(childEntityPutMethod));
  }
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

  public void shouldFindEntityById() throws Exception {
    GetMethod getMethod = new GetMethod("http://localhost:8789/cryson/CrysonTestEntity/" + foundEntity.getId());
    int status = httpClient.executeMethod(getMethod);
    assertEquals(HttpStatus.SC_OK, status);
   
    CrysonTestEntity testEntity = crysonSerializer.deserialize(getMethod.getResponseBodyAsString(), CrysonTestEntity.class, null);
    assertEquals(foundEntity.getId(), testEntity.getId());
  }
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

    int status = httpClient.executeMethod(getMethod);
    assertEquals(HttpStatus.SC_OK, status);

    JsonElement jsonElement = crysonSerializer.parse(getMethod.getResponseBodyAsString());
    assertEquals(1, jsonElement.getAsJsonArray().size());
    CrysonTestEntity testEntity = crysonSerializer.deserialize(jsonElement.getAsJsonArray().get(0), CrysonTestEntity.class, null);
    assertEquals(foundEntity.getId(), testEntity.getId());
  }
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

    int status = httpClient.executeMethod(postMethod);
    assertEquals(HttpStatus.SC_OK, status);

    JsonElement jsonElement = crysonSerializer.parse(postMethod.getResponseBodyAsString());
    assertEquals(1, jsonElement.getAsJsonArray().size());
    CrysonTestEntity testEntity = crysonSerializer.deserialize(jsonElement.getAsJsonArray().get(0), CrysonTestEntity.class, null);
    assertEquals(foundEntity.getId(), testEntity.getId());
  }
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

    int status = httpClient.executeMethod(getMethod);
    assertEquals(HttpStatus.SC_OK, status);

    JsonElement jsonElement = crysonSerializer.parse(getMethod.getResponseBodyAsString());
    assertEquals(1, jsonElement.getAsJsonArray().size());
    CrysonTestEntity testEntity = crysonSerializer.deserialize(jsonElement.getAsJsonArray().get(0), CrysonTestEntity.class, null);
    assertEquals(foundEntity.getId(), testEntity.getId());
    assertEquals(foundEntity.getChildEntities().size(), testEntity.getChildEntities().size());
  }
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

    int status = httpClient.executeMethod(postMethod);
    assertEquals(HttpStatus.SC_OK, status);

    JsonElement jsonElement = crysonSerializer.parse(postMethod.getResponseBodyAsString());
    assertEquals(1, jsonElement.getAsJsonArray().size());
    CrysonTestEntity testEntity = crysonSerializer.deserialize(jsonElement.getAsJsonArray().get(0), CrysonTestEntity.class, null);
    assertEquals(foundEntity.getId(), testEntity.getId());
    assertEquals((long)foundEntity.getChildEntities().iterator().next().getId(), jsonElement.getAsJsonArray().get(0).getAsJsonObject().get("childEntities").getAsJsonArray().get(0).getAsJsonObject().get("id").getAsLong());
  }
View Full Code Here

Examples of se.sperber.cryson.testutil.CrysonTestEntity

    int status = httpClient.executeMethod(postMethod);
    assertEquals(HttpStatus.SC_OK, status);

    JsonElement jsonElement = crysonSerializer.parse(postMethod.getResponseBodyAsString());
    assertEquals(1, jsonElement.getAsJsonArray().size());
    CrysonTestEntity testEntity = crysonSerializer.deserialize(jsonElement.getAsJsonArray().get(0), CrysonTestEntity.class, null);
    assertEquals(foundEntity.getId(), testEntity.getId());
    assertEquals((long)foundEntity.getChildEntities().iterator().next().getId(), jsonElement.getAsJsonArray().get(0).getAsJsonObject().get("childEntities").getAsJsonArray().get(0).getAsJsonObject().get("id").getAsLong());
  }
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.