Ejemplo n.º 1
0
  private void checkGroupValidity(Guid groupId, Guid bobId, Guid janeId) throws NotFoundException {
    ReadOnlySession session = support.currentSessionRO();

    TestGroupDMO groupDMO = session.find(TestGroupDMO.class, groupId);
    assertNotNull(groupDMO);
    assertEquals(groupId, groupDMO.getKey());

    boolean seenBob = false;
    boolean seenJane = false;

    assertEquals(2, groupDMO.getMembers().size());

    for (TestGroupMemberDMO groupMemberDMO : groupDMO.getMembers()) {
      TestUserDMO memberDMO = groupMemberDMO.getMember();
      if (memberDMO.getKey().equals(bobId)) {
        seenBob = true;
        assertEquals("Bob", memberDMO.getName());
      }
      if (memberDMO.getKey().equals(janeId)) {
        seenJane = true;
        assertEquals("Jane", memberDMO.getName());
      }
    }

    assertTrue(seenBob && seenJane);
  }
Ejemplo n.º 2
0
  // Test grouping
  public void testGrouping() throws Exception {
    EntityManager em;

    TestViewpoint viewpoint = new TestViewpoint(Guid.createNew());

    /////////////////////////////////////////////////
    // Setup

    em = support.beginSessionRW(viewpoint);

    TestUser bob = new TestUser("Bob");
    Guid bobId = bob.getGuid();
    em.persist(bob);

    em.getTransaction().commit();

    /////////////////////////////////////////////////

    em = support.beginSessionRO(viewpoint);

    ReadOnlySession session = support.currentSessionRO();

    TestUserDMO bobDMO = session.find(TestUserDMO.class, bobId);

    assertEquals("initializedA", bobDMO.getGroupedA());
    assertEquals("initializedB", bobDMO.getGroupedB());

    em.getTransaction().commit();
  }