Package info.galleria.domain

Examples of info.galleria.domain.User


  @Test
  public void testModifyUserModifyAlbum() throws Exception
  {
    //Setup
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    user.addToAlbums(album);
    em.persist(user);
   
    em.flush();
    em.clear();
   
    //Execute
    String modifiedAlbumName = "Modified Album Name";
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.setName(modifiedAlbumName);
      }
    }
    user = repository.modify(user);
    em.flush();
    em.clear();
   
    //Verify
    User actualUser = em.find(User.class, TEST_USER_ID);
    assertEquals(user, actualUser);
    for(Album actualAlbum : actualUser.getAlbums())
    {
      assertFalse(actualAlbum.getName().equals(TEST_ALBUM_NAME));
      assertTrue(actualAlbum.getName().equals(modifiedAlbumName));
    }
  }
View Full Code Here


  @Test
  public void testModifyUserRemoveAlbum() throws Exception
  {
    //Setup
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    user.addToAlbums(album);
    em.persist(user);
   
    em.flush();
    em.clear();
   
    //Execute
    user.removeFromAlbums(album);
    user = repository.modify(user);
    em.flush();
    em.clear();
   
    //Verify
    User actualUser = em.find(User.class, TEST_USER_ID);
    assertEquals(user, actualUser);
    assertFalse(actualUser.getAlbums().contains(album));
  }
View Full Code Here

  @Test
  public void testModifyUserRemoveAlbumWithPhoto() throws Exception
  {
    //Setup
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    user.addToAlbums(album);
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
      }
    }
    em.persist(user);
    long albumId = album.getAlbumId();
    long photoId = photo.getPhotoId();
   
    em.flush();
    em.clear();
   
    //Execute
    user.removeFromAlbums(album);
    user = repository.modify(user);
    em.flush();
    em.clear();
   
    //Verify
    User actualUser = em.find(User.class, TEST_USER_ID);
    Album actualAlbum =  em.find(Album.class, albumId);
    Photo actualPhoto =  em.find(Photo.class, photoId);
    assertEquals(user, actualUser);
    assertFalse(actualUser.getAlbums().contains(album));
    assertNull(actualAlbum);
    assertNull(actualPhoto);
  }
View Full Code Here

 
  @Test
  public void testModifyUserAddPhoto() throws Exception
  {
    //Setup
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    user.addToAlbums(album);
    em.persist(user);
   
    em.flush();
    em.clear();
   
    //Execute
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
      }
    }
    user = repository.modify(user);
    em.flush();
    em.clear();
   
    //Verify
    User actualUser = em.find(User.class, TEST_USER_ID);
    assertEquals(user, actualUser);
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
View Full Code Here

 
  @Test
  public void testModifyUserModifyPhoto() throws Exception
  {
    //Setup
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    user.addToAlbums(album);
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
      }
    }
    em.persist(user);
   
    em.flush();
    em.clear();
   
    //Execute
    String modifiedTitle = "Modified Photo Title";
    for(Album anAlbum: user.getAlbums())
    {
      for(Photo aPhoto: anAlbum.getPhotos())
      {
        aPhoto.setTitle(modifiedTitle);
      }
    }
    user = repository.modify(user);
    em.flush();
    em.clear();
   
    //Verify
    User actualUser = em.find(User.class, TEST_USER_ID);
    assertEquals(user, actualUser);
    for(Album anAlbum: user.getAlbums())
    {
      assertTrue(anAlbum.getPhotos().contains(photo));
      for(Photo aPhoto: anAlbum.getPhotos())
View Full Code Here

 
  @Test
  public void testModifyUserRemovePhoto() throws Exception
  {
    //Setup
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    user.addToAlbums(album);
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
      }
    }
    em.persist(user);
   
    em.flush();
    em.clear();
   
    //Execute
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.removeFromPhotos(photo);
      }
    }
    user = repository.modify(user);
    em.flush();
    em.clear();
   
    //Verify
    User actualUser = em.find(User.class, TEST_USER_ID);
    assertEquals(user, actualUser);
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
View Full Code Here

 
  @Test
  public void testDeleteUser() throws Exception
  {
    //Setup
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    em.persist(user);
    em.flush();
    em.clear();
   
    //Execute
    repository.delete(user);
   
    //Verify
    em.flush();
    em.clear();
    User actualUser = em.find(User.class, TEST_USER_ID);
    assertNull(actualUser);
  }
View Full Code Here

  @Test
  public void testDeleteUserWithAlbumAndPhotos() throws Exception
  {
    //Setup
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    user.addToAlbums(album);
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
      }
    }
    em.persist(user);
    long albumId = album.getAlbumId();
    long photoId = photo.getPhotoId();
   
    em.flush();
    em.clear();
   
    //Execute
    repository.delete(user);
    em.flush();
    em.clear();
   
    //Verify
    User actualUser = em.find(User.class, TEST_USER_ID);
    Album actualAlbum =  em.find(Album.class, albumId);
    Photo actualPhoto =  em.find(Photo.class, photoId);
    assertNull(actualUser);
    assertNull(actualAlbum);
    assertNull(actualPhoto);
View Full Code Here

 
  @Test
  public void testFindUserById() throws Exception
  {
    //Setup
    User user = new User(TEST_USER_ID, TEST_PASSWORD);
    em.persist(user);
   
    em.flush();
    em.clear();
   
    //Execute
    User actualUser = repository.findById(TEST_USER_ID);
   
    //Verify
    assertEquals(user, actualUser);
  }
View Full Code Here

      return result;
    }

    try
    {
      User user = new User(signupRequest.getUserId(), signupRequest.getPassword());
      userAccountService.signupUser(user);
      String message = Messages.getString("Signup.AccountCreationSuccessMessage", locale);
      FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, message, null);
      FacesContext.getCurrentInstance().addMessage(null, facesMessage);
      result = "/Index.xhtml?faces-redirect=true";
View Full Code Here

TOP

Related Classes of info.galleria.domain.User

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.