public static Address addressExample2() {
   Address address = new Address();
   address.setCity("Ekumseekum");
   address.setCountry("Canada");
   address.setPostalCode("B2N 2C0");
   address.setProvince("Nova Scotia");
   address.setStreet("2 Main");
   return address;
 }
 public static Address addressExample4() {
   Address address = new Address();
   address.setCity("Gander");
   address.setCountry("Canada");
   address.setPostalCode("A2C1B1");
   address.setProvince("Newfoundland");
   address.setStreet("324 Bay Street");
   return address;
 }
 public static Address addressExample1() {
   Address address = new Address();
   address.setCity("Washabuc");
   address.setCountry("Canada");
   address.setPostalCode("K2T3A4");
   address.setProvince("Ontario");
   address.setStreet("1734 Wallywoo Drive");
   return address;
 }
 public static Address addressExample3() {
   Address address = new Address();
   address.setCity("Shoolee");
   address.setCountry("Canada");
   address.setPostalCode("B1M 1C2");
   address.setProvince("Nova Scotia");
   address.setStreet("3 Main");
   return address;
 }
Ejemplo n.º 5
0
  public void testAddAndRemoveUser() throws Exception {
    User user = new User("testuser");
    user.setPassword("testpass");
    user.setFirstName("Test");
    user.setLastName("Last");
    Address address = new Address();
    address.setCity("Denver");
    address.setProvince("CO");
    address.setCountry("USA");
    address.setPostalCode("80210");
    user.setAddress(address);
    user.setEmail("*****@*****.**");
    user.setWebsite("http://tek42.com");
    user.setTimeZone("US/Central");

    // Here we are creating an org that should already be in the database...
    // Ideally, we somehow have an org object... from the other dao or whatever...
    /*
     * Account org = new Account(); org.setName("Tek42"); org.setId(1L);
     */
    Account org = adao.get(2L);
    System.out.println("Have org: " + org);
    user.setAccount(org);

    Role role = rdao.getRoleByName(Constants.USER_ROLE);
    assertNotNull(role.getId());
    user.addRole(role);

    user = dao.saveUser(user);

    assertNotNull(user.getId());

    user = dao.get(user.getId());

    assertEquals("Vigilant", user.getAccount().getName());
    assertEquals("testpass", user.getPassword());
    assertEquals("US/Central", user.getTimeZone());

    dao.remove(user.getId());

    try {
      dao.get(user.getId());
      fail("getUser didn't throw DataAccessException");
    } catch (DataAccessException d) {
      assertNotNull(d);
    }
  }