diff --git a/UyTube_aplicacion/nbproject/project.properties b/UyTube_aplicacion/nbproject/project.properties index 1f399e5abba4a418204f873bebeb1208c916f548..4977975f1ffac44dbd757e50e32fc5b7de9f8d00 100644 --- a/UyTube_aplicacion/nbproject/project.properties +++ b/UyTube_aplicacion/nbproject/project.properties @@ -52,7 +52,8 @@ javac.classpath=\ ${file.reference.jcalendar-1.4.jar-4}:\ ${file.reference.jcalendar-1.4.jar-5}:\ ${libs.PostgreSQLDriver.classpath}:\ - ${libs.eclipselink.classpath} + ${libs.eclipselink.classpath}:\ + ${libs.Logica.classpath} <<<<<<< HEAD:\ ${file.reference.jcalendar-1.4.jar-1} ${file.reference.jcalendar-1.4.jar}:\ diff --git a/UyTube_aplicacion/src/JPAControllerClasses/AdministradorJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/AdministradorJpaController.java deleted file mode 100644 index 77038026ebf61756e3924d6b1ba82ee648b52a53..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/AdministradorJpaController.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import JPAControllerClasses.exceptions.PreexistingEntityException; -import Logica.Clases.Administrador; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class AdministradorJpaController implements Serializable { - - public AdministradorJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public AdministradorJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(Administrador administrador) throws PreexistingEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(administrador); - em.getTransaction().commit(); - } catch (Exception ex) { - if (findAdministrador(administrador.getId()) != null) { - throw new PreexistingEntityException("Administrador " + administrador + " already exists.", ex); - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(Administrador administrador) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - administrador = em.merge(administrador); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - int id = administrador.getId(); - if (findAdministrador(id) == null) { - throw new NonexistentEntityException("The administrador with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(int id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - Administrador administrador; - try { - administrador = em.getReference(Administrador.class, id); - administrador.getId(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The administrador with id " + id + " no longer exists.", enfe); - } - em.remove(administrador); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<Administrador> findAdministradorEntities() { - return findAdministradorEntities(true, -1, -1); - } - - public List<Administrador> findAdministradorEntities(int maxResults, int firstResult) { - return findAdministradorEntities(false, maxResults, firstResult); - } - - private List<Administrador> findAdministradorEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - cq.select(cq.from(Administrador.class)); - Query q = em.createQuery(cq); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public Administrador findAdministrador(int id) { - EntityManager em = getEntityManager(); - try { - return em.find(Administrador.class, id); - } finally { - em.close(); - } - } - - public int getAdministradorCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<Administrador> rt = cq.from(Administrador.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/BusquedaEnBDD.java b/UyTube_aplicacion/src/JPAControllerClasses/BusquedaEnBDD.java deleted file mode 100644 index 1e495779a639087aa5618de4fc1b09e8fd6c300b..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/BusquedaEnBDD.java +++ /dev/null @@ -1,322 +0,0 @@ -package JPAControllerClasses; - -import Logica.Clases.Canal; -import Logica.Clases.ListaDeReproduccion; -import Logica.Clases.ListaDeReproduccion_; -import Logica.Clases.Usuario; -import Logica.Clases.Video; -import Logica.DataType.DtVideo; -import Logica.Enumerados.Filtrado; -import Logica.Enumerados.Ordenacion; -import Logica.Enumerados.TipoListaDeReproduccion; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.Persistence; - -public class BusquedaEnBDD implements Serializable { - private EntityManagerFactory emf = null; - - public BusquedaEnBDD() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public BusquedaEnBDD(EntityManagerFactory emf) { - this.emf = emf; - } - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - /** - * Busca contenido por coincidencia de texto en nombre o descripcion de los - * contenidos del sistema En el resultado se incluirán (si corresponde segun - * el filtrado) los videos privados del usuarioActual - * - * @param busqueda Texto a buscar (si es vacÃo incluye todo el contenido) - * @param filtro Tipo de contenido en el cual se realizará la búsqueda - * @param orden Manera de ordenar el resultado de la búsqueda - * @return Resultado de la busqueda. Puede contener DtVideo, - * DtListaDeReproduccion y/o DtCanal. (para usar los elementos devueltos hay - * que castearlos) - */ - public ArrayList<Object> buscar(String busqueda, Filtrado filtro, Ordenacion orden){ - EntityManager em = getEntityManager(); - List<Object> ret = new ArrayList(); - if (busqueda == null || busqueda.equals("")) { - }else{ - busqueda = "%" + busqueda + "%"; - } - try { - Query q; - // Segun la opcion de filtrado, se obtienen los contenidos que contengan el texto a buscar - // Busca los Canales - if (filtro == Filtrado.TODO || filtro == Filtrado.CANALES){ - if (busqueda == null || busqueda.equals("")){ - q = em.createQuery("SELECT e FROM Canal e WHERE NOT e.eliminado"); - }else{ - q = em.createQuery("SELECT e FROM Canal e WHERE (UPPER(e.nombre)) LIKE (UPPER(?1)) OR (UPPER(e.descripcion)) LIKE (UPPER(?1)) AND NOT e.eliminado"); - q.setParameter(1, busqueda); - } - ret.addAll(q.getResultList()); - } - // Busca los Listas de reproduccion - if (filtro == Filtrado.TODO || filtro == Filtrado.LISTAS_DE_REPRODUCCION){ - if (busqueda == null || busqueda.equals("")){ - q = em.createQuery("SELECT e FROM ListaDeReproduccion e WHERE e.tipo = ? AND NOT e.eliminado"); - q.setParameter(1, TipoListaDeReproduccion.PARTICULAR); - }else{ - q = em.createQuery("SELECT e FROM ListaDeReproduccion e WHERE e.tipo = ?1 AND (UPPER(e.nombre)) LIKE (UPPER(?2)) AND NOT e.eliminado"); - q.setParameter(1, TipoListaDeReproduccion.PARTICULAR); - q.setParameter(2, busqueda); - } - ret.addAll(q.getResultList()); - } - // Busca los Videos - if (filtro == Filtrado.TODO || filtro == Filtrado.VIDEOS){ - if (busqueda == null || busqueda.equals("")){ - q = em.createQuery("SELECT e FROM Video e WHERE NOT e.eliminado"); - }else{ - q = em.createQuery("SELECT e FROM Video e WHERE (UPPER(e.nombre)) LIKE (UPPER(?1)) OR (UPPER(e.descripcion)) LIKE (UPPER(?1)) AND NOT e.eliminado"); - q.setParameter(1, busqueda); - } - ret.addAll(q.getResultList()); - } - - // En este punto ret contiene todos los contenidos que contienen la busqueda en su nombre o descripcion - ArrayList<ParDeObjetos> pares = null; - ArrayList<ParDeObjetos> paresOrdenados; - // Asocia los elementos a su nombre o su fecha (segun como se desee ordenar) - switch (orden){ - case ALFABETICA_ASCENDENTE: - pares = nombrarElementos((ArrayList<Object>) ret); - break; - case FECHA_DESCENDENTE: - pares = fecharElementos((ArrayList<Object>) ret); - break; - } - - // Leido de adentro hacia afuera: - // se ordena por fecha - // Se desarma el par de objetos - // se convierte cada objeto a su DataType - // retorna el resultado - return convertirClaseADatatype( - ParDeObjetos.extraerElementos( - ordenar(pares) - ) - ); - } finally { - em.close(); - } - } - - /** - * Devuelve un listado de Video y ListaDeReproduccion que pertenezcan ala - * categoria indicada, ordenado por fecha de actividasd reciente - * @param cat Categoria a buscar - * @return Lista ordenada Video y ListaDeReproduccion - */ - public ArrayList<Object> buscarPorCategoria(String cat) { - EntityManager em = getEntityManager(); - List<Object> ret = new ArrayList(); - try { - Query q; - // Obtiene los videos en esa categoria - q = em.createQuery("SELECT e FROM Video e WHERE e.categoria = ?1 AND NOT e.eliminado"); - q.setParameter(1, cat); - ret.addAll(q.getResultList()); - // obtiene las listas de reproduccion en esa categoria - q = em.createQuery("SELECT e FROM ListaDeReproduccion e WHERE e.categoria = ?1 AND NOT e.eliminado"); - q.setParameter(1, cat); - ret.addAll(q.getResultList()); - - // Leido de adentro hacia afuera: - // Asocia los elementos a una fecha - // se ordena por fecha - // Se desarma el par de objetos - // se convierte cada objeto a su DataType - // retorna el resultado - return convertirClaseADatatype( - ParDeObjetos.extraerElementos( - ordenar( - fecharElementos( - (ArrayList<Object>) ret - ) - ) - ) - ); - } finally { - em.close(); - } - } - - /** - * Asocia los objetos recibidos a una fecha - * Canal se asocia a la fecha del video mas reciente - * Video a su propia fecha - * ListaDeReproduccion fecha del video con fecha mas reciente - * @param lista Lista de objetos a ordenar (Canal, Video o ListaDeReproduccion) - * @return Lista de los objetos recibidos pero asociados a una fecha - */ - public ArrayList<ParDeObjetos> fecharElementos(ArrayList<Object> lista){ - ArrayList<ParDeObjetos> ret = new ArrayList(); - // Asocia cada elemento del array recibido con su fecha - for (Object o : lista){ - ret.add(new ParDeObjetos(o, ultimaActividad(o))); - } - return ret; - } - - /** - * Asocia los objetos recibidos a una fecha - * Canal se asocia a la fecha del video mas reciente - * Video a su propia fecha - * ListaDeReproduccion fecha del video con fecha mas reciente - * @param lista Lista de objetos a ordenar (Canal, Video o ListaDeReproduccion) - * @return Lista de los objetos recibidos pero asociados a una fecha - */ - public ArrayList<ParDeObjetos> nombrarElementos(ArrayList<Object> lista){ - ArrayList<ParDeObjetos> ret = new ArrayList(); - // Asocia cada elemento del array recibido con su nombre - for (Object o : lista){ - ret.add(new ParDeObjetos(o, nombreParaOrdenar(o))); - } - return ret; - } - - /** - * Devuelve el nombre del objeto - * Canal su nombre - * Video su nombre - * ListaDeReproduccion su nombre - * @param o Objeto a dar nombre - * @return Nombre del objeto - */ - private String nombreParaOrdenar(Object o){ - java.sql.Date ret = null; - // Devuelve el nombre del objeto - if (o instanceof Canal){ - return ((Canal) o).getNombre(); - }else if (o instanceof ListaDeReproduccion){ - return ((ListaDeReproduccion) o).getNombre(); - }else if (o instanceof Video){ - return ((Video) o).getNombre(); - } - return ""; - } - - /** - * Devuelve la fecha de la ultima actividad del objeto - * Canal es la fecha del video mas reciente - * Video su propia fecha - * ListaDeReproduccion la fecha del video con fecha mas reciente - * @param o - * @return - */ - private java.sql.Date ultimaActividad(Object o){ - // Por si no se pude determinar la fecha, inicializo con una fecha bien vieja - java.sql.Date ret = new java.sql.Date(-1900, 0, 1); - // mas viejo que eso solo puede ser algun video de Mirta Legrant, y no creo que ella use UyTube... - - if (o instanceof Canal){ - // si el objeto es un Canal - // busca la fecha de publicacion mas reciente entre los videos del canal - ArrayList<DtVideo> videos = ((Canal) o).listarVideos(); - for (DtVideo dtv : videos){ - if (ret == null || dtv.getFechaPublicacion().compareTo(ret) > 0){ - ret = dtv.getFechaPublicacion(); - } - } - }else if (o instanceof ListaDeReproduccion){ - // si el objeto es una ListaDeReproduccion - // busca la fecha de publicacion mas reciente entre los videos de la lista - ArrayList<DtVideo> videos = ((ListaDeReproduccion) o).listarVideos(); - for (DtVideo dtv : videos){ - if (ret == null || dtv.getFechaPublicacion().compareTo(ret) > 0){ - ret = dtv.getFechaPublicacion(); - } - } - }else if (o instanceof Video){ - // si el objeto es un Video - // Devuelve su fecha - ret = ((Video) o).getFechaPublicacion(); - } - return ret; - } - - /** - * Ordena la lista de pares recibida - * @param lista Lista a ordenar - * @return Lista ordenada - */ - public ArrayList<ParDeObjetos> ordenar(ArrayList<ParDeObjetos> lista){ - // Caso base, no hay lista o es vacia - if (lista == null || lista.isEmpty()){ - return new ArrayList(); - } - - // Extrae el primer elemento de la lista - ParDeObjetos par = lista.remove(0); - // llama a la recursividad - ArrayList<ParDeObjetos> listaOrdenada = ordenar(lista); - - // Recore la lista ya ordenada por la llamada recursiva - // compara cada elemento y para cuando encuentra su lugar - int i = 0; - for (; i < listaOrdenada.size(); i++){ - ParDeObjetos p = listaOrdenada.get(i); - if (comparar(p, par) < 0){ - break; - } - } - // Agrega el elemento al resultado - listaOrdenada.add(i, par); - return listaOrdenada; - } - - /** - * Compara dos pares de objetos - * Se soportan String o java.sql.Date - * @param a Primer par a comparar - * @param b Segundo par a comparar - * @return 0 si (a == b), -1 si (a < b), 1 si (a > b) - */ - private int comparar(ParDeObjetos a, ParDeObjetos b){ - // Realiza la comparacion dependiendo del tipo de objeto para comparar - if (a.getOrderField() instanceof String){ - String str1 = (String) a.getOrderField(); - String str2 = (String) b.getOrderField(); - return (str1.compareToIgnoreCase(str2)) * -1; - }else if (a.getOrderField() instanceof java.sql.Date){ - java.sql.Date date1 = (java.sql.Date) a.getOrderField(); - java.sql.Date date2 = (java.sql.Date) b.getOrderField(); - return date1.compareTo(date2); - } - return 0; - } - - /** - * Reemplaza los objetos de la lista por sus DataType - * @param lst Lista con clases Canal, ListaDeReproduccion o Video - * @return Lista de DtCanal, DtListaDeReproduccion o DtVideo - */ - private ArrayList<Object> convertirClaseADatatype(ArrayList<Object> lst){ - Object o; - // Recorre todo el array - for (int i = 0; i < lst.size(); i++) { - o = lst.get(i); - // Castea el objeto para llamar a la funcion .getDT() - if (o instanceof Canal) { - lst.set(i, ((Canal)o).getDT()); - } else if (o instanceof ListaDeReproduccion) { - lst.set(i, ((ListaDeReproduccion)o).getDt()); - } else if (o instanceof Video) { - lst.set(i, ((Video)o).getDt()); - } - } - return lst; - } -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/CanalJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/CanalJpaController.java deleted file mode 100644 index 1876ea644572e94b1be194c49e2bc79e5a47b792..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/CanalJpaController.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import Logica.Clases.Canal; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class CanalJpaController implements Serializable { - - public CanalJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public CanalJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(Canal canal) { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(canal); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(Canal canal) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - canal = em.merge(canal); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - int id = canal.getId(); - if (findCanal(id) == null) { - throw new NonexistentEntityException("The canal with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(int id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - Canal canal; - try { - canal = em.getReference(Canal.class, id); - canal.getId(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The canal with id " + id + " no longer exists.", enfe); - } - em.remove(canal); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<Canal> findCanalEntities() { - return findCanalEntities(true, -1, -1); - } - - public List<Canal> findCanalEntities(int maxResults, int firstResult) { - return findCanalEntities(false, maxResults, firstResult); - } - - private List<Canal> findCanalEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - cq.select(cq.from(Canal.class)); - Query q = em.createQuery(cq); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public Canal findCanal(int id) { - EntityManager em = getEntityManager(); - try { - return em.find(Canal.class, id); - } finally { - em.close(); - } - } - - public int getCanalCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<Canal> rt = cq.from(Canal.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/CategoriaJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/CategoriaJpaController.java deleted file mode 100644 index 3893b56833e851cbcf049db915afe35182941a94..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/CategoriaJpaController.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import JPAControllerClasses.exceptions.PreexistingEntityException; -import Logica.Clases.Categoria; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class CategoriaJpaController implements Serializable { - - public CategoriaJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public CategoriaJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(Categoria categoria) throws PreexistingEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(categoria); - em.getTransaction().commit(); - } catch (Exception ex) { - if (findCategoria(categoria.getNombre()) != null) { - throw new PreexistingEntityException("Categoria " + categoria + " already exists.", ex); - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(Categoria categoria) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - categoria = em.merge(categoria); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - String id = categoria.getNombre(); - if (findCategoria(id) == null) { - throw new NonexistentEntityException("The categoria with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(String id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - Categoria categoria; - try { - categoria = em.getReference(Categoria.class, id); - categoria.getNombre(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The categoria with id " + id + " no longer exists.", enfe); - } - em.remove(categoria); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<Categoria> findCategoriaEntities() { - return findCategoriaEntities(true, -1, -1); - } - - public List<Categoria> findCategoriaEntities(int maxResults, int firstResult) { - return findCategoriaEntities(false, maxResults, firstResult); - } - - private List<Categoria> findCategoriaEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - cq.select(cq.from(Categoria.class)); - Query q = em.createQuery(cq); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public Categoria findCategoria(String id) { - EntityManager em = getEntityManager(); - try { - return em.find(Categoria.class, id); - } finally { - em.close(); - } - } - - public int getCategoriaCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<Categoria> rt = cq.from(Categoria.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/ComentarioJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/ComentarioJpaController.java deleted file mode 100644 index ca7ea2c884cda73e13fd6fb3df470da3de44086c..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/ComentarioJpaController.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import Logica.Clases.Comentario; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class ComentarioJpaController implements Serializable { - - public ComentarioJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public ComentarioJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(Comentario comentario) { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(comentario); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(Comentario comentario) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - comentario = em.merge(comentario); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - int id = comentario.getId(); - if (findComentario(id) == null) { - throw new NonexistentEntityException("The comentario with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(int id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - Comentario comentario; - try { - comentario = em.getReference(Comentario.class, id); - comentario.getId(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The comentario with id " + id + " no longer exists.", enfe); - } - em.remove(comentario); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<Comentario> findComentarioEntities() { - return findComentarioEntities(true, -1, -1); - } - - public List<Comentario> findComentarioEntities(int maxResults, int firstResult) { - return findComentarioEntities(false, maxResults, firstResult); - } - - private List<Comentario> findComentarioEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - cq.select(cq.from(Comentario.class)); - Query q = em.createQuery(cq); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public Comentario findComentario(int id) { - EntityManager em = getEntityManager(); - try { - return em.find(Comentario.class, id); - } finally { - em.close(); - } - } - - public int getComentarioCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<Comentario> rt = cq.from(Comentario.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/ListaDeReproduccionJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/ListaDeReproduccionJpaController.java deleted file mode 100644 index 6b625cd6096408a827c471699c2fc6558d3a5a4d..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/ListaDeReproduccionJpaController.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import Logica.Clases.ListaDeReproduccion; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class ListaDeReproduccionJpaController implements Serializable { - - public ListaDeReproduccionJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public ListaDeReproduccionJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(ListaDeReproduccion listaDeReproduccion) { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(listaDeReproduccion); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(ListaDeReproduccion listaDeReproduccion) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - listaDeReproduccion = em.merge(listaDeReproduccion); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - int id = listaDeReproduccion.getId(); - if (findListaDeReproduccion(id) == null) { - throw new NonexistentEntityException("The listaDeReproduccion with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(int id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - ListaDeReproduccion listaDeReproduccion; - try { - listaDeReproduccion = em.getReference(ListaDeReproduccion.class, id); - listaDeReproduccion.getId(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The listaDeReproduccion with id " + id + " no longer exists.", enfe); - } - em.remove(listaDeReproduccion); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<ListaDeReproduccion> findListaDeReproduccionEntities() { - return findListaDeReproduccionEntities(true, -1, -1); - } - - public List<ListaDeReproduccion> findListaDeReproduccionEntities(int maxResults, int firstResult) { - return findListaDeReproduccionEntities(false, maxResults, firstResult); - } - - private List<ListaDeReproduccion> findListaDeReproduccionEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - cq.select(cq.from(ListaDeReproduccion.class)); - Query q = em.createQuery(cq); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public ListaDeReproduccion findListaDeReproduccion(int id) { - EntityManager em = getEntityManager(); - try { - return em.find(ListaDeReproduccion.class, id); - } finally { - em.close(); - } - } - - public int getListaDeReproduccionCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<ListaDeReproduccion> rt = cq.from(ListaDeReproduccion.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/ListaPorDefectoJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/ListaPorDefectoJpaController.java deleted file mode 100644 index 9e2d0ed59291eda457190eaa740a39475c1531c9..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/ListaPorDefectoJpaController.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import JPAControllerClasses.exceptions.PreexistingEntityException; -import Logica.Clases.ListaPorDefecto; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class ListaPorDefectoJpaController implements Serializable { - - public ListaPorDefectoJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public ListaPorDefectoJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(ListaPorDefecto listaPorDefecto) throws PreexistingEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(listaPorDefecto); - em.getTransaction().commit(); - } catch (Exception ex) { - if (findListaPorDefecto(listaPorDefecto.getNombre()) != null) { - throw new PreexistingEntityException("ListaPorDefecto " + listaPorDefecto + " already exists.", ex); - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(ListaPorDefecto listaPorDefecto) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - listaPorDefecto = em.merge(listaPorDefecto); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - String id = listaPorDefecto.getNombre(); - if (findListaPorDefecto(id) == null) { - throw new NonexistentEntityException("The listaPorDefecto with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(String id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - ListaPorDefecto listaPorDefecto; - try { - listaPorDefecto = em.getReference(ListaPorDefecto.class, id); - listaPorDefecto.getNombre(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The listaPorDefecto with id " + id + " no longer exists.", enfe); - } - em.remove(listaPorDefecto); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<ListaPorDefecto> findListaPorDefectoEntities() { - return findListaPorDefectoEntities(true, -1, -1); - } - - public List<ListaPorDefecto> findListaPorDefectoEntities(int maxResults, int firstResult) { - return findListaPorDefectoEntities(false, maxResults, firstResult); - } - - private List<ListaPorDefecto> findListaPorDefectoEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - cq.select(cq.from(ListaPorDefecto.class)); - Query q = em.createQuery(cq); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public ListaPorDefecto findListaPorDefecto(String id) { - EntityManager em = getEntityManager(); - try { - return em.find(ListaPorDefecto.class, id); - } finally { - em.close(); - } - } - - public int getListaPorDefectoCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<ListaPorDefecto> rt = cq.from(ListaPorDefecto.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/NombreManejador.java b/UyTube_aplicacion/src/JPAControllerClasses/NombreManejador.java deleted file mode 100644 index 8a046140c974c191f5ad455aaffcff4b6c8886d8..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/NombreManejador.java +++ /dev/null @@ -1,9 +0,0 @@ -package JPAControllerClasses; - -public class NombreManejador { - private static String nombreManejador = "UyTubePU"; - - public static String getNombreManejador(){ - return nombreManejador; - } -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/ParDeObjetos.java b/UyTube_aplicacion/src/JPAControllerClasses/ParDeObjetos.java deleted file mode 100644 index 8c38f83397175f66b759940cfe327f8138c1ebbf..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/ParDeObjetos.java +++ /dev/null @@ -1,40 +0,0 @@ -package JPAControllerClasses; - -import java.util.ArrayList; - -public class ParDeObjetos { - private Object element; - private Object orderField; - - public ParDeObjetos(Object element, Object orderField) { - this.element = element; - this.orderField = orderField; - } - - public Object getElement() { - return element; - } - - public void setElement(Object element) { - this.element = element; - } - - public Object getOrderField() { - return orderField; - } - - public void setOrderField(Object orderField) { - this.orderField = orderField; - } - - - public static ArrayList<Object> extraerElementos(ArrayList<ParDeObjetos> lista){ - ArrayList<Object> ret = new ArrayList(); - for (ParDeObjetos par : lista){ - ret.add(par.getElement()); - } - return ret; - } - - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/PersonaJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/PersonaJpaController.java deleted file mode 100644 index 764949584a6733d6811f56630b621746c26b2cee..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/PersonaJpaController.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import JPAControllerClasses.exceptions.PreexistingEntityException; -import Logica.Clases.Persona; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class PersonaJpaController implements Serializable { - - public PersonaJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public PersonaJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(Persona persona) throws PreexistingEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(persona); - em.getTransaction().commit(); - } catch (Exception ex) { - if (findPersona(persona.getId()) != null) { - throw new PreexistingEntityException("Persona " + persona + " already exists.", ex); - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(Persona persona) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - persona = em.merge(persona); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - int id = persona.getId(); - if (findPersona(id) == null) { - throw new NonexistentEntityException("The persona with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(int id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - Persona persona; - try { - persona = em.getReference(Persona.class, id); - persona.getId(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The persona with id " + id + " no longer exists.", enfe); - } - em.remove(persona); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<Persona> findPersonaEntities() { - return findPersonaEntities(true, -1, -1); - } - - public List<Persona> findPersonaEntities(int maxResults, int firstResult) { - return findPersonaEntities(false, maxResults, firstResult); - } - - private List<Persona> findPersonaEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - cq.select(cq.from(Persona.class)); - Query q = em.createQuery(cq); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public Persona findPersona(int id) { - EntityManager em = getEntityManager(); - try { - return em.find(Persona.class, id); - } finally { - em.close(); - } - } - - public int getPersonaCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<Persona> rt = cq.from(Persona.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/UsuarioJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/UsuarioJpaController.java deleted file mode 100644 index 87a42ad7d2b14a123c5eaf3c4ac1128082bbc606..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/UsuarioJpaController.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import JPAControllerClasses.exceptions.PreexistingEntityException; -import Logica.Clases.Usuario; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class UsuarioJpaController implements Serializable { - - public UsuarioJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public UsuarioJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(Usuario usuario) throws PreexistingEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(usuario); - em.getTransaction().commit(); - } catch (Exception ex) { - if (findUsuario(usuario.getNickname()) != null) { - throw new PreexistingEntityException("Usuario " + usuario + " already exists.", ex); - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(Usuario usuario) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - usuario = em.merge(usuario); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - String id = usuario.getNickname(); - if (findUsuario(id) == null) { - throw new NonexistentEntityException("The usuario with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(String id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - Usuario usuario; - try { - usuario = em.getReference(Usuario.class, id); - usuario.getNickname(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The usuario with id " + id + " no longer exists.", enfe); - } - em.remove(usuario); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<Usuario> findUsuarioEntities() { - return findUsuarioEntities(true, -1, -1); - } - - public List<Usuario> findUsuarioEntities(int maxResults, int firstResult) { - return findUsuarioEntities(false, maxResults, firstResult); - } - - private List<Usuario> findUsuarioEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - Query q = em.createQuery("SELECT u FROM Usuario u WHERE u.eliminado = ?1"); - q.setParameter(1, false); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public List<Usuario> findUsuarioEliminadoEntities() { - EntityManager em = getEntityManager(); - try { - Query q = em.createQuery("SELECT u FROM Usuario u WHERE u.eliminado = ?1"); - q.setParameter(1, true); - List<Usuario> usuarios = (List<Usuario>) q.getResultList(); - return usuarios; - } finally { - em.close(); - } - } - - public Usuario findUsuario(String id) { - EntityManager em = getEntityManager(); - try { - return em.find(Usuario.class, id); - } finally { - em.close(); - } - } - - public int getUsuarioCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<Usuario> rt = cq.from(Usuario.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/ValoracionJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/ValoracionJpaController.java deleted file mode 100644 index 2c4e68764319b25bc23ed03b5021bb5b647f8139..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/ValoracionJpaController.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import Logica.Clases.Valoracion; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class ValoracionJpaController implements Serializable { - - public ValoracionJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - public ValoracionJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(Valoracion valoracion) { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(valoracion); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(Valoracion valoracion) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - valoracion = em.merge(valoracion); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - int id = valoracion.getId(); - if (findValoracion(id) == null) { - throw new NonexistentEntityException("The valoracion with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(int id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - Valoracion valoracion; - try { - valoracion = em.getReference(Valoracion.class, id); - valoracion.getId(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The valoracion with id " + id + " no longer exists.", enfe); - } - em.remove(valoracion); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<Valoracion> findValoracionEntities() { - return findValoracionEntities(true, -1, -1); - } - - public List<Valoracion> findValoracionEntities(int maxResults, int firstResult) { - return findValoracionEntities(false, maxResults, firstResult); - } - - private List<Valoracion> findValoracionEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - cq.select(cq.from(Valoracion.class)); - Query q = em.createQuery(cq); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public Valoracion findValoracion(int id) { - EntityManager em = getEntityManager(); - try { - return em.find(Valoracion.class, id); - } finally { - em.close(); - } - } - - public int getValoracionCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<Valoracion> rt = cq.from(Valoracion.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/VideoJpaController.java b/UyTube_aplicacion/src/JPAControllerClasses/VideoJpaController.java deleted file mode 100644 index b56d22ac9e42d22cfcdc55d220f97a2b2d9eac7b..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/VideoJpaController.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package JPAControllerClasses; - -import JPAControllerClasses.exceptions.NonexistentEntityException; -import Logica.Clases.Video; -import java.io.Serializable; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Query; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -/** - * - * @author Juan - */ -public class VideoJpaController implements Serializable { - - public VideoJpaController() { - this.emf = Persistence.createEntityManagerFactory(NombreManejador.getNombreManejador()); - } - - public VideoJpaController(EntityManagerFactory emf) { - this.emf = emf; - } - private EntityManagerFactory emf = null; - - public EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public void create(Video video) { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - em.persist(video); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public void edit(Video video) throws NonexistentEntityException, Exception { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - video = em.merge(video); - em.getTransaction().commit(); - } catch (Exception ex) { - String msg = ex.getLocalizedMessage(); - if (msg == null || msg.length() == 0) { - int id = video.getId(); - if (findVideo(id) == null) { - throw new NonexistentEntityException("The video with id " + id + " no longer exists."); - } - } - throw ex; - } finally { - if (em != null) { - em.close(); - } - } - } - - public void destroy(int id) throws NonexistentEntityException { - EntityManager em = null; - try { - em = getEntityManager(); - em.getTransaction().begin(); - Video video; - try { - video = em.getReference(Video.class, id); - video.getId(); - } catch (EntityNotFoundException enfe) { - throw new NonexistentEntityException("The video with id " + id + " no longer exists.", enfe); - } - em.remove(video); - em.getTransaction().commit(); - } finally { - if (em != null) { - em.close(); - } - } - } - - public List<Video> findVideoEntities() { - return findVideoEntities(true, -1, -1); - } - - public List<Video> findVideoEntities(int maxResults, int firstResult) { - return findVideoEntities(false, maxResults, firstResult); - } - - private List<Video> findVideoEntities(boolean all, int maxResults, int firstResult) { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - cq.select(cq.from(Video.class)); - Query q = em.createQuery(cq); - if (!all) { - q.setMaxResults(maxResults); - q.setFirstResult(firstResult); - } - return q.getResultList(); - } finally { - em.close(); - } - } - - public Video findVideo(int id) { - EntityManager em = getEntityManager(); - try { - return em.find(Video.class, id); - } finally { - em.close(); - } - } - - public int getVideoCount() { - EntityManager em = getEntityManager(); - try { - CriteriaQuery cq = em.getCriteriaBuilder().createQuery(); - Root<Video> rt = cq.from(Video.class); - cq.select(em.getCriteriaBuilder().count(rt)); - Query q = em.createQuery(cq); - return ((Long) q.getSingleResult()).intValue(); - } finally { - em.close(); - } - } - -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/exceptions/IllegalOrphanException.java b/UyTube_aplicacion/src/JPAControllerClasses/exceptions/IllegalOrphanException.java deleted file mode 100644 index 3b58e834bf2dfe2e42918d7e8c27a4604af9878c..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/exceptions/IllegalOrphanException.java +++ /dev/null @@ -1,20 +0,0 @@ -package JPAControllerClasses.exceptions; - -import java.util.ArrayList; -import java.util.List; - -public class IllegalOrphanException extends Exception { - private List<String> messages; - public IllegalOrphanException(List<String> messages) { - super((messages != null && messages.size() > 0 ? messages.get(0) : null)); - if (messages == null) { - this.messages = new ArrayList<String>(); - } - else { - this.messages = messages; - } - } - public List<String> getMessages() { - return messages; - } -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/exceptions/NonexistentEntityException.java b/UyTube_aplicacion/src/JPAControllerClasses/exceptions/NonexistentEntityException.java deleted file mode 100644 index 4722e104e36b54ab9c5c491d14a60405b1d906df..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/exceptions/NonexistentEntityException.java +++ /dev/null @@ -1,10 +0,0 @@ -package JPAControllerClasses.exceptions; - -public class NonexistentEntityException extends Exception { - public NonexistentEntityException(String message, Throwable cause) { - super(message, cause); - } - public NonexistentEntityException(String message) { - super(message); - } -} diff --git a/UyTube_aplicacion/src/JPAControllerClasses/exceptions/PreexistingEntityException.java b/UyTube_aplicacion/src/JPAControllerClasses/exceptions/PreexistingEntityException.java deleted file mode 100644 index 6e3acce872661df58e32b20d9b8b92e4a474d00b..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/JPAControllerClasses/exceptions/PreexistingEntityException.java +++ /dev/null @@ -1,10 +0,0 @@ -package JPAControllerClasses.exceptions; - -public class PreexistingEntityException extends Exception { - public PreexistingEntityException(String message, Throwable cause) { - super(message, cause); - } - public PreexistingEntityException(String message) { - super(message); - } -} diff --git a/UyTube_aplicacion/src/Logica/Clases/Administrador.java b/UyTube_aplicacion/src/Logica/Clases/Administrador.java deleted file mode 100644 index 373b88d46f222de027143277825511fdde8766c7..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/Administrador.java +++ /dev/null @@ -1,33 +0,0 @@ -package Logica.Clases; - -import java.io.Serializable; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name="administrador") -public class Administrador extends Persona implements Serializable{ - - @Id - // No logre hacer que el id fuera auto-incremental, no se por que, probe de todo y no pude - //@GeneratedValue(strategy=GenerationType.IDENTITY) - //@Column(name = "id") - private Integer id; - - //------------------------------------------------------------------------- - - public Administrador() { - super(); - } - - public Administrador(int id, String contrasenia, String nombre, String apellido){ - super(nombre,apellido,contrasenia); - this.id = id; - } - - public int getIdAdmin() { - return id; - } - -} diff --git a/UyTube_aplicacion/src/Logica/Clases/Canal.java b/UyTube_aplicacion/src/Logica/Clases/Canal.java deleted file mode 100644 index ebd5294e66df60b9b5c83afd43fa37d859e629d5..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/Canal.java +++ /dev/null @@ -1,540 +0,0 @@ -package Logica.Clases; - -import JPAControllerClasses.ListaDeReproduccionJpaController; -import JPAControllerClasses.VideoJpaController; -import Logica.Enumerados.Privacidad; -import Logica.DataType.DtComentario; -import Logica.DataType.DtListaDeReproduccion; -import Logica.DataType.DtValoracion; -import Logica.DataType.DtVideo; -import Logica.DataType.DtCanal; -import Logica.Enumerados.TipoListaDeReproduccion; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Map; -import java.util.TreeMap; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.MapKey; -import javax.persistence.OneToMany; -import javax.persistence.Table; - -@Entity -@Table(name = "canal") -public class Canal implements Serializable { - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - @Column(name = "nombre") - private String nombre; - - @Column(name = "descripcion") - private String descripcion; - - @Enumerated(EnumType.STRING) - @Column(name = "privacidad") - private Privacidad privacidad; - - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumn(name = "id_canal") - @MapKey(name = "id") - private Map<Integer, ListaDeReproduccion> misListas; - - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumn(name = "id_canal") - @MapKey(name = "id") - private Map<Integer, Video> misVideos; - - @Column(name = "eliminado") - private boolean eliminado; - - //------------------------------------------------------------------------------------- - public Canal() { - } - - public Canal(int id, String nombre, String descripcion, Privacidad privacidad) { - if (nombre.equals("")){ - throw new RuntimeException("El nombre del canal no puede ser vacio"); - } - - this.id = id; - this.nombre = nombre; - this.descripcion = descripcion; - this.privacidad = privacidad; - this.misListas = new TreeMap(); - this.misVideos = new TreeMap(); - this.eliminado = false; - } - - public int getId() { - return id; - } - - public String getNombre() { - return nombre; - } - - public String getDescripcion() { - return descripcion; - } - - public Privacidad getPrivacidad() { - return privacidad; - } - - public void setNombre(String nombre) { - if (nombre.equals("")) { - throw new RuntimeException("El nombre del canal no puede ser vacio"); - } - this.nombre = nombre; - } - - public void setDescripcion(String descripcion) { - this.descripcion = descripcion; - } - - public void setPrivacidad(Privacidad privacidad) { - // Si el canal es publico y se va a cambiar a privado, se deben cambiar a privado todos los videos del canal - if (privacidad == Privacidad.PRIVADO){ - for (Map.Entry<Integer, Video> m : misVideos.entrySet()) { - m.getValue().setPrivacidad(Privacidad.PRIVADO); - } - for (Map.Entry<Integer, ListaDeReproduccion> m : misListas.entrySet()) { - m.getValue().setPrivacidad(Privacidad.PRIVADO); - } - } - this.privacidad = privacidad; - } - - - public void eliminar(){ - this.eliminado = true; - // elimina logicamente cada lista de reproduccion del canal - for (Map.Entry<Integer, ListaDeReproduccion> it : this.misListas.entrySet()){ - it.getValue().eliminar(); - try { - new ListaDeReproduccionJpaController().edit(it.getValue()); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - // elimina logicamente cada video del canal - // en el proceso se eliminan los comentarios, pero lo hace permanentemente - for (Map.Entry<Integer, Video> it : this.misVideos.entrySet()){ - it.getValue().eliminar(); - try { - new VideoJpaController().edit(it.getValue()); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - } - - public void eliminarTodoRastroDelUsuario(String nickname) { - // recorre los videos del canal eliminando comentarios y valoraciones hechas por el usuario con ese nickname - for (Map.Entry<Integer, Video> it : this.misVideos.entrySet()){ - it.getValue().eliminarTodoRastroDelUsuario(nickname); - try { - new VideoJpaController().edit(it.getValue()); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - } - //----------------------------------------------------------------------------- - public void actualizarListasPorDefecto(ArrayList<String> listas) { - // descarta las listas que ya estan agregadas - for (Map.Entry<Integer, ListaDeReproduccion> l : misListas.entrySet()) { - if (l.getValue().getTipo() == TipoListaDeReproduccion.POR_DEFECTO) { - listas.remove(l.getValue().getNombre()); - } - } - // agrega las que pasaron el filtro anterior - for (String lista : listas) { - ListaDeReproduccion nuevaLista = new ListaDeReproduccion(0, lista, Privacidad.PRIVADO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED"); - // crea la tupla en la base de datos - // asi se genera el ID y se puede agregar al Map - new ListaDeReproduccionJpaController().create(nuevaLista); - this.misListas.put(nuevaLista.getId(), nuevaLista); - } - } - - public void agregarComentarioAVideo(int id, DtComentario comentario, Usuario usuario) { - if (this.misVideos.containsKey(id)) { - this.misVideos.get(id).agregarComentario(comentario, usuario); - try { - new VideoJpaController().edit(this.misVideos.get(id)); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - } - - public void agregarComentarioAVideo(int id, int idComentario, DtComentario comentario, Usuario usuario) { - if (this.misVideos.containsKey(id)) { - this.misVideos.get(id).agregarComentario(idComentario, comentario, usuario); - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - } - - public void agregarListaParticular(DtListaDeReproduccion listaReproduccion) { - if (listaReproduccion == null){ - throw new RuntimeException("La lista de reprodccion es null"); - } - if (listaReproduccion.getNombre().equals("")){ - throw new RuntimeException("El nombre no puede ser vacio"); - } - if (this.privacidad == Privacidad.PRIVADO && listaReproduccion.getPrivacidad() == Privacidad.PUBLICO){ - throw new RuntimeException("No se puede agregar una lista de reproduccion publica a un canal privado"); - } - if (listaReproduccion.getCategoria().equals("")){ - throw new RuntimeException("La categoria no puede ser vacia"); - } - - // un canal no puede tener dos videos con el mismo nomre - for (Map.Entry<Integer, ListaDeReproduccion> v : misListas.entrySet()){ - if (v.getValue().getNombre().equals(listaReproduccion.getNombre())){ - throw new RuntimeException("El canal ya posee una lista de reproduccion con ese nombre"); - } - } - - ListaDeReproduccion ldr = new ListaDeReproduccion( - 0, - listaReproduccion.getNombre(), - listaReproduccion.getPrivacidad(), - listaReproduccion.getTipo(), - listaReproduccion.getCategoria()); - // crea la tupla en la base de datos - // asi se genera el ID y se puede agregar al Map - new ListaDeReproduccionJpaController().create(ldr); - this.misListas.put(ldr.getId(), ldr); - } - - public void quitarValoracion(int idVideo, String nickname) { - if (this.misVideos.containsKey(idVideo)) { - this.misVideos.get(idVideo).quitarValoracion(nickname); - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - - } - - public void agregarModificarValoracion(int id, DtValoracion valoracion, Usuario usuario) { - if (this.misVideos.containsKey(id)) { - this.misVideos.get(id).agregarModificarValoracion(valoracion, usuario); - try { - new VideoJpaController().edit(this.misVideos.get(id)); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - - } - - public void agregarVideo(DtVideo video) { - if(video== null){ - throw new RuntimeException("El Datatype del video es null"); - } - if (video.getNombre().equals("")){ - throw new RuntimeException("El nombre no puede ser vacio"); - } - if(video.getDuracion() == null){ - throw new RuntimeException("La duracion no puede ser null"); - } - if(video.getFechaPublicacion() == null){ - throw new RuntimeException("La fecha de publicion no puede ser null"); - } - if (video.getUrlVideoOriginal().equals("")){ - throw new RuntimeException("La direccion URL no puede ser vacia"); - } - if (video.getCategoria().equals("")){ - throw new RuntimeException("La categorÃa no puede ser vacÃa"); - } - - // un canal no puede tener dos videos con el mismo nomre - for (Map.Entry<Integer, Video> v : misVideos.entrySet()){ - if (v.getValue().getNombre().equals(video.getNombre())){ - throw new RuntimeException("El canal ya posee un video con ese nombre"); - } - } - - Video vd = new Video( - 0, - video.getNombre(), - video.getDescripcion(), - video.getDuracion(), - video.getFechaPublicacion(), - video.getUrlVideoOriginal(), - video.getCategoria()); - - // si el canal es privado, el video debera serlo tambien - // si el canal es publico, el video sera lo definido en el DataType - if (this.privacidad == Privacidad.PRIVADO){ - vd.setPrivacidad(Privacidad.PRIVADO); - } - // crea la tupla en la base de datos - // asi se genera el ID y se puede agregar al Map - new VideoJpaController().create(vd); - this.misVideos.put(vd.getId(), vd); - } - - public void agregarVideoALista(int id, Video video) { - if (this.misListas.containsKey(id)) { - this.misListas.get(id).agregarVideoA(video); - try { - new ListaDeReproduccionJpaController().edit(this.misListas.get(id)); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } else { - throw new RuntimeException("La lista no pertenece al canal"); - } - } - - public DtCanal getDT() { - return new DtCanal(this.id, - this.nombre, - this.descripcion, - this.privacidad); - } - - public ArrayList<DtComentario> listarComentariosDeVideo(int id) { - if (this.misVideos.containsKey(id)) { - return this.misVideos.get(id).listarComentarios(); - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - } - - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccion(boolean soloParticulares) { - ArrayList<DtListaDeReproduccion> ret = new ArrayList(); - // porDefecto = false --> lista todas las listas - // porDefecto = true --> lista solo las particulares - for (Map.Entry<Integer, ListaDeReproduccion> m : misListas.entrySet()) { - if(soloParticulares && m.getValue().getTipo()==TipoListaDeReproduccion.POR_DEFECTO){ - continue; - } - ret.add(m.getValue().getDt()); - } - - return ret; - } - - public ArrayList<DtValoracion> listarValoracionesDeVideo(int id) { - if (this.misVideos.containsKey(id)) { - return this.misVideos.get(id).listarValoraciones(); - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - } - - public ArrayList<DtVideo> listarVideos() { - ArrayList<DtVideo> ret = new ArrayList(); - - // para cada elemento en misVideos - /** - * este for no es normal, se declara la variable m que es de tipo - * Entrada de Map (como un nodo arbol), y autmaticamente la hace avanzar - * por todas las entradas de la coleccion. De la entrada actual se puede - * obtener la Key y el Valor almacenado - */ - for (Map.Entry<Integer, Video> m : misVideos.entrySet()) { - // hace un getDT y lo agrega a la coleccion de retorno - ret.add(m.getValue().getDt()); - } - return ret; - } - - public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(int id) { - if (this.misListas.containsKey(id)) { - return this.misListas.get(id).listarVideos(); - } else { - throw new RuntimeException("La lista de reproduccion no pertenece al canal"); - } - } - - public void modificar(DtCanal canal) { - if (canal.getNombre().equals("")) { - throw new RuntimeException("El nombre no puede ser vacio"); - } - - // Si el canal es publico y se va a cambiar a privado, se deben cambiar a privado todos los videos del canal - if (this.privacidad == Privacidad.PUBLICO && canal.getPrivacidad() == Privacidad.PRIVADO){ - this.setPrivacidad(canal.getPrivacidad()); - } - - this.nombre = canal.getNombre(); - this.descripcion = canal.getDescripcion(); - this.privacidad = canal.getPrivacidad(); - } - - public void modificarListaDeReproduccion(DtListaDeReproduccion ldr) { - if (ldr == null) { - throw new RuntimeException("El Datatype de la lista de reprodccion es null"); - } - if (this.misListas.containsKey(ldr.getId())) { - - if (this.privacidad == Privacidad.PRIVADO && ldr.getPrivacidad() == Privacidad.PUBLICO){ - throw new RuntimeException("No se puede hacer publica una lista de reproduccion de un canal privado"); - } - for (Map.Entry<Integer, ListaDeReproduccion> m : this.misListas.entrySet()){ - if (m.getKey() != ldr.getId()){ - if (m.getValue().getNombre().equals(ldr.getNombre())) { - throw new RuntimeException("El canal ya posee una lista con ese nombre"); - } - } - } - - this.misListas.get(ldr.getId()).modificar(ldr); - try { - new ListaDeReproduccionJpaController().edit(this.misListas.get(ldr.getId())); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } else { - throw new RuntimeException("La lista de reproduccion no pertenece al canal"); - } - } - - public void modificarVideo(DtVideo video) { - if(video== null){ - throw new RuntimeException("El Datatype del video es null"); - } - - if (this.misVideos.containsKey(video.getId())) { - - if (this.privacidad == Privacidad.PRIVADO && video.getPrivacidad() == Privacidad.PUBLICO){ - throw new RuntimeException("No se puede hacer publico un video de un canal privado"); - } - - for (Map.Entry<Integer, Video> m : this.misVideos.entrySet()){ - if (m.getKey() != video.getId()){ - if (m.getValue().getNombre().equals(video.getNombre())) { - throw new RuntimeException("El canal ya posee una lista con ese nombre"); - } - } - } - - this.misVideos.get(video.getId()).modificar(video); - try { - new VideoJpaController().edit(this.misVideos.get(video.getId())); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - } - - public DtListaDeReproduccion obtenerListaDeReproduccion(int id){ - ListaDeReproduccion ldr = misListas.get(id); - if (ldr == null){ - throw new RuntimeException("La lista de reproduccion no pertenece al canal"); - }else{ - return ldr.getDt(); - } - } - - public ArrayList<DtListaDeReproduccion> obtenerListasEnCategoria(String cat) { - ArrayList<DtListaDeReproduccion> ret = new ArrayList(); - - // para cada elemento en misVideos - /** - * este for no es normal, se declara la variable m que es de tipo - * Entrada de Map (como un nodo arbol), y autmaticamente la hace avanzar - * por todas las entradas de la coleccion. De la entrada actual se puede - * obtener la Key y el Valor almacenado - */ - for (Map.Entry<Integer, ListaDeReproduccion> m : misListas.entrySet()) { - // hace un getDT y lo agrega a la coleccion de retorno - if (m.getValue().getCategoria().equals(cat)) { - ret.add(m.getValue().getDt()); - } - } - - return ret; - } - - public DtVideo obtenerDtVideo(int id) { - if (this.misVideos.containsKey(id)) { - return this.misVideos.get(id).getDt(); - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - } - - public Video obtenerVideo(int id) { - if (this.misVideos.containsKey(id)) { - return this.misVideos.get(id); - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - } - - public ArrayList<DtVideo> obtenerVideosEnCategoria(String cat) { - ArrayList<DtVideo> ret = new ArrayList(); - - // para cada elemento en misVideos - /** - * este for no es normal, se declara la variable m que es de tipo - * Entrada de Map (como un nodo arbol), y autmaticamente la hace avanzar - * por todas las entradas de la coleccion. De la entrada actual se puede - * obtener la Key y el Valor almacenado - */ - for (Map.Entry<Integer, Video> m : misVideos.entrySet()) { - // hace un getDT y lo agrega a la coleccion de retorno - if (m.getValue().getCategoria().equals(cat)) { - ret.add(m.getValue().getDt()); - } - } - - return ret; - } - - public void quitarVideoDeListaDeReproduccion(int idLista, int idVideo) { - if (this.misListas.containsKey(idLista)) { - this.misListas.get(idLista).quitarVideo(idVideo); - try { - new ListaDeReproduccionJpaController().edit(this.misListas.get(idLista)); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } else { - throw new RuntimeException("La lista de reproduccion no pertenece al canal"); - } - } - - public boolean validarListaParticular(String nombreLista) { - for (Map.Entry<Integer, ListaDeReproduccion> l : misListas.entrySet()) { - if (l.getValue().getTipo() == TipoListaDeReproduccion.PARTICULAR && l.getValue().getNombre().equals(nombreLista)) { - return false; - } - } - return true; - } - - public DtValoracion obtenerValoracion(int id, String nickname) { - if (this.misVideos.containsKey(id)) { - return this.misVideos.get(id).obtenerValoracion(nickname); - } else { - throw new RuntimeException("El video no pertenece al canal"); - } - } - -} diff --git a/UyTube_aplicacion/src/Logica/Clases/Categoria.java b/UyTube_aplicacion/src/Logica/Clases/Categoria.java deleted file mode 100644 index b02df9b0a041fd7ae27c44528f295952327341c6..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/Categoria.java +++ /dev/null @@ -1,30 +0,0 @@ -package Logica.Clases; - -import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "categoria") -public class Categoria implements Serializable { - @Id - @Column(name = "nombre") - private String nombre; - - //--------------------------------------------------------------------------- - public Categoria() { - } - - public Categoria(String nombre) { - if (nombre.equals("")){ - throw new RuntimeException("El nombre de la categoria no puede ser vacio"); - } - this.nombre = nombre; - } - - public String getNombre() { - return nombre; - } -} diff --git a/UyTube_aplicacion/src/Logica/Clases/Comentario.java b/UyTube_aplicacion/src/Logica/Clases/Comentario.java deleted file mode 100644 index 752952e492d173ec0283804cc9112a98a2fd6c25..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/Comentario.java +++ /dev/null @@ -1,158 +0,0 @@ -package Logica.Clases; - -import JPAControllerClasses.ComentarioJpaController; -import Logica.DataType.DtComentario; -import java.io.Serializable; -import java.sql.Date; -import java.util.ArrayList; -import java.util.List; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; -import javax.persistence.Table; - -@Entity -@Table(name = "comentario") -public class Comentario implements Serializable { - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - @Basic - @Column(name = "fecha") - private Date fecha; - - @Column(name = "texto") - private String texto; - - @Column(name = "nivel") - private int nivelSubComentario; - - @ManyToOne() - @JoinColumn(name = "nick_usuario") - private Usuario usr; - - @OneToMany(cascade = CascadeType.ALL, - orphanRemoval = true) - @JoinColumn(name = "id_com_padre") - private List<Comentario> misComentario; - - //--------------------------------------------------------------------------- - public Comentario() { - } - - public Comentario(int id, Date fecha, String texto, int nivelSubComentario, Usuario usr) { - if(usr==null){ - throw new RuntimeException("Usuario No puede ser null"); - } - if(fecha==null){ - throw new RuntimeException("Date No puede ser null"); - } - this.id = id; - this.fecha = fecha; - this.texto = texto; - this.nivelSubComentario = nivelSubComentario; - this.usr = usr; - this.misComentario = new ArrayList(); - } - - public int getId() { - return id; - } - - public Date getFecha() { - return fecha; - } - public String getTexto() { - return texto; - } - public int getNivelSubComentario() { - return nivelSubComentario; - } - - public Usuario getUsr() { - return usr; - } - - public void setUsr(Usuario usr) { - this.usr = usr; - } - - @Override - public String toString() { - return "Comentario{" + "id=" + id + ", fecha=" + fecha + ", texto=" + texto + ", nivelSubComentario=" + nivelSubComentario + '}'; - } - - public void eliminarTodoRastroDelUsuario(String nickname) { - - for (int i = 0; i < this.misComentario.size(); i++){ - if (this.misComentario.get(i).getUsr().getNickname().equals(nickname)){ - this.misComentario.remove(i); - i--; - } else { - this.misComentario.get(i).eliminarTodoRastroDelUsuario(nickname); - try { - new ComentarioJpaController().edit(this.misComentario.get(i)); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - } - } - - - public boolean agregarSubComentario(int idComPadre, DtComentario dtC, Usuario usr) { - if(dtC==null){ - throw new RuntimeException("DtComentario No puede ser null"); - } - if(usr==null){ - throw new RuntimeException("Usuario No puede ser null"); - } - if (this.id == idComPadre) { - Comentario com = new Comentario(0, - dtC.getFecha(), - dtC.getTexto(), - this.nivelSubComentario + 1, - usr); - // crea la tupla en la base de datos - // asi se genera el ID y se puede agregar al Map - new ComentarioJpaController().create(com); - this.misComentario.add(com); - return true; - } else { - boolean comentarioComentado; - for (int i = 0; i < misComentario.size(); i++) { - comentarioComentado = this.misComentario.get(i).agregarSubComentario(idComPadre, dtC, usr); - if (comentarioComentado) { - return true; - } - } - return false; - } - } - - public DtComentario getDT() { - DtComentario dtC = new DtComentario(this.id, this.usr.getNickname(), this.fecha, this.texto, this.nivelSubComentario); - return dtC; - } - - public ArrayList<DtComentario> listarSubComentarios() { - ArrayList lsc = new ArrayList(); - - for (int i = 0; i < this.misComentario.size(); i++) { - lsc.add(this.misComentario.get(i).getDT()); - lsc.addAll(this.misComentario.get(i).listarSubComentarios()); - } - return lsc; - } -} diff --git a/UyTube_aplicacion/src/Logica/Clases/ListaDeReproduccion.java b/UyTube_aplicacion/src/Logica/Clases/ListaDeReproduccion.java deleted file mode 100644 index 171684d3ad3899880f1f04449e0ff7a437339e05..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/ListaDeReproduccion.java +++ /dev/null @@ -1,174 +0,0 @@ -package Logica.Clases; - -import Logica.DataType.DtListaDeReproduccion; -import Logica.DataType.DtVideo; -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoListaDeReproduccion; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Map; -import java.util.TreeMap; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.MapKey; -import javax.persistence.OneToMany; -import javax.persistence.Table; - -@Entity -@Table(name = "lista_de_reproduccion") -public class ListaDeReproduccion implements Serializable { - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - @Column(name = "nombre") - private String nombre; - - @Enumerated(EnumType.STRING) - @Column(name = "privacidad") - private Privacidad privacidad; - - @Column(name = "eliminado") - private boolean eliminado; - - @Enumerated(EnumType.STRING) - @Column(name = "tipo") - private TipoListaDeReproduccion tipo; - - @Column(name = "categoria") - private String categoria; - - @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) - @JoinTable( - name="videos_en_listas", - joinColumns={@JoinColumn(name="id_lista", referencedColumnName="id")}, - inverseJoinColumns={@JoinColumn(name="id_video", referencedColumnName="id")}) - @MapKey(name = "id") - private Map<Integer, Video> misVideos; - - //----------------------------------------------------------------------------- - public ListaDeReproduccion() { - } - - public ListaDeReproduccion(int id, String nombre, Privacidad privacidad, TipoListaDeReproduccion tipo, String categoria) { - if (nombre.equals("")){ - throw new RuntimeException("El nombre de la lista de reproduccion no puede ser vacio"); - } - if (categoria.equals("")){ - throw new RuntimeException("La Categoria de la lista de reproduccion no puede ser vacia"); - } - if (tipo == TipoListaDeReproduccion.POR_DEFECTO && privacidad != Privacidad.PRIVADO){ - throw new RuntimeException("No se puede crear una lista de reproduccion por defecto publica"); - } - if (tipo == TipoListaDeReproduccion.POR_DEFECTO && !categoria.equals("UNDEFINED")){ - throw new RuntimeException("No se puede crear una lista de reproduccion por defecto en una categoria"); - } - this.id = id; - this.nombre = nombre; - this.privacidad = privacidad; - this.tipo = tipo; - this.categoria = categoria; - this.misVideos = new TreeMap(); - this.eliminado = false; - } - - public int getId() { - return id; - } - - public String getNombre() { - return nombre; - } - - public Privacidad getPrivacidad() { - return privacidad; - } - - public void setPrivacidad(Privacidad privacidad) { - this.privacidad = privacidad; - } - - public TipoListaDeReproduccion getTipo() { - return tipo; - } - - public String getCategoria() { - return categoria; - } - - @Override - public String toString() { - return "ListaDeReproduccion{" + "id=" + id + ", nombre=" + nombre + ", privacidad=" + privacidad + ", tipo=" + tipo + ", categoria=" + categoria + ", misVideos.size=" + misVideos.size() + '}'; - } - - public void eliminar(){ - this.eliminado = true; - - } - ///////////////////////////////////////////////////////////////////////////////////////// - - public void agregarVideoA(Video v){ - if (v == null){ - throw new RuntimeException("El video recibido para agregar a la lista es NULL"); - } - // agrega el video y su clave a la coleccion - this.misVideos.put(v.getId(), v); - } - - public DtListaDeReproduccion getDt(){ - // devuelve un DT con los datos de la lista - return new DtListaDeReproduccion(this.id, this.nombre, this.privacidad, this.tipo, this.categoria); - } - - public ArrayList<DtVideo> listarVideos(){ - // crea una lista de retorno - ArrayList<DtVideo> ret = new ArrayList(); - - // para cada elemento en misVideos - /** - * este for no es normal, se declara la variable m que es de tipo - * Entrada de Map (como un nodo arbol), y autmaticamente la hace avanzar - * por todas las entradas de la coleccion. - * De la entrada actual se puede obtener la Key y el Valor almacenado - */ - for (Map.Entry<Integer, Video> m : misVideos.entrySet()){ - // hace un getDT y lo agrega a la coleccion de retorno - ret.add(m.getValue().getDt()); - } - - return ret; - } - - public void modificar(DtListaDeReproduccion ldr) { - if (this.tipo == TipoListaDeReproduccion.POR_DEFECTO){ - throw new RuntimeException("No se puede modificar una lista por defecto"); - } - if (ldr == null){ - throw new RuntimeException("El DataTyppe recibido para modificar la lista de reproduccion es NULL"); - } - if (ldr.getNombre().equals("")){ - throw new RuntimeException("El nombre de la lista de reproduccion no puede ser vacio"); - } - // se sobreescriben los atributos que pueden ser modificados - this.nombre = ldr.getNombre(); - this.privacidad = ldr.getPrivacidad(); - this.categoria = ldr.getCategoria(); - // el ID y el tipo de lista no se puede modificar - } - - public void quitarVideo(int idVideo) { - // remueve de la coleccion el video con la clave idVideo - this.misVideos.remove(idVideo); - } - -} diff --git a/UyTube_aplicacion/src/Logica/Clases/ListaPorDefecto.java b/UyTube_aplicacion/src/Logica/Clases/ListaPorDefecto.java deleted file mode 100644 index 2860ce7d3b5aca952cadb5594a54b80c6323d302..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/ListaPorDefecto.java +++ /dev/null @@ -1,29 +0,0 @@ -package Logica.Clases; - -import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "lista_por_defecto") -public class ListaPorDefecto implements Serializable { - - @Id - @Column(name = "nombre") - private String nombre; - - //---------------------------------------------------------------------- - public ListaPorDefecto() { - } - - public ListaPorDefecto(String nombre) { - this.nombre = nombre; - } - - public String getNombre() { - return nombre; - } - -} diff --git a/UyTube_aplicacion/src/Logica/Clases/Persona.java b/UyTube_aplicacion/src/Logica/Clases/Persona.java deleted file mode 100644 index 599c6d0099d0efaa1df00940d5df94beb28aad43..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/Persona.java +++ /dev/null @@ -1,71 +0,0 @@ -package Logica.Clases; - -import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; - -@Entity -@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) -public abstract class Persona implements Serializable { - @Id - private int id; - - @Column(name = "nombre") - private String nombre; - - @Column(name = "apellido") - private String apellido; - - @Column(name = "contrasenia") - private String contrasenia; - - //----------------------------------------------------------------------------- - - public Persona() { - } - - public Persona(String nombre, String apellido, String contrasenia) { - if(contrasenia.equals("")){ - throw new RuntimeException("La contraseña no puede ser Vacio"); - } - this.nombre = nombre; - this.apellido = apellido; - this.contrasenia = contrasenia; - } - - public int getId() { - return id; - } - - public String getNombre() { - return nombre; - } - - public String getApellido() { - return apellido; - } - - public String getContrasenia() { - return contrasenia; - } - - public void setNombre(String nombre) { - this.nombre = nombre; - } - - public void setApellido(String apellido) { - this.apellido = apellido; - } - - public void setContrasenia(String contrasenia) { - this.contrasenia = contrasenia; - } - - public boolean validarContrasenia(String pass){ - return this.contrasenia.equals(pass); - } - -} diff --git a/UyTube_aplicacion/src/Logica/Clases/Usuario.java b/UyTube_aplicacion/src/Logica/Clases/Usuario.java deleted file mode 100644 index 1ca5dcaeedc420c6fb07b0861120d6d689d2691f..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/Usuario.java +++ /dev/null @@ -1,406 +0,0 @@ -package Logica.Clases; -import JPAControllerClasses.CanalJpaController; -import java.sql.Date; -import Logica.DataType.*; -import java.util.ArrayList; -import java.util.Map; -import java.util.TreeMap; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.MapKey; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; -import javax.persistence.Table; - -@Entity -@Table(name="usuario") -public class Usuario extends Persona{ - @Id - @Column(name = "id") - private String id; - - @Column(name = "correo") - private String correo; - - @Basic - @Column(name = "fecha_nacimiento") - private Date fechaNacimiento; - - @Column(name = "imagen") - private String imagen; - - @Column(name = "seguidores") - private int seguidores; - - @Column(name = "eliminado") - private boolean eliminado; - - @Basic - @Column(name = "fecha_eliminado") - private Date fechaEliminado; - - - @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "id_canal") - private Canal MiCanal; - - @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) - @JoinTable( - name="usuarios_seguidores", - joinColumns={@JoinColumn(name="nick_seguido", referencedColumnName="id")}, - inverseJoinColumns={@JoinColumn(name="nick_seguidor", referencedColumnName="id")}) - @MapKey(name = "id") - private Map<String, Usuario> misSeguidores; - - @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) - @JoinTable( - name="usuarios_seguidos", - joinColumns={@JoinColumn(name="nick_seguidor", referencedColumnName="id")}, - inverseJoinColumns={@JoinColumn(name="nick_seguido", referencedColumnName="id")}) - @MapKey(name = "id") - private Map<String, Usuario> seguidos; - - //---------------------------------------------------------------------------------- - public Usuario() { - super(); - } - - public Usuario(String nickname, String correo, Date fechaNacimiento, String imagen, String contrasenia, String nombre, String apellido, DtCanal DTC) { - super(nombre,apellido,contrasenia); - - if(fechaNacimiento == null){ - throw new RuntimeException("la fecha no puede ser nill"); - } - if(DTC == null){ - throw new RuntimeException("El canal no puede ser null"); - } - if(nickname == ""){ - throw new RuntimeException("El nickname no puede ser Vacio"); - } - - if(correo == ""){ - throw new RuntimeException("El correo no puede ser Vacio"); - } - - this.id = nickname; - this.correo = correo; - this.fechaNacimiento = fechaNacimiento; - this.imagen = imagen; - this.seguidores = 0; - this.MiCanal = new Canal(0,DTC.getNombre(),DTC.getDescripcion(),DTC.getPrivacidad()); - this.misSeguidores = new TreeMap(); - this.seguidos = new TreeMap(); - this.eliminado = false; - this.fechaEliminado = null; - } - - public String getNickname() { - return id; - } - - public String getCorreo() { - return correo; - } - - public Date getFechaNacimiento() { - return fechaNacimiento; - } - - public String getImagen() { - return imagen; - } - - public int getSeguidores() { - return seguidores; - } - - public DtUsuario getDT(){ - return new DtUsuario(this.id, super.getContrasenia(), super.getNombre(), super.getApellido(), this.correo, this.fechaNacimiento, this.fechaEliminado, this.imagen, this.seguidores); - } - - public void eliminar(Date fecha) { - this.fechaEliminado = fecha; - this.eliminado = true; - this.MiCanal.eliminar(); - try { - new CanalJpaController().edit(this.MiCanal); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - public void eliminarTodoRastroDelUsuario(String nickname) { - // Esta funcion que estas leyendo NO se encarga de eliminar vinculos de seguimiento - this.MiCanal.eliminarTodoRastroDelUsuario(nickname); - try { - new CanalJpaController().edit(this.MiCanal); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - public void actualizarListasPorDefecto(ArrayList<String> listas){ - this.MiCanal.actualizarListasPorDefecto(listas); - try { - new CanalJpaController().edit(this.MiCanal); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - public void agregarComentarioAVideo(int idVideo, DtComentario DtComentario, Usuario Usu){ - if(DtComentario == null){ - throw new RuntimeException("El comentario no puede ser null"); - } - if(Usu == null){ - throw new RuntimeException("El usuario no puede ser null"); - } - - this.MiCanal.agregarComentarioAVideo(idVideo, DtComentario, Usu); - } - - public void agregarComentarioAVideo(int idVideo, int idCom, DtComentario DtComentario, Usuario Usu){ - if(DtComentario == null){ - throw new RuntimeException("El comentario no puede ser null"); - } - if(Usu == null){ - throw new RuntimeException("El usuario no puede ser null"); - } - - this.MiCanal.agregarComentarioAVideo(idVideo, idCom, DtComentario, Usu); - } - - public void agregarListaParticular(DtListaDeReproduccion DtValoracion){ - if(DtValoracion == null){ - throw new RuntimeException("La valoracion no puede ser null"); - } - this.MiCanal.agregarListaParticular(DtValoracion); - try { - new CanalJpaController().edit(this.MiCanal); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - public void agregarModificarValoracionDeVideo(int idVideo, DtValoracion DtValoracion, Usuario Usu){ - if(DtValoracion == null){ - throw new RuntimeException("La valoracion no puede ser null"); - } - if(Usu == null){ - throw new RuntimeException("El usuario no puede ser null"); - } - - this.MiCanal.agregarModificarValoracion(idVideo , DtValoracion, Usu); - } - - public void agregarOQuitarSeguido(Usuario Usu){ - if(Usu == null){ - throw new RuntimeException("El usuario no puede ser null"); - } - if(Usu == this){ - throw new RuntimeException("Un usuario no se puede seguir a si mismo"); - } - - if (this.seguidos.containsKey(Usu.getNickname())){ - this.seguidos.remove(Usu.getNickname()); - }else{ - this.seguidos.put(Usu.getNickname(), Usu); - } - - Usu.agregarOQuitarSeguidor(this); - } - - // si, esta si es private, no es un error - private void agregarOQuitarSeguidor(Usuario Usu){ - if(Usu == null){ - throw new RuntimeException("El usuario no puede ser null"); - } - - if (this.misSeguidores.containsKey(Usu.id)){ - this.misSeguidores.remove(Usu.getNickname()); - this.seguidores--; - }else{ - this.misSeguidores.put(Usu.getNickname(), Usu); - this.seguidores++; - } - } - - public void agregarVideoACanal(DtVideo DtVideo){ - if(DtVideo == null){ - throw new RuntimeException("El video no puede ser null"); - } - this.MiCanal.agregarVideo(DtVideo); - try { - new CanalJpaController().edit(this.MiCanal); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - public void agregarVideoALista(int idLista , int idVideo, Usuario Usu){ - if(Usu == null){ - throw new RuntimeException("El usuario no puede ser null"); - } - Video v = null; - try { - v = Usu.obtenerVideo(idVideo); - } catch (Exception e) { - throw new RuntimeException("El video no pertenece al usuario: " + Usu.getNickname()); - } - this.MiCanal.agregarVideoALista(idLista, v); - } - - public ArrayList<DtComentario> listarComentariosDeVideo(int idVideo){ - return this.MiCanal.listarComentariosDeVideo(idVideo); - } - - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeCanal(boolean soloParticulares){ - return this.MiCanal.listarListasDeReproduccion(soloParticulares); - } - - public ArrayList<DtUsuario> listarUsuariosSeguidos(){ - // crea una lista de retorno - ArrayList<DtUsuario> ret = new ArrayList(); - - for (Map.Entry<String,Usuario> i : this.seguidos.entrySet()){ - // hace un getDT y lo agrega a la coleccion de retorno - ret.add(i.getValue().getDT()); - } - return ret; - }//(Ctrl + C Ctrl + V) De la clase video - - public ArrayList<DtUsuario> listarUsuariosSeguidores(){ - // crea una lista de retorno - ArrayList<DtUsuario> ret = new ArrayList(); - - for (Map.Entry<String,Usuario> i : this.misSeguidores.entrySet()){ - // hace un getDT y lo agrega a la coleccion de retorno - ret.add(i.getValue().getDT()); - } - return ret; - }//(Ctrl + C Ctrl + V) De la clase lirRepro - - public ArrayList<DtValoracion> listarValoracionesDeVideo(int id){ - return this.MiCanal.listarValoracionesDeVideo(id); - } - - public ArrayList<DtVideo> listarVideosDeCanal(){ - return this.MiCanal.listarVideos(); - } - - public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(int id){ - return this.MiCanal.listarVideosDeListaDeReproduccion(id); - } - - public void modificar(DtUsuario DtUsu, DtCanal DtCanal){ - if(DtUsu == null){ - throw new RuntimeException("El usuario no puede ser null"); - } - if(DtUsu.getFechaNacimiento() == null){ - throw new RuntimeException("La fecha no puede ser null"); - } - if(DtCanal == null){ - throw new RuntimeException("El canal no puede ser null"); - } - if (this.id != DtUsu.getNickname()){ - throw new RuntimeException("El nickname no puede ser modificado"); - } - if (this.correo != DtUsu.getCorreo()){ - throw new RuntimeException("El correo no puede ser modificado"); - } - super.setNombre(DtUsu.getNombre()); - super.setApellido(DtUsu.getApellido()); - super.setContrasenia(DtUsu.getContrasenia()); - this.fechaNacimiento = DtUsu.getFechaNacimiento(); - this.imagen = DtUsu.getImagen(); - - this.MiCanal.modificar(DtCanal); - try { - new CanalJpaController().edit(this.MiCanal); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - public void modificarListaDeReproduccionDeCanal(DtListaDeReproduccion DtListaDeReproduccion){ - if(DtListaDeReproduccion == null){ - throw new RuntimeException("La lista de reproduccion no puede ser null"); - } - - this.MiCanal.modificarListaDeReproduccion(DtListaDeReproduccion); - } - - public void modificarVideoDeCanal(DtVideo DtVideo){ - if(DtVideo == null){ - throw new RuntimeException("El video no puede ser null"); - } - this.MiCanal.modificarVideo(DtVideo); - } - - public DtCanal obtenerCanal(){ - return this.MiCanal.getDT(); - } - - - public DtListaDeReproduccion obtenerListaDeReproduccion(int id){ - return MiCanal.obtenerListaDeReproduccion(id); - } - - - public ArrayList<DtListaDeReproduccion> obtenerListasEnCategoria(String cat){ - if(cat == ""){ - throw new RuntimeException("La categoria no puede ser vacia"); - } - - return this.MiCanal.obtenerListasEnCategoria(cat); - } - - public DtValoracion obtenerValoracion(int id, String nickname){ - if(nickname == ""){ - throw new RuntimeException("El nickname no puede ser vacio"); - } - - return this.MiCanal.obtenerValoracion(id, nickname); - } - - public Video obtenerVideo(int id){ - return this.MiCanal.obtenerVideo(id); - } - - public DtVideo obtenerVideoDeCanal(int idVideo){ - return this.MiCanal.obtenerDtVideo(idVideo); - } - - public ArrayList<DtVideo> obtenerVideosEnCategoria(String cat){ - if(cat == ""){ - throw new RuntimeException("La categoria no puede ser vacia"); - } - - return this.MiCanal.obtenerVideosEnCategoria(cat); - - } - - public void quitarValoracion(int id, String nickname){ - if(nickname == ""){ - throw new RuntimeException("El nickname no puede ser vacia"); - } - this.MiCanal.quitarValoracion(id, nickname); - } - - public void quitarVideoDeListaDeReproduccion(int idLista, int idVideo){ - this.MiCanal.quitarVideoDeListaDeReproduccion(idLista, idVideo); - } - - public boolean validarListaParticular(String nombre){ - if(nombre == ""){ - throw new RuntimeException("El nombre de la lista no puede ser vacia"); - } - return this.MiCanal.validarListaParticular(nombre); - } -} - diff --git a/UyTube_aplicacion/src/Logica/Clases/Valoracion.java b/UyTube_aplicacion/src/Logica/Clases/Valoracion.java deleted file mode 100644 index 69d547d87034d9aa96a2e0c2d005c49e2ccb3a44..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/Valoracion.java +++ /dev/null @@ -1,95 +0,0 @@ -package Logica.Clases; - -import Logica.DataType.DtValoracion; -import Logica.Enumerados.TipoValoracion; -import java.io.Serializable; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; - -@Entity -@Table(name = "valoracion") -public class Valoracion implements Serializable { - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - @Enumerated(EnumType.STRING) - @JoinColumn(name = "valoracion") - private TipoValoracion val; - - @OneToOne(cascade = CascadeType.MERGE) - @JoinColumn(name = "nick_usuario") - private Usuario usr; - - //----------------------------------------------------------------------- - public Valoracion() { - } - - public Valoracion(TipoValoracion val, Usuario usr) { - if(usr==null){ - throw new RuntimeException("Usuario No puede ser null"); - } - this.val = val; - this.usr = usr; - } - - //----------------------------------------------------------------------- - public int getId() { - return id; - } - - public TipoValoracion getVal() { - return val; - } - - public void setVal(TipoValoracion val) { - this.val = val; - } - - public String getNicknameDeUsuario() { - return this.usr.getNickname(); - } - - public DtValoracion getDT(){ - DtValoracion dtV = new DtValoracion(this.val, this.usr.getNickname()); - return dtV; - } - public DtValoracion getDT(String nickname){ - if(nickname==null){ - throw new RuntimeException("Nickname No puede ser null"); - } - // si esta valoracion corresponde al usuario, devuelve su DT, sino null - if (nickname.equals(this.usr.getNickname())){ - return this.getDT(); - }else{ - return null; - } - } - public boolean modificar(DtValoracion dtV, String nickname){ - if(dtV==null){ - throw new RuntimeException("DtValoracion No puede ser null"); - } - if(nickname==null){ - throw new RuntimeException("Nickname No puede ser null"); - } - if (nickname.equals(this.usr.getNickname())){ - this.val = dtV.getVal(); - return true; - }else{ - return false; - } - } - - -} diff --git a/UyTube_aplicacion/src/Logica/Clases/Video.java b/UyTube_aplicacion/src/Logica/Clases/Video.java deleted file mode 100644 index 221025a6cffe770ca127a9a1ad4ea344772278df..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Clases/Video.java +++ /dev/null @@ -1,429 +0,0 @@ -package Logica.Clases; -import JPAControllerClasses.ComentarioJpaController; -import JPAControllerClasses.ValoracionJpaController; -import Logica.DataType.DtComentario; -import Logica.DataType.DtValoracion; -import Logica.DataType.DtVideo; -import java.sql.Time; -import java.sql.Date; -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoValoracion; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.MapKey; -import javax.persistence.OneToMany; -import javax.persistence.Table; - -@Entity -@Table(name = "video") -public class Video implements Serializable { - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - @Column(name = "nombre") - private String nombre; - - @Column(name = "descripcion") - private String descripcion; - - @Basic - @Column(name = "duracion") - private Time duracion; - - @Basic - @Column(name = "fecha_publicacion") - private Date fechaPublicacion; - - - @Column(name = "url") - private String urlVideoOriginal; - - @Enumerated(EnumType.STRING) - private Privacidad privacidad = Privacidad.PRIVADO; - - - @Column(name = "categoria") - private String categoria; - - - @Column(name = "cant_likes") - private int cantLikes = 0; - - - @Column(name = "cant_dislikes") - private int cantDisLikes = 0; - - @Column(name = "eliminado") - private boolean eliminado; - - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumn(name = "id_video") - private List<Valoracion> valoraciones; - - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumn(name = "id_video") - @MapKey(name = "id") - private Map<Integer, Comentario> comentarios; - - //------------------------------------------------------------------------ - public Video(){ - - } - /********************** Constructor *********************/ - public Video(int _id, String _nombre, String _descripcion,Time _duracion, Date _fechaPublicacion,String _urlVideoOriginal,String _categoria ){ - if (_nombre == "") { - throw new RuntimeException("Error, el nombre del video está vacÃo"); - } - if (_duracion == null) { - throw new RuntimeException("Error, la duración del video es null."); - } - if (_fechaPublicacion == null) { - throw new RuntimeException("Error, la fecha de publicación del video es null."); - } - if (_urlVideoOriginal == "") { - throw new RuntimeException("Error, la url del video está vacÃa."); - } - if (_categoria == "") { - throw new RuntimeException("Error, la descripción del video está vacÃa."); - } - - this.id = _id; - this.nombre = _nombre; - this.descripcion = _descripcion; - this.duracion = _duracion; - this.fechaPublicacion = _fechaPublicacion; - this.urlVideoOriginal = _urlVideoOriginal; - this.categoria = _categoria; - this.valoraciones = new ArrayList<Valoracion>(); - this.comentarios = new TreeMap<Integer, Comentario>(); - this.eliminado = false; - } - - - public void eliminar(){ - this.eliminado = true; - this.valoraciones = new ArrayList<Valoracion>(); - this.comentarios = new TreeMap<Integer, Comentario>(); - } - - public void eliminarTodoRastroDelUsuario(String nickname) { - // manda a quitar la valoracion del usuario (si no ha valorado no tiene efecto) - quitarValoracion(nickname); - ArrayList<Integer> idAEliminar = new ArrayList(); - - for (Map.Entry<Integer, Comentario> it : this.comentarios.entrySet()){ - if (it.getValue().getDT().getNickname().equals(nickname)){ - idAEliminar.add(it.getKey()); - } else { - it.getValue().eliminarTodoRastroDelUsuario(nickname); - try { - new ComentarioJpaController().edit(it.getValue()); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - } - for (Integer i : idAEliminar){ - this.comentarios.remove(i); - } - } - - - - /** Agregar un nuevo comentario **/ - public void agregarComentario(DtComentario dtComentario, Usuario usuario){ - if (dtComentario == null){ - throw new RuntimeException("El DataType es null"); - } - if (usuario == null){ - throw new RuntimeException("El usuario es null"); - } - - Comentario nuevoComentario = new Comentario(0, dtComentario.getFecha(), dtComentario.getTexto(), 0, usuario); - // crea la tupla en la base de datos - // asi se genera el ID y se puede agregar al Map - new ComentarioJpaController().create(nuevoComentario); - comentarios.put(nuevoComentario.getId(), nuevoComentario); - } - - /* Agregar un subcomentario a un comentario existente */ - public void agregarComentario(int idCom, DtComentario dtComentario, Usuario usuario){ - if (dtComentario == null){ - throw new RuntimeException("El DataType es null"); - } - if (usuario == null){ - throw new RuntimeException("El usuario es null"); - } - boolean comentarioComentado; - for (Map.Entry<Integer, Comentario> coment : comentarios.entrySet()) { - comentarioComentado = coment.getValue().agregarSubComentario(idCom, dtComentario, usuario); - if (comentarioComentado) { - try { - new ComentarioJpaController().edit(coment.getValue()); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - break; - } - } - } - - /* Agrega o midifica una valoración */ - public void agregarModificarValoracion(DtValoracion dtValoracion, Usuario usuario) { - if (dtValoracion == null) { - throw new RuntimeException("El DataType es null"); - } - if (usuario == null){ - throw new RuntimeException("El usuario es null"); - } - - String nickname = usuario.getNickname(); - // por las dudas, para que los contadores de likes no queden inconsistentes: - // obtengo la valoracion que le habia dado antes el usuario (si es que lo habia alorado) - DtValoracion dtv = this.obtenerValoracion(nickname); - // si el usuario ya lo valoro - if (dtv != null) { - // segun cual fuera la valoracion anterior, resta 1 al contador - if (dtv.getVal() == TipoValoracion.LIKE) { - cantLikes--; - } else { - cantDisLikes--; - } - - // Si te estas preguntando por que esta parte de la cobertura esta en amarillo - // te comento que es porque al for siempre se entra al menos una vez, dado que - // si se esta en este bloque del if, significa que el usuario ya ha valorado el - // video, pero para no entrar al for, ningun usuario debe haberlo hecho. - // Con el if dentro del for sucede lo mismo, tarde o temprano encuentra al - // usuario que quiere modificar su valoracion - for (Valoracion val : valoraciones) { - if (val.modificar(dtValoracion, nickname)) { - try { - new ValoracionJpaController().edit(val); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - break; - } - } - } else { - Valoracion nuevaValoracion = new Valoracion(dtValoracion.getVal(), usuario); - new ValoracionJpaController().create(nuevaValoracion); - valoraciones.add(nuevaValoracion); - } - - // segun cual sea la nueva valoracion, suma 1 al contador - if (dtValoracion.getVal() == TipoValoracion.LIKE) { - cantLikes++; - } else { - cantDisLikes++; - } - } - - public DtVideo getDt(){ - return new DtVideo(this.id, this.nombre, this.descripcion, this.duracion, this.fechaPublicacion, this.urlVideoOriginal, this.privacidad, this.categoria, this.cantLikes, this.cantDisLikes); - } - - public ArrayList<DtComentario> listarComentarios(){ - ArrayList<DtComentario> listaComent = new ArrayList<DtComentario>(); - // recorro los comentarios sobre el video - for (Map.Entry<Integer, Comentario> coment : comentarios.entrySet()) { - // le obtengo el DT y lo agrego a la lista resultado - listaComent.add(coment.getValue().getDT()); - // agrego a la lista resultado, la lista de sub comentarios - listaComent.addAll(coment.getValue().listarSubComentarios()); - } - return listaComent; - } - - public ArrayList<DtValoracion> listarValoraciones(){ - ArrayList<DtValoracion> listaValoraciones = new ArrayList(); - // recorre todo el array de valoraciones - for(int i = 0; i < this.valoraciones.size(); i++){ - // para cada elemento le pide el DT (al llamar esa funcion es que hace el new) y lo agrega a la coleccion de retorno - listaValoraciones.add(this.valoraciones.get(i).getDT()); - } - return listaValoraciones; - } - - public void modificar(DtVideo dtVideo){ - if(dtVideo == null){ - throw new RuntimeException("El DtVideo es vacÃo"); - } - // Perdon julio pero no entendi nada xD - - if(dtVideo.getNombre()== ""){ - throw new RuntimeException("El nombre no puede ser vacÃo"); - } - - if (dtVideo.getDuracion()== null) { - throw new RuntimeException("La duracion no puede ser vacÃa"); - } - - if (dtVideo.getFechaPublicacion() == null) { - throw new RuntimeException("La fecha no puede ser vacÃa"); - } - - if (dtVideo.getCategoria() == "") { - throw new RuntimeException("La categoria no puede ser vacÃa"); - } - - this.nombre = dtVideo.getNombre(); - this.descripcion = dtVideo.getDescripcion(); - this.duracion = dtVideo.getDuracion(); - this.fechaPublicacion = dtVideo.getFechaPublicacion(); - this.privacidad = dtVideo.getPrivacidad(); - this.categoria = dtVideo.getCategoria(); - this.urlVideoOriginal = dtVideo.getUrlVideoOriginal(); - } - - /* Obtiene la valoracion que hizo un usuario */ - public DtValoracion obtenerValoracion(String nickname) { - if (nickname.equals("")) { - throw new RuntimeException("El nickname no puede ser vacio"); - } - for(int i = 0; i < this.valoraciones.size(); i++){ - if( valoraciones.get(i).getNicknameDeUsuario() == nickname){ - return valoraciones.get(i).getDT(); - } - } - return null; - } - - public void quitarValoracion(String nickname){ - if (nickname.equals("")){ - throw new RuntimeException("El nickname no puede ser vacio"); - } - // Recorrer todas las valoraciones hasta encontrar la valoracion cuyo usuario sea el que tiene ese nickname - // cuando la encuentre, la saca de la coleccion - - for(int i = 0; i < this.valoraciones.size(); i++){ - if(valoraciones.get(i).getNicknameDeUsuario().equals(nickname) ){ - - // segun cual fuera la valoracion anterior, resta 1 al contador - if (valoraciones.get(i).getVal() == TipoValoracion.LIKE) { - cantLikes--; - } else { - cantDisLikes--; - } - - // remueve de la coleccion - Valoracion borrada = valoraciones.remove(i); - try { - new ValoracionJpaController().destroy(borrada.getId()); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - break; - } - - } - } - - -//============================ Get and Set ================================ - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getNombre() { - return nombre; - } - - public void setNombre(String nombre) { - this.nombre = nombre; - } - - public String getDescripcion() { - return descripcion; - } - - public void setDescripcion(String descripcion) { - this.descripcion = descripcion; - } - - public Time getDuracion() { - return duracion; - } - - public void setDuracion(Time duracion) { - this.duracion = duracion; - } - - public Date getFechaPublicacion() { - return fechaPublicacion; - } - - public void setFechaPublicacion(Date fechaPublicacion) { - this.fechaPublicacion = fechaPublicacion; - } - - public String getUrlVideoOriginal() { - return urlVideoOriginal; - } - - public void setUrlVideoOriginal(String urlVideoOriginal) { - this.urlVideoOriginal = urlVideoOriginal; - } - - public Privacidad getPrivacidad() { - return privacidad; - } - - public void setPrivacidad(Privacidad privacidad) { - this.privacidad = privacidad; - } - - public String getCategoria() { - return categoria; - } - - public void setCategoria(String categoria) { - this.categoria = categoria; - } - - public int getCantLikes() { - return cantLikes; - } - - public void setCantLikes(int cantLikes) { - this.cantLikes = cantLikes; - } - - public int getCantDisLikes() { - return cantDisLikes; - } - - public void setCantDisLikes(int cantDisLikes) { - this.cantDisLikes = cantDisLikes; - } - - @Override - public String toString() { - return "Video{" + "id=" + id + ", nombre=" + nombre + ", descripcion=" + descripcion + ", duracion=" + duracion + ", fechaPublicacion=" + fechaPublicacion + ", urlVideoOriginal=" + urlVideoOriginal + ", privacidad=" + privacidad + ", categoria=" + categoria + ", cantLikes=" + cantLikes + ", cantDisLikes=" + cantDisLikes + '}'; - } - - - - -} diff --git a/UyTube_aplicacion/src/Logica/Controladores/CAdmin.java b/UyTube_aplicacion/src/Logica/Controladores/CAdmin.java deleted file mode 100644 index ae1e57e788a9d173b3983a0423fd56560cccf288..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Controladores/CAdmin.java +++ /dev/null @@ -1,982 +0,0 @@ -package Logica.Controladores; - -// Interfaz que se realizara -import JPAControllerClasses.AdministradorJpaController; -import JPAControllerClasses.CategoriaJpaController; -import JPAControllerClasses.ListaPorDefectoJpaController; -import JPAControllerClasses.UsuarioJpaController; -import Logica.Interfaces.IAdmin; -// DataTypes -import Logica.DataType.*; -// Clases necesarias -import Logica.Clases.Administrador; -import Logica.Clases.Usuario; -import Logica.Clases.Categoria; -import Logica.Clases.ListaPorDefecto; -import Logica.DatosDePrueba; -// Colecciones -import java.util.Map; -import java.util.TreeMap; -import java.util.ArrayList; -import java.util.List; - - -public class CAdmin implements IAdmin{ - private static CAdmin instancia = null; - private Map<String, Usuario> usuarios; - private Map<Integer, Administrador> administradores; - private Map<String, Categoria> categorias; - private Map<String, ListaPorDefecto> listasPorDefecto; - private Usuario usuarioActual; - private Usuario usuarioSeleccionado; - private int idListaSeleccionada; - private int idVideoSeleccionado; - - - private CAdmin(){ - this.usuarios = new TreeMap(String.CASE_INSENSITIVE_ORDER); - this.administradores = new TreeMap(); - this.categorias = new TreeMap(); - this.listasPorDefecto = new TreeMap(); - this.usuarioActual = null; - this.usuarioSeleccionado = null; - this.idListaSeleccionada = 0; - this.idVideoSeleccionado = 0; - - // si la categoria no esta en la BDD, la crea - if ( ! existeCategoria("UNDEFINED")){ - this.altaCategoria("UNDEFINED"); - } - - sincronizarAdministradoresConBDD(); - sincronizarCategoriasConBDD(); - sincronizarListasPorDefectoConBDD(); - sincronizarUsuariosConBDD(); - - // si en la BDD no hay administrador, lo crea - if (this.administradores.isEmpty()) { - // Administrador por defecto (temporal) - Administrador root = new Administrador(0, "admin", "administrador", "root"); - try { - new AdministradorJpaController().create(root); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - this.administradores.put(root.getIdAdmin(), root); - } - } - - public static CAdmin getInstancia(){ - if( instancia == null ){ - instancia = new CAdmin(); - } - return instancia; - } - - private void sincronizarUsuariosConBDD(){ - this.usuarios = new TreeMap(String.CASE_INSENSITIVE_ORDER); - try { - List<Usuario> usuariosEnBDD = new UsuarioJpaController().findUsuarioEntities(); - for (Usuario u : usuariosEnBDD){ - // si en BDD hay algo que no este en memoria - if ( ! this.usuarios.containsKey(u.getNickname())){ - this.usuarios.put(u.getNickname(), u); - } - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - private void sincronizarAdministradoresConBDD(){ - this.administradores = new TreeMap(); - try { - List<Administrador> administradoresEnBDD = new AdministradorJpaController().findAdministradorEntities(); - for (Administrador a : administradoresEnBDD){ - // si en BDD hay algo que no este en memoria - if ( ! this.administradores.containsKey(a.getIdAdmin())){ - this.administradores.put(a.getIdAdmin(), a); - } - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - private void sincronizarCategoriasConBDD(){ - this.categorias = new TreeMap(); - try { - List<Categoria> categoriasEnBDD = new CategoriaJpaController().findCategoriaEntities(); - for (Categoria c : categoriasEnBDD){ - // si en BDD hay algo que no este en memoria - if ( ! this.categorias.containsKey(c.getNombre())){ - this.categorias.put(c.getNombre(), c); - } - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - private void sincronizarListasPorDefectoConBDD(){ - this.listasPorDefecto = new TreeMap(); - try { - List<ListaPorDefecto> listasPorDefectoEnBDD = new ListaPorDefectoJpaController().findListaPorDefectoEntities(); - for (ListaPorDefecto l : listasPorDefectoEnBDD){ - // si en BDD hay algo que no este en memoria - if ( ! this.listasPorDefecto.containsKey(l.getNombre())){ - this.listasPorDefecto.put(l.getNombre(), l); - } - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - // //////////////////////////////////////////////////////////////////////////////////////// - public void agregarVideoAListaDeReproduccion(int idLista){ - /** - * Agrega el video idVideoSeleccionado a la lista idListaSeleccionada - */ - if (usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (usuarioActual == null){ - throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - if (idLista == 0){ - throw new RuntimeException("El ID de la lista de reproduccion no es valido"); - } - usuarioActual.agregarVideoALista(idLista, idVideoSeleccionado, usuarioSeleccionado); - } - - public void altaCategoria(String categoria){ - /** - * Crea la categoria con el nombre indicado - */ - if (categoria.equals("")){ - throw new RuntimeException("El nombre de la categoria no puede ser vacio"); - } - if (existeCategoria(categoria)){ - throw new RuntimeException("El sistema ya posee una categoria con ese nombre"); - } - Categoria cat = new Categoria(categoria); - categorias.put(cat.getNombre(), cat); - try { - new CategoriaJpaController().create(cat); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - public void altaComentario(DtComentario dtCom){ - /** - * Comenta el video idVideoSeleccionado a nombre de usuarioActual - */ - if (usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (usuarioActual == null){ - throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); - } - if (dtCom == null){ - throw new RuntimeException("El DataType comentario no puede ser null"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - usuarioSeleccionado.agregarComentarioAVideo(idVideoSeleccionado, dtCom, usuarioActual); - } - - public void altaComentario(DtComentario dtCom, int idComPadre){ - /** - * Comenta el comentario con dicho ID a nombre de usuarioActual - */ - if (usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (usuarioActual == null){ - throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); - } - if (dtCom == null){ - throw new RuntimeException("El DataType comentario no puede ser null"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - usuarioSeleccionado.agregarComentarioAVideo(idVideoSeleccionado, idComPadre, dtCom, usuarioActual); - } - - public void altaListaDeReproduccionParticular(DtListaDeReproduccion lista) { - /** - * Crea la lista de reproduccion para usuarioSeleccionado - */ - if (usuarioSeleccionado == null) { - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (lista == null) { - throw new RuntimeException("El DataType recibido es null"); - } - if (!existeCategoria(lista.getCategoria())) { - throw new RuntimeException("La categoria no existe"); - } - usuarioSeleccionado.agregarListaParticular(lista); - } - - public void altaListaDeReproduccionPorDefecto(DtListaDeReproduccion lista){ - /** - * Crea la lista de reproduccion para todos los usuarios del sistema y - * la agrega listas por defecto (para que se creen al crear un usuario nuevo) - */ - if (lista == null){ - throw new RuntimeException("El DataType lista de reproduccion no puede ser null"); - } - if (lista.getNombre().equals("")){ - throw new RuntimeException("El nombre de la nueva lista de reproduccion por defecto no puede ser vacio"); - } - if (listasPorDefecto.containsKey(lista.getNombre())){ - throw new RuntimeException("El sistema ya posee una lista de reproduccion por defecto con ese nombre"); - } - ListaPorDefecto lpd = new ListaPorDefecto(lista.getNombre()); - try { - new ListaPorDefectoJpaController().create(lpd); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - listasPorDefecto.put(lista.getNombre(), lpd); - ArrayList<String> nuevaLista = new ArrayList(); - nuevaLista.add(lista.getNombre()); - for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ - u.getValue().actualizarListasPorDefecto(nuevaLista); - } - } - - public void altaUsuarioCanal(DtUsuario usr, DtCanal canal){ - /** - * Crea un usuario y su canal a partir de los datos recibidos - */ - if (usr == null){ - throw new RuntimeException("El DataType usuario no puede ser null"); - } - if (canal == null){ - throw new RuntimeException("El DataType canal no puede ser null"); - } - if (existeNickname(usr.getNickname())){ - throw new RuntimeException("El sistema ya tiene un usuario con ese nickname"); - } - if (existeEmail(usr.getCorreo())){ - throw new RuntimeException("El sistema ya tiene un usuario con ese correo"); - } - - ArrayList<String> listasDefault = new ArrayList(); - for (Map.Entry<String, ListaPorDefecto> lpd : listasPorDefecto.entrySet()) { - listasDefault.add(lpd.getKey()); - } - - Usuario nuevoUsuario = new Usuario( - usr.getNickname(), - usr.getCorreo(), - usr.getFechaNacimiento(), - usr.getImagen(), - usr.getContrasenia(), - usr.getNombre(), - usr.getApellido(), - canal - ); - try { - new UsuarioJpaController().create(nuevoUsuario); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - nuevoUsuario.actualizarListasPorDefecto(listasDefault); - usuarios.put(nuevoUsuario.getNickname(), nuevoUsuario); - } - - public void altaValoracion(DtValoracion val){ - /** - Se ingresa la nueva valoracion dada por usuarioActual al video idVideoSeleccionado - Si el usuario ya habia valorado, se actualiza la valoracion dada - */ - if (usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (usuarioActual == null){ - throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - if (val == null){ - usuarioSeleccionado.quitarValoracion(idVideoSeleccionado, usuarioActual.getNickname()); - }else{ - usuarioSeleccionado.agregarModificarValoracionDeVideo(idVideoSeleccionado, val, usuarioActual); - } - } - - public void altaVideo(DtVideo video){ - /** - * Se crea un video nuevo en el canal de usuarioSeleccionado - */ - if (usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (video == null){ - throw new RuntimeException("El DataType video no puede ser null"); - } - if ( ! existeCategoria(video.getCategoria())){ - throw new RuntimeException("La categoria no existe"); - } - usuarioSeleccionado.agregarVideoACanal(video); - } - - public void bajaUsuario(){ - /** - * Elimina el usuario actual seleccionado - */ - /** - * Este algoritmo debe: - * Quitar las relaciones con usuarios seguidos y de seguidores - * Quitar los videos del usuario a eliminar de las listas de otros usuarios. - * Quitar comentarios en los videos del usuario a eliminar - * Quitar valoraciones en los videos del usuario a eliminar - * Quitar las valoraciones dadas por el usuario de todos los videos del sistema - * Quitar los comentarios hechos por el usuario de todos los videos del sistema - * - */ - - Usuario elim = usuarioActual; - - // * Quitar las relaciones con usuarios seguidos y de seguidores - // El usuario que se va a eliminar deja de seguir a todos los que sigue - ArrayList<DtUsuario> seguidos = usuarioActual.listarUsuariosSeguidos(); - for (DtUsuario u : seguidos) { - this.seleccionarUsuario(u.getNickname()); - this.seguirUsuario(); - } - this.liberarMemoriaUsuario(); - - // Todos los usuarios que siguen al que se va a eliminar, lo dejan de seguir - ArrayList<DtUsuario> seguidores = usuarioActual.listarUsuariosSeguidores(); - this.seleccionarUsuario(usuarioActual.getNickname()); - for (DtUsuario u : seguidores) { - this.seleccionarUsuarioActual(u.getNickname()); - this.seguirUsuario(); - } - this.liberarMemoriaUsuario(); - this.seleccionarUsuarioActual(elim.getNickname()); - - // para cada usuario del sistema, recorro todas sus listas y en cada - // una manda a quitar todoslos videos del usuario a eliminar - this.seleccionarUsuario(elim.getNickname()); - ArrayList<DtVideo> videos = this.listarVideosDeUsuario(); - // Para facilitar el algoritmo, agrego a la coleccion (de manera provisoria) los usuarios eliminados - // ¡Recuerdo los nicknames para sacarlos despues! - ArrayList<String> nicksProvisorios = new ArrayList(); - try { - for (Usuario u : new UsuarioJpaController().findUsuarioEliminadoEntities()){ - nicksProvisorios.add(u.getNickname()); - this.usuarios.put(u.getNickname(), u); - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - - for (Map.Entry<String, Usuario> it : usuarios.entrySet()){ - if (it.getValue().getNickname().equals(elim.getNickname())) continue; - - // * Quitar los videos del usuario a eliminar de las listas de otros usuarios. - ArrayList<DtListaDeReproduccion> listas = it.getValue().listarListasDeReproduccionDeCanal(false); - for (DtListaDeReproduccion l : listas){ - for (DtVideo v : videos){ - it.getValue().quitarVideoDeListaDeReproduccion(l.getId(), v.getId()); - } - } - - // * Quitar las valoraciones dadas por el usuario de todos los videos del sistema - // * Quitar los comentarios hechos por el usuario de todos los videos del sistema - it.getValue().eliminarTodoRastroDelUsuario(elim.getNickname()); - try { - new UsuarioJpaController().edit(it.getValue()); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - // quito de la coleccion los usuarios que estaban eliminados y agregue provisoriamente antes del for - for (String s : nicksProvisorios){ - this.usuarios.remove(s); - } - - // obtiene la fecha actual - java.util.Date utilDate = new java.util.Date(); - java.sql.Date hoy = new java.sql.Date(utilDate.getTime()); - - // * Quitar comentarios en los videos del usuario a eliminar - // * Quitar valoraciones en los videos del usuario a eliminar - usuarioActual.eliminar(hoy); - try { - new UsuarioJpaController().edit(usuarioActual); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - this.usuarios.remove(elim.getNickname()); - } - - - public boolean existeCategoria(String cat){ - /** - * Verifica si existe una categoria con el nombre recibido - */ - sincronizarCategoriasConBDD(); - return categorias.containsKey(cat); - } - - public boolean existeEmail(String email){ - /** - * Verifica si existe un usuario con el mail recibido - */ - sincronizarUsuariosConBDD(); - for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ - if (u.getValue().getCorreo().equals(email)){ - return true; - } - } - for (DtUsuario dtu : this.listarUsuariosEliminados()){ - if (dtu.getCorreo().equals(email)){ - return true; - } - } - return false; - } - - public boolean existeNickname(String nickname){ - /** - * Verifica si existe un usuario con el nickname recibido - */ - sincronizarUsuariosConBDD(); - if (usuarios.containsKey(nickname)){ - return true; - } - for (DtUsuario dtu : this.listarUsuariosEliminados()){ - if (dtu.getNickname().equals(nickname)){ - return true; - } - } - return false; - } - - public boolean iniciarSesionAdministrador(int id, String pass){ - /** - * Verifica la contrasenia para el administrador con esa ID y devuelve true si es correcta - * En cualquier otro caso devuelve false - */ - sincronizarAdministradoresConBDD(); - Administrador a = administradores.get(id); - if (a == null){ - return false; - } - return a.validarContrasenia(pass); - } - - public boolean iniciarSesionUsuario(String nickname, String pass){ - sincronizarUsuariosConBDD(); - Usuario u = usuarios.get(nickname); - if (u == null){ - return false; - } - boolean ok = u.validarContrasenia(pass); - if (ok){ - usuarioActual = u; - } - return ok; - } - - public void liberarMemoriaListaDeReproduccion(){ - idListaSeleccionada = 0; - } - - public void liberarMemoriaUsuario(){ - usuarioSeleccionado = null; - } - - public void liberarMemoriaUsuarioActual(){ - usuarioActual = null; - } - - public void liberarMemoriaVideo(){ - idVideoSeleccionado = 0; - } - - public ArrayList<String> listarCategorias(){ - /** - * Devuelve todas las categorias existentes en el sistema - */ - sincronizarCategoriasConBDD(); - ArrayList<String> ret = new ArrayList(); - for (Map.Entry<String, Categoria> c : categorias.entrySet()){ - ret.add(c.getValue().getNombre()); - } - return ret; - } - - public ArrayList<DtComentario> listarComentariosDeVideo(){ - /** - * Devuelve en forma ordenada (recursiva ) todos los comentarios de idVideoSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - return usuarioSeleccionado.listarComentariosDeVideo(idVideoSeleccionado); - } - - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionEnCategoria(String cat){ - /** - * Devuelve todos las listas de reproduccion del sistema que pertenezcan a la categoria indicada - */ - if (cat.equals("")){ - throw new RuntimeException("La categoria no puede ser vacia"); - } - sincronizarUsuariosConBDD(); - sincronizarCategoriasConBDD(); - ArrayList<DtListaDeReproduccion> ret = new ArrayList(); - for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ - ret.addAll(u.getValue().obtenerListasEnCategoria(cat)); - } - return ret; - } - - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeUsuario(String nickname){ - /** - * Devuelve todas las listas de reproduccion de usuarioSeleccionado o de usuarioActual segun el nickname indicado - */ - if (nickname.equals("")){ - throw new RuntimeException("El nickname del usuario no puede ser vacio"); - } - if (usuarioActual == null && usuarioSeleccionado == null){ - throw new RuntimeException("No hay usuarios seleccionados"); - } - - if (usuarioActual != null && usuarioActual.getNickname().equals(nickname)){ - return usuarioActual.listarListasDeReproduccionDeCanal(false); - } - if (usuarioSeleccionado != null && usuarioSeleccionado.getNickname().equals(nickname)){ - return usuarioSeleccionado.listarListasDeReproduccionDeCanal(false); - } - throw new RuntimeException("El nickname no coincide con los posibles usuarios seleccionados"); - } - - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionParticularesDeUsuario(){ - /** - * Devuelve las listas de reproduccion particulares de usuarioSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - return usuarioSeleccionado.listarListasDeReproduccionDeCanal(true); - } - - public ArrayList<DtUsuario> listarUsuarioSeguidores(){ - /** - * Devuelve todos los usuarios que siguen a usuarioSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - return usuarioSeleccionado.listarUsuariosSeguidores(); - } - - public ArrayList<DtUsuario> listarUsuarioNoSeguidos(){ - /** - * Devuelve todos los usuarios a quienes sigue usuarioSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - // creo el array de retorno y obtengo la lista de usuarios seguidos - ArrayList<DtUsuario> noSeguidos = new ArrayList(); - ArrayList<DtUsuario> seguidos = listarUsuarioSeguidos(); - // para saber si hay que agregar a la lista de retorno o no - boolean agregar; - - // no quiero que incluya al usuario seleccinado, asi que lo agrego para excluirlo - seguidos.add(usuarioSeleccionado.getDT()); - - // rrecorro los usuarios del sistema - for (Map.Entry<String, Usuario> u : usuarios.entrySet()) { - agregar = true; - // recorro los usuarios seguidos para ver si debo agregar a u al array de retorno - for (DtUsuario uSegido : seguidos){ - // si encuentra coincidencia, no debo agregarlo ya que es un usuario seguido - if (u.getKey().equals(uSegido.getNickname())){ - // lo saco del array para ahorrar procesamiento - seguidos.remove(uSegido); - agregar = false; - break; - } - } - if (agregar){ - noSeguidos.add(u.getValue().getDT()); - } - } - return noSeguidos; - } - - public ArrayList<DtUsuario> listarUsuarioSeguidos(){ - /** - * Devuelve todos los usuarios a quienes sigue usuarioSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - return usuarioSeleccionado.listarUsuariosSeguidos(); - } - - public ArrayList<DtUsuario> listarUsuarios(){ - /** - * Devuelve todos los datos de todos los usuarios - */ - sincronizarUsuariosConBDD(); - ArrayList<DtUsuario> ret = new ArrayList<>(); - for (Map.Entry<String, Usuario> usuario : usuarios.entrySet()) { - ret.add(usuario.getValue().getDT()); - } - return ret; - } - - public ArrayList<DtUsuario> listarUsuariosEliminados(){ - /** - * Devuelve todos los datos de todos los usuarios eliminados - */ - ArrayList<DtUsuario> ret = new ArrayList(); - try { - for (Usuario u : new UsuarioJpaController().findUsuarioEliminadoEntities()){ - ret.add(u.getDT()); - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - return ret; - } - - public ArrayList<DtVideo> listarVideosEnCategoria(String cat){ - /** - * Devuelve todos los videos del sistema que pertenezcan a la categoria indicada - */ - if (cat.equals("")){ - throw new RuntimeException("La categoria no puede ser vacia"); - } - sincronizarUsuariosConBDD(); - sincronizarCategoriasConBDD(); - ArrayList<DtVideo> ret = new ArrayList(); - for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ - ret.addAll(u.getValue().obtenerVideosEnCategoria(cat)); - } - return ret; - } - - public ArrayList<DtVideo> listarVideosDeUsuario(){ - /** - * Devuelve todos los videos de usuarioSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - return usuarioSeleccionado.listarVideosDeCanal(); - } - - public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(){ - /** - * Devuelve los videos de la lista de reproduccion idListaSeleccionada - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idListaSeleccionada == 0){ - throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionado"); - } - return usuarioSeleccionado.listarVideosDeListaDeReproduccion(idListaSeleccionada); - } - - public void modificarListaDeReproduccion(DtListaDeReproduccion lista){ - /** - * Se modifican los datos de la lista idListaSeleccionada - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idListaSeleccionada == 0){ - throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionado"); - } - if (lista == null){ - throw new RuntimeException("El DataType recibido es null"); - } - if ( ! existeCategoria(lista.getCategoria())){ - throw new RuntimeException("La categoria no existe"); - } - // no confio en que el DataType recibido venga con el id del video correcto, - // asi que creo otro y con el idVideoSeleccionado por las dudas - DtListaDeReproduccion dtl = new DtListaDeReproduccion( - idListaSeleccionada, - lista.getNombre(), - lista.getPrivacidad(), - lista.getTipo(), - lista.getCategoria()); - usuarioSeleccionado.modificarListaDeReproduccionDeCanal(dtl); - } - - public void modificarUsuarioYCanal(DtUsuario usr,DtCanal canal){ - /** - * Se modifican los datos de usuarioActual y su canal - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (usr == null){ - throw new RuntimeException("El DataType usuario no puede ser null"); - } - if (canal == null){ - throw new RuntimeException("El DataType canal no puede ser null"); - } - usuarioSeleccionado.modificar(usr, canal); - try { - new UsuarioJpaController().edit(usuarioSeleccionado); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - public void modificarVideo(DtVideo video){ - /** - * Se modifican los datos del video idVideoSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - if (video == null){ - throw new RuntimeException("El DataType video no puede ser null"); - } - if ( ! existeCategoria(video.getCategoria())){ - throw new RuntimeException("La categoria no existe"); - } - // no confio en que el DataType recibido venga con el id del video correcto, - // asi que creo otro y con el idVideoSeleccionado por las dudas - DtVideo dtv = new DtVideo( - idVideoSeleccionado, - video.getNombre(), - video.getDescripcion(), - video.getDuracion(), - video.getFechaPublicacion(), - video.getUrlVideoOriginal(), - video.getPrivacidad(), - video.getCategoria(), - 0, 0); - - usuarioSeleccionado.modificarVideoDeCanal(dtv); - } - - public DtUsuario obtenerPropietarioDeVideo(int idVideo){ - /** - * Busca entre todos los usuarios al propietario del video con ese ID - */ - - sincronizarUsuariosConBDD(); - // Esto es un parche, pero de los que nunca se despegan... - // A tiempos desesperados, medidas desesperadas - for (Map.Entry<String, Usuario> u : usuarios.entrySet()){ - try { - u.getValue().obtenerVideo(idVideo); - return u.getValue().getDT(); - } catch (Exception e) { - // a seguir buscando - } - } - throw new RuntimeException("El iID de video no crresponde a ningun usuario"); - } - - public DtCanal obtenerCanalDeUsuario(){ - /** - * Devuelve los datos del canal del usuario en memoria usuarioSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - return usuarioSeleccionado.obtenerCanal(); - } - - public ArrayList<DtValoracion> obtenerValoracionesDeVideo(){ - /** - * Devuelve las valoraciones de idVideoSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - return usuarioSeleccionado.listarValoracionesDeVideo(idVideoSeleccionado); - } - - public DtValoracion obtenerValoracionDada(){ - /** - * Devuelve la valoracion dada por usuarioActual al video idVideoSeleccionado - * - */ - if (this.usuarioActual == null) { - throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); - } - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - // si la funcion retorna null, significa que el usuario no lo ha valorado. Entonces no se considera error - return usuarioSeleccionado.obtenerValoracion(idVideoSeleccionado, usuarioActual.getNickname()); - } - - public void quitarVideoDeListaDeReproduccion(int idVideo){ - /** - * Quita el video idVideoSeleccionado de la lista idListaSeleccionada - */ - if (usuarioSeleccionado == null) { - throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); - } - if (idListaSeleccionada == 0){ - throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionado"); - } - if (idVideo == 0){ - throw new RuntimeException("El ID de video no es valido"); - } - usuarioSeleccionado.quitarVideoDeListaDeReproduccion(idListaSeleccionada, idVideo); - } - - public DtUsuario seleccionarUsuario(String nickname){ - /** - * El sistema recuerda un link al usuario como usuarioSeleccionado - * Devuelve los datos de usuarioSeleccionado - */ - sincronizarUsuariosConBDD(); - usuarioSeleccionado = usuarios.get(nickname); - if (usuarioSeleccionado == null){ - throw new RuntimeException("No se encontro ningun usuario con ese nickname"); - } - return usuarioSeleccionado.getDT(); - } - - public DtUsuario seleccionarUsuarioEliminado(String nickname){ - /** - * El sistema recuerda un link al usuario eliminado como usuarioActual Devuelve - * los datos de usuarioActual - */ - try { - usuarioSeleccionado = new UsuarioJpaController().findUsuario(nickname); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - if (usuarioSeleccionado == null){ - throw new RuntimeException("No se encontro ningun usuario con ese nickname"); - } - return usuarioSeleccionado.getDT(); - } - - public DtUsuario seleccionarUsuarioActual(String nickname){ - /** - * El sistema recuerda un link al usuario como usuarioActual Devuelve - * los datos de usuarioActual - */ - sincronizarUsuariosConBDD(); - usuarioActual = usuarios.get(nickname); - if (usuarioActual == null){ - throw new RuntimeException("No se encontro ningun usuario con ese nickname"); - } - return usuarioActual.getDT(); - } - - public DtVideo seleccionarVideo(int idVideo){ - /** - El sistema recuerda el ID del video como idVideoSeleccionado Devuelve - * los datos del video seleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - DtVideo ret = usuarioSeleccionado.obtenerVideoDeCanal(idVideo); - idVideoSeleccionado = idVideo; - return ret; - } - - public DtListaDeReproduccion seleccionarListaDeReproduccion(int idLista){ - /** - * El sistema recuerda el ID de la lista como idListaSeleccionada - * Devuelve los datos de la lista de reproduccion seleccionada perteneciente a usuarioSeleccionado - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - DtListaDeReproduccion ret = usuarioSeleccionado.obtenerListaDeReproduccion(idLista); - idListaSeleccionada = idLista; - return ret; - } - - public void seguirUsuario(){ - /** - * El usuario usuarioActual comienza a seguir a usuarioSeleccionado En - * caso de que este ya lo este siguiendo, lo deja de seguir - */ - if (this.usuarioActual == null) { - throw new RuntimeException("El sistema no tiene un usuario actual seleccionado"); - } - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - usuarioActual.agregarOQuitarSeguido(usuarioSeleccionado); - try { - new UsuarioJpaController().edit(usuarioSeleccionado); - new UsuarioJpaController().edit(usuarioActual); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - public boolean validarNuevaListaParticular(String nombre){ - /** - * Devuelve false si usuarioSeleccionado posee una lista de reproducion con ese nombre - */ - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - sincronizarListasPorDefectoConBDD(); - if (listasPorDefecto.containsKey(nombre)) { - return false; - } - return usuarioSeleccionado.validarListaParticular(nombre); - } - - public boolean validarNuevaListaPorDefecto(String nombre){ - /** - * Devuelve false si existe algun usuario en el sistema que posea una - * lista de reproduccion con ese nombre - */ - sincronizarListasPorDefectoConBDD(); - sincronizarUsuariosConBDD(); - if (listasPorDefecto.containsKey(nombre)) { - return false; - } - for (Map.Entry<String, Usuario> u : this.usuarios.entrySet()){ - if ( ! u.getValue().validarListaParticular(nombre)){ - return false; - } - } - return true; - } -} - diff --git a/UyTube_aplicacion/src/Logica/Controladores/CUsuario.java b/UyTube_aplicacion/src/Logica/Controladores/CUsuario.java deleted file mode 100644 index d1afc0a86edb837fcb6c10747f7543e544c7d83c..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Controladores/CUsuario.java +++ /dev/null @@ -1,823 +0,0 @@ -package Logica.Controladores; - -import JPAControllerClasses.BusquedaEnBDD; -import JPAControllerClasses.CategoriaJpaController; -import JPAControllerClasses.ListaPorDefectoJpaController; -import JPAControllerClasses.UsuarioJpaController; -import Logica.Clases.Categoria; -import Logica.Clases.ListaPorDefecto; -import Logica.Clases.Usuario; -import Logica.Clases.Video; -import Logica.DataType.DtCanal; -import Logica.DataType.DtComentario; -import Logica.DataType.DtListaDeReproduccion; -import Logica.DataType.DtUsuario; -import Logica.DataType.DtValoracion; -import Logica.DataType.DtVideo; -import Logica.Enumerados.Filtrado; -import Logica.Enumerados.Ordenacion; -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoListaDeReproduccion; -import Logica.Fabrica; -import Logica.Interfaces.IAdmin; -import Logica.Interfaces.IUsuario; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -public class CUsuario implements IUsuario { - private static CUsuario instancia = null; - private Usuario usuarioActual; - private Usuario usuarioSeleccionado; - private int idListaSeleccionada; - private int idVideoSeleccionado; - - private CUsuario() { - this.usuarioActual = null; - this.usuarioSeleccionado = null; - this.idListaSeleccionada = 0; - this.idVideoSeleccionado = 0; - } - public static CUsuario getInstancia() { - if (instancia == null) { - instancia = new CUsuario(); - } - return instancia; - } - - //***************** Traer datos de la base de datos ******************* - /** - * Lista los usuarios no eliminados desde la base de datos - * @return Mapa de usuarios indexados por nickname - */ - private Map<String, Usuario> obtenerUsuarios(){ - Map<String, Usuario> usuarios = new TreeMap(); - try { - List<Usuario> usuariosEnBDD = new UsuarioJpaController().findUsuarioEntities(); - for (Usuario u : usuariosEnBDD){ - usuarios.put(u.getNickname(), u); - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - return usuarios; - } - - /** - * Lista las categorias desde la base de datos - * @return Mapa de categorias indexados por nombre - */ - private Map<String, Categoria> obtenerCategorias(){ - Map<String, Categoria> categorias = new TreeMap(); - try { - List<Categoria> categoriasEnBDD = new CategoriaJpaController().findCategoriaEntities(); - for (Categoria c : categoriasEnBDD){ - categorias.put(c.getNombre(), c); - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - return categorias; - } - - /** - * Lista los nombres de las listas por defecto desde la base de datos - * @return Mapa de listas por defecto indexados por nombre - */ - private Map<String, ListaPorDefecto> obtenerListasPorDefecto(){ - Map<String, ListaPorDefecto> ListasPorDefecto = new TreeMap(); - try { - List<ListaPorDefecto> listasPorDefectoEnBDD = new ListaPorDefectoJpaController().findListaPorDefectoEntities(); - for (ListaPorDefecto l : listasPorDefectoEnBDD){ - ListasPorDefecto.put(l.getNombre(), l); - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - return ListasPorDefecto; - } - - //******************** Funciones de la interfaz ************************ - @Override - public void agregarVideoAListaDeReproduccion(int idLista) { - if (usuarioActual == null){ - throw new RuntimeException("No se ha iniciado sesión"); - } - if (usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - if (idLista == 0){ - throw new RuntimeException("El ID de la lista de reproduccion no es valido"); - } - usuarioActual.agregarVideoALista(idLista, idVideoSeleccionado, usuarioSeleccionado); - } - - @Override - public void altaComentario(DtComentario dtCom) { - if (usuarioActual == null){ - throw new RuntimeException("No se ha iniciado sesión"); - } - if (usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (dtCom == null){ - throw new RuntimeException("El DataType comentario no puede ser null"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - usuarioSeleccionado.agregarComentarioAVideo(idVideoSeleccionado, dtCom, usuarioActual); - } - - @Override - public void altaComentario(DtComentario dtCom, int idComPadre) { - if (usuarioActual == null){ - throw new RuntimeException("No se ha iniciado sesión"); - } - if (usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (dtCom == null){ - throw new RuntimeException("El DataType comentario no puede ser null"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - usuarioSeleccionado.agregarComentarioAVideo(idVideoSeleccionado, idComPadre, dtCom, usuarioActual); - } - - @Override - public void altaListaDeReproduccionParticular(DtListaDeReproduccion lista) { - if (usuarioActual == null) { - throw new RuntimeException("No se ha iniciado sesión"); - } - if (lista == null) { - throw new RuntimeException("El DataType recibido es null"); - } - if ( ! this.obtenerCategorias().containsKey(lista.getCategoria())) { - throw new RuntimeException("La categoria no existe"); - } - usuarioActual.agregarListaParticular(lista); - } - - @Override - public void altaUsuarioCanal(DtUsuario usr, DtCanal canal) { - // valida datos recibidos - if (usr == null){ - throw new RuntimeException("El DataType usuario no puede ser null"); - } - if (canal == null){ - throw new RuntimeException("El DataType canal no puede ser null"); - } - if (existeNickname(usr.getNickname())){ - throw new RuntimeException("El sistema ya tiene un usuario con ese nickname"); - } - if (existeEmail(usr.getCorreo())){ - throw new RuntimeException("El sistema ya tiene un usuario con ese correo"); - } - // obtiene las listas por defecto que el usuario debera crear - ArrayList<String> listasDefault = new ArrayList(); - for (Map.Entry<String, ListaPorDefecto> lpd : this.obtenerListasPorDefecto().entrySet()) { - listasDefault.add(lpd.getKey()); - } - // Crea al usuario - Usuario nuevoUsuario = new Usuario( - usr.getNickname(), - usr.getCorreo(), - usr.getFechaNacimiento(), - usr.getImagen(), - usr.getContrasenia(), - usr.getNombre(), - usr.getApellido(), - canal - ); - // persiste el usuario - try { - new UsuarioJpaController().create(nuevoUsuario); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - // Actualiza sus listas por defecto - nuevoUsuario.actualizarListasPorDefecto(listasDefault); - // Le inicia la sesion - this.iniciarSesionUsuario(usr.getNickname(), usr.getContrasenia()); - } - - @Override - public void altaVideo(DtVideo video) { - if(usuarioActual == null){ - throw new RuntimeException("No se a iniciado sesión"); - } - if (video == null) { - throw new RuntimeException("El video no puede ser null"); - } - if(!obtenerCategorias().containsKey(video.getCategoria())){ - throw new RuntimeException("La categoria no existe"); - } - usuarioActual.agregarVideoACanal(video); - } - - @Override - public void bajaUsuario() { - if(usuarioActual == null){ - throw new RuntimeException("No se a iniciado sesión"); - } - // Bienvenido al parche - // La verdad no sabia bien como implementar esta funcion, asi que mejor no reinventar la rueda, uso la que ya existe aunque implique llamar al otro controlador... - IAdmin ca = Fabrica.getInstancia().getIAdmin(); - ca.seleccionarUsuarioActual(usuarioActual.getNickname()); - cerrarSesion(); - ca.bajaUsuario(); - } - - @Override - public ArrayList<Object> buscar(String busqueda, Filtrado filtro, Ordenacion orden) { - //Cambiar la linea de abajo cuando se implemente la funcion de juan - // hecho - ArrayList<Object> ret = new BusquedaEnBDD().buscar(busqueda, filtro, orden); - - for (int i = 0; i < ret.size(); i++) { - - if (ret.get(i) instanceof DtVideo) { - DtVideo vid = (DtVideo) ret.get(i); - if (vid.getPrivacidad() == Privacidad.PRIVADO) { - try { - // Si el usuarioActual es null, o no posee un video con ese ID, se quita el elemento de la lista - this.usuarioActual.obtenerVideo(vid.getId()); - } catch (Exception e) { - ret.remove(i); - i--; - } - } - } else if (ret.get(i) instanceof DtListaDeReproduccion) { - DtListaDeReproduccion list = (DtListaDeReproduccion) ret.get(i); - if (list.getPrivacidad() == Privacidad.PRIVADO) { - if (list.getTipo() == TipoListaDeReproduccion.POR_DEFECTO) { - ret.remove(i); - i--; - } else { - try { - // Si el usuarioActual es null, o no posee una lista con ese ID, se quita el elemento de la lista - this.usuarioActual.obtenerListaDeReproduccion(list.getId()); - } catch (Exception e) { - ret.remove(i); - i--; - } - } - } - } else if (ret.get(i) instanceof DtCanal) { - DtCanal canal = (DtCanal) ret.get(i); - if (canal.getPrivacidad() == Privacidad.PRIVADO) { // Si el canal es privado... - if (sesionIniciada()) { // Si hay una sesion iniciada - if (this.usuarioActual.obtenerCanal().getId() != canal.getId()) { // si el canal no es el propio, se remueve - ret.remove(i); - i--; - } - // si no entro al if, el canal esprivado pero es propio, entonces no se quita - } else { // Si no hay una sesion iniciada, se quita el canal - ret.remove(i); - i--; - } - } - } - } - return ret; - } - - @Override - public ArrayList<Object> buscar(String categoria) { - //Cambiar la linea de abajo cuando se implemente la funcion de juan - // hecho - ArrayList<Object> ret = new BusquedaEnBDD().buscarPorCategoria(categoria); - - for (int i = 0; i < ret.size(); i++) { - - if (ret.get(i) instanceof DtVideo) { - DtVideo vid = (DtVideo) ret.get(i); - if (vid.getPrivacidad() == Privacidad.PRIVADO) { - try { - // Si el usuarioActual es null, o no posee un video con ese ID, se quita el elemento de la lista - this.usuarioActual.obtenerVideo(vid.getId()); - } catch (Exception e) { - ret.remove(i); - i--; - } - } - } else if (ret.get(i) instanceof DtListaDeReproduccion) { - DtListaDeReproduccion list = (DtListaDeReproduccion) ret.get(i); - if (list.getPrivacidad() == Privacidad.PRIVADO) { - if (list.getTipo() == TipoListaDeReproduccion.POR_DEFECTO) { - ret.remove(i); - i--; - } else { - try { - // Si el usuarioActual es null, o no posee una lista con ese ID, se quita el elemento de la lista - this.usuarioActual.obtenerListaDeReproduccion(list.getId()); - } catch (Exception e) { - ret.remove(i); - i--; - } - } - } - } - } - return ret; - } - - @Override - public void cerrarSesion() { - if(usuarioActual == null){ - throw new RuntimeException("No puedes cerrar sesión sin haberla iniciado"); - } - usuarioActual = null; - } - - - @Override - public boolean elUsuarioSeleccionadoEsElUsuarioActual(){ - if (usuarioActual == null || usuarioSeleccionado == null){ - return false; - } - return usuarioActual.getNickname().equals(usuarioSeleccionado.getNickname()); - } - - @Override - public boolean existeEmail(String email) { - if (email.equals("")){ - return false; - } - Map<String, Usuario> Usuarios = obtenerUsuarios(); - - for (Map.Entry<String, Usuario> u : Usuarios.entrySet()) { - if (u.getValue().getCorreo().equals(email)) { - return true; - } - } - - for (Usuario u : new UsuarioJpaController().findUsuarioEliminadoEntities()) { - if (u.getCorreo().equals(email)) { - return true; - } - } - return false; - } - - @Override - public boolean existeNickname(String nickname) { - if (nickname.equals("")){ - return false; - } - Map<String, Usuario> Usuarios = obtenerUsuarios(); - if (Usuarios.containsKey(nickname)) { - return true; - } - - for (Usuario u : new UsuarioJpaController().findUsuarioEliminadoEntities()) { - if (u.getNickname().equals(nickname)) { - return true; - } - } - return false; - } - - @Override - public boolean iniciarSesionUsuario(String nickOEmail, String contrasenia) { - if (usuarioActual != null){ - throw new RuntimeException("Ya hay un usuario con la sesión iniciada"); - } - Map<String, Usuario> usuarios = obtenerUsuarios(); - boolean usuarioEncontrado = false; - // Intenta obtener al usuario por nickname - usuarioActual = usuarios.get(nickOEmail); - if (usuarioActual == null){ // si NO lo encuentra por nickname - // Recorre todos los usuarios buscandolo por su correo - for (Map.Entry<String, Usuario> u : usuarios.entrySet()) { - // Si encuentra al usuario con ese correo - if (u.getValue().getCorreo().equals(nickOEmail)){ - usuarioActual = u.getValue(); - usuarioEncontrado = true; - break; - } - } - }else{ // si lo encuentra por nickname - usuarioEncontrado = true; - } - - if (usuarioEncontrado){ - if (usuarioActual.validarContrasenia(contrasenia)){ - return true; - }else{ - usuarioActual = null; - } - } - return false; - } - - @Override - public void liberarMemoriaListaDeReproduccion(){ - idListaSeleccionada = 0; - } - - @Override - public void liberarMemoriaUsuario(){ - usuarioSeleccionado = null; - } - - @Override - public void liberarMemoriaVideo(){ - idVideoSeleccionado = 0; - } - - @Override - public ArrayList<String> listarCategorias() { - Map<String, Categoria> categorias = obtenerCategorias(); - ArrayList<String> ret = new ArrayList<>(); - - for (Map.Entry<String, Categoria> entry : categorias.entrySet()) { - ret.add(entry.getKey()); - } - return ret; - } - - @Override - public ArrayList<DtComentario> listarComentariosDeVideo() { - if (this.usuarioSeleccionado == null) { - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - return usuarioSeleccionado.listarComentariosDeVideo(idVideoSeleccionado); - } - - @Override - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeUsuario(boolean incluirListasPorDefecto) { - if (this.usuarioSeleccionado == null) { - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - - ArrayList<DtListaDeReproduccion> ret = usuarioSeleccionado.listarListasDeReproduccionDeCanal(false); - - if (elUsuarioSeleccionadoEsElUsuarioActual()) { - // Se incluyen las privadas pero se quitan las POR_DEFECTO segun el parametro recibido - if (incluirListasPorDefecto) { - // se retorna todo - return ret; - } else { - // Se quitan las listas POR_DEFECTO - for (int i = 0; i < ret.size(); i++) { - if (ret.get(i).getTipo() == TipoListaDeReproduccion.POR_DEFECTO) { - ret.remove(i); - i--; - } - } - return ret; - } - } else { - // si no se ha iniciado sesion, o si se inicio sesion pero el usuarioSeleccionado no es el usuarioActual - // Solo se incluyen las listas Publicas, osea que se quitan todas las Privadas - for (int i = 0; i < ret.size(); i++) { - if (ret.get(i).getPrivacidad() == Privacidad.PRIVADO) { - ret.remove(i); - i--; - } - } - return ret; - } - } - - @Override - public ArrayList<DtUsuario> listarUsuarioSeguidores() { - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - return usuarioSeleccionado.listarUsuariosSeguidores(); - } - - @Override - public ArrayList<DtUsuario> listarUsuarioSeguidos() { - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - return usuarioSeleccionado.listarUsuariosSeguidos(); - } - - @Override - public ArrayList<DtUsuario> listarUsuarios() { - ArrayList<DtUsuario> ret = new ArrayList<>(); - for (Map.Entry<String, Usuario> usuario : obtenerUsuarios().entrySet()) { - ret.add(usuario.getValue().getDT()); - } - return ret; - } - - @Override - public ArrayList<DtVideo> listarVideosDeListaDeReproduccion() { - if (this.usuarioSeleccionado == null) { - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - ArrayList<DtVideo> ret = this.usuarioSeleccionado.listarVideosDeListaDeReproduccion(idListaSeleccionada); - if (elUsuarioSeleccionadoEsElUsuarioActual()) { - // incluye los videos privados si y solo si son del usuario actual - // dicho de otra manera: quita los videos privados que no son del usuarioActual - for (int i = 0; i < ret.size(); i++) { - if (ret.get(i).getPrivacidad() == Privacidad.PRIVADO) { - try { - this.usuarioActual.obtenerVideo(ret.get(i).getId()); - } catch (Exception e) { - ret.remove(i); - i--; - } - } - } - return ret; - } else { - // Se devuelven solo los videos Publicos - for (int i = 0; i < ret.size(); i++) { - if (ret.get(i).getPrivacidad() == Privacidad.PRIVADO) { - ret.remove(i); - i--; - } - } - return ret; - } - } - - @Override - public ArrayList<DtVideo> listarVideosDeUsuario() { - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - - if(elUsuarioSeleccionadoEsElUsuarioActual()){ - // se incluyen todos los videos - return usuarioSeleccionado.listarVideosDeCanal(); - }else{ - // Se quitan los videos privados - ArrayList<DtVideo> ret = this.usuarioSeleccionado.listarVideosDeCanal(); - for (int i = 0 ; i < ret.size(); i++) { - if(ret.get(i).getPrivacidad() == Privacidad.PRIVADO){ - ret.remove(i); - i--; - } - } - return ret; - } - } - - @Override - public void modificarListaDeReproduccion(DtListaDeReproduccion lista) { - /** - * Se modifican los datos de la lista idListaSeleccionada - */ - if (this.usuarioActual == null){ - throw new RuntimeException("No se ha iniciado sesión"); - } - if (idListaSeleccionada == 0){ - throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionado"); - } - if (lista == null){ - throw new RuntimeException("El DataType recibido es null"); - } - if (!this.obtenerCategorias().containsKey(lista.getCategoria())) { - throw new RuntimeException("La categoria no existe"); - } - // no confio en que el DataType recibido venga con el id del video correcto, - // asi que creo otro y con el idVideoSeleccionado por las dudas - DtListaDeReproduccion dtl = new DtListaDeReproduccion( - idListaSeleccionada, - lista.getNombre(), - lista.getPrivacidad(), - lista.getTipo(), - lista.getCategoria()); - usuarioActual.modificarListaDeReproduccionDeCanal(dtl); - } - - @Override - public void modificarUsuarioYCanal(DtUsuario usr, DtCanal canal) { - if (usuarioActual == null) { - throw new RuntimeException("No se a iniciado la sesión"); - } - if (usr == null) { - throw new RuntimeException("Todos los datos del Usuario no pueden ser vacios"); - } - if (canal == null) { - throw new RuntimeException("Todos los datos del Canal no pueden ser vacios"); - } - usuarioActual.modificar(usr, canal); - - try { - new UsuarioJpaController().edit(usuarioActual); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - @Override - public void modificarVideo(DtVideo video) { - if (usuarioActual == null) { - throw new RuntimeException("No se a iniciado la sesión"); - } - if (video == null) { - throw new RuntimeException("Todos los datos del video no pueden ser vacios"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - if (!this.obtenerCategorias().containsKey(video.getCategoria())) { - throw new RuntimeException("La categoria no existe"); - } - - DtVideo dtv = new DtVideo( - idVideoSeleccionado, - video.getNombre(), - video.getDescripcion(), - video.getDuracion(), - video.getFechaPublicacion(), - video.getUrlVideoOriginal(), - video.getPrivacidad(), - video.getCategoria(), - 0, 0); - usuarioActual.modificarVideoDeCanal(dtv); - } - - @Override - public DtCanal obtenerCanalDeUsuario() { - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - return usuarioSeleccionado.obtenerCanal(); - } - - @Override - public DtUsuario obtenerPropietarioDeVideo(int idVideo) { - // Esto es un parche, pero de los que nunca se despegan... - // A tiempos desesperados, medidas desesperadas - for (Map.Entry<String, Usuario> u : this.obtenerUsuarios().entrySet()){ - try { - u.getValue().obtenerVideo(idVideo); - return u.getValue().getDT(); - } catch (Exception e) { - // a seguir buscando - } - } - throw new RuntimeException("El iID de video no crresponde a ningun usuario"); - } - - @Override - public DtUsuario obtenerPropietarioDeListaDeReproduccion(int idLista) { - // Esto es un parche, pero de los que nunca se despegan... - // A tiempos desesperados, medidas desesperadas - for (Map.Entry<String, Usuario> u : this.obtenerUsuarios().entrySet()){ - try { - u.getValue().obtenerListaDeReproduccion(idLista); - return u.getValue().getDT(); - } catch (Exception e) { - // a seguir buscando - } - } - throw new RuntimeException("El iID de video no crresponde a ningun usuario"); - } - - @Override - public DtValoracion obtenerValoracionDada() { - if (usuarioActual == null) { - throw new RuntimeException("No se a iniciado la sesión"); - } - if(usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - return usuarioSeleccionado.obtenerValoracion(idVideoSeleccionado, usuarioActual.getNickname()); - } - - @Override - public ArrayList<DtValoracion> obtenerValoracionesDeVideo() { - if(usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - return usuarioSeleccionado.listarValoracionesDeVideo(idVideoSeleccionado); - } - - @Override - public void quitarVideoDeListaDeReproduccion(int idVideo) { - if(usuarioActual == null){ - throw new RuntimeException("No se a iniciado la sesión"); - } - if (idListaSeleccionada == 0){ - throw new RuntimeException("El sistema no tiene una lista de reproduccion seleccionada"); - } - usuarioActual.quitarVideoDeListaDeReproduccion(idListaSeleccionada,idVideo); - - } - - @Override - public void seguirUsuario() { - if (this.usuarioActual == null){ - throw new RuntimeException("No se ha iniciado sesión"); - } - if (this.usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - usuarioActual.agregarOQuitarSeguido(usuarioSeleccionado); - try { - new UsuarioJpaController().edit(usuarioSeleccionado); - new UsuarioJpaController().edit(usuarioActual); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } - } - - @Override - public DtUsuario seleccionarUsuario(String nickname) { - usuarioSeleccionado = obtenerUsuarios().get(nickname); - if (usuarioSeleccionado == null){ - throw new RuntimeException("No se encontro ningun usuario con ese nickname"); - } - return usuarioSeleccionado.getDT(); - } - - @Override - public DtListaDeReproduccion seleccionarListaDeReproduccion(int idLista) { - if (this.usuarioSeleccionado == null){ - String nick = this.obtenerPropietarioDeListaDeReproduccion(idLista).getNickname(); - this.seleccionarUsuario(nick); - } - DtListaDeReproduccion ret = usuarioSeleccionado.obtenerListaDeReproduccion(idLista); - idListaSeleccionada = idLista; - return ret; - } - - @Override - public DtVideo seleccionarVideo(int idVideo) { - if (this.usuarioSeleccionado == null){ - String nick = this.obtenerPropietarioDeVideo(idVideo).getNickname(); - this.seleccionarUsuario(nick); - } - DtVideo ret = usuarioSeleccionado.obtenerVideoDeCanal(idVideo); - idVideoSeleccionado = idVideo; - return ret; - } - - @Override - public boolean sesionIniciada(){ - return (usuarioActual != null); - } - - @Override - public boolean validarNuevaListaParticular(String nombre) { - if (this.usuarioActual == null){ - throw new RuntimeException("No se ha iniciado sesión"); - } - if (obtenerListasPorDefecto().containsKey(nombre)) { - return false; - } - if (idListaSeleccionada != 0){ - if (usuarioActual.obtenerListaDeReproduccion(idListaSeleccionada).getNombre().equals(nombre)){ - return true; - } - } - return usuarioActual.validarListaParticular(nombre); - } - - @Override - public boolean validarNuevoVideo(String nombre) { - if (this.usuarioActual == null){ - throw new RuntimeException("No se ha iniciado sesión"); - } - if (idVideoSeleccionado != 0){ - if (usuarioActual.obtenerVideo(idVideoSeleccionado).getNombre().equals(nombre)){ - return true; - } - } - return usuarioActual.validarListaParticular(nombre); - } - - @Override - public void valorarVideo(DtValoracion val) { - if (this.usuarioActual == null){ - throw new RuntimeException("No se ha iniciado sesión"); - } - if (usuarioSeleccionado == null){ - throw new RuntimeException("El sistema no tiene un usuario seleccionado"); - } - if (idVideoSeleccionado == 0){ - throw new RuntimeException("El sistema no tiene un video seleccionado"); - } - if (val == null){ - usuarioSeleccionado.quitarValoracion(idVideoSeleccionado, usuarioActual.getNickname()); - }else{ - usuarioSeleccionado.agregarModificarValoracionDeVideo(idVideoSeleccionado, val, usuarioActual); - } - } - -} diff --git a/UyTube_aplicacion/src/Logica/DataType/DtCanal.java b/UyTube_aplicacion/src/Logica/DataType/DtCanal.java deleted file mode 100644 index 40408a02ecd46a0ee0a0b67219f5a7e60ea19773..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/DataType/DtCanal.java +++ /dev/null @@ -1,40 +0,0 @@ -package Logica.DataType; - -import Logica.Enumerados.Privacidad; - -public class DtCanal { - private int id; - private String nombre; - private String descripcion; - private Privacidad privacidad; - - public DtCanal(int id, String nombre, String descripcion,Privacidad privacidad) { - this.id = id; - this.nombre = nombre; - this.descripcion = descripcion; - this.privacidad = privacidad; - } - - public int getId() { - return id; - } - - public String getNombre() { - return nombre; - } - - public String getDescripcion() { - return descripcion; - } - - public Privacidad getPrivacidad() { - return privacidad; - } - - @Override - public String toString() { - return "DtCanal{" + "id=" + id + ", nombre=" + nombre + ", descripcion=" + descripcion + ", privacidad=" + privacidad + '}'; - } - - -} diff --git a/UyTube_aplicacion/src/Logica/DataType/DtCategoria.java b/UyTube_aplicacion/src/Logica/DataType/DtCategoria.java deleted file mode 100644 index 21b7c92839262def00e043456c7d2856fac4fdf7..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/DataType/DtCategoria.java +++ /dev/null @@ -1,19 +0,0 @@ -package Logica.DataType; - -public class DtCategoria { - private String nombre; - - public DtCategoria(String nombre) { - this.nombre = nombre; - } - - public String getNombre() { - return nombre; - } - - @Override - public String toString() { - return "DtCategoria{" + "nombre=" + nombre + '}'; - } - -} diff --git a/UyTube_aplicacion/src/Logica/DataType/DtComentario.java b/UyTube_aplicacion/src/Logica/DataType/DtComentario.java deleted file mode 100644 index 8df8fd39ffe3aa7578c966f6346c45b259eca1b0..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/DataType/DtComentario.java +++ /dev/null @@ -1,46 +0,0 @@ -package Logica.DataType; - -import java.sql.Date; - -public class DtComentario { - private int id; - private String nickname; - private Date fecha; - private String texto; - private int nivelSubComentario; - - public DtComentario(int id, String nickname, Date fecha, String texto, int nivelSubComentario) { - this.id = id; - this.nickname = nickname; - this.fecha = fecha; - this.texto = texto; - this.nivelSubComentario = nivelSubComentario; - } - - public int getId() { - return id; - } - - public String getNickname() { - return nickname; - } - - public Date getFecha() { - return fecha; - } - - public String getTexto() { - return texto; - } - - public int getNivelSubComentario() { - return nivelSubComentario; - } - - @Override - public String toString() { - return "DtComentario{" + "id=" + id + ", nickname=" + nickname + ", fecha=" + fecha + ", texto=" + texto + ", nivelSubComentario=" + nivelSubComentario + '}'; - } - - -} diff --git a/UyTube_aplicacion/src/Logica/DataType/DtListaDeReproduccion.java b/UyTube_aplicacion/src/Logica/DataType/DtListaDeReproduccion.java deleted file mode 100644 index d617e63e588c6ad5491b77a093c0e7b5217d60f4..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/DataType/DtListaDeReproduccion.java +++ /dev/null @@ -1,56 +0,0 @@ -package Logica.DataType; - -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoListaDeReproduccion; - -public class DtListaDeReproduccion { - private int id; - private String nombre; - private Privacidad privacidad; - private TipoListaDeReproduccion tipo; - private String categoria; - private String nombreDuenio; - - public DtListaDeReproduccion(int id, String nombre, Privacidad privacidad, TipoListaDeReproduccion tipo, String categoria) { - this.id = id; - this.nombre = nombre; - this.privacidad = privacidad; - this.tipo = tipo; - this.categoria = categoria; - } - - public DtListaDeReproduccion(int id, String nombre, Privacidad privacidad, TipoListaDeReproduccion tipo, String categoria, String nombreDuenio) { - this.id = id; - this.nombre = nombre; - this.privacidad = privacidad; - this.tipo = tipo; - this.categoria = categoria; - this.nombreDuenio = nombreDuenio; - } - - public int getId() { - return id; - } - - public String getNombre() { - return nombre; - } - - public Privacidad getPrivacidad() { - return privacidad; - } - - public TipoListaDeReproduccion getTipo() { - return tipo; - } - - public String getCategoria() { - return categoria; - } - - @Override - public String toString() { - return "DtListaDeReproduccion{" + "id=" + id + ", nombre=" + nombre + ", privacidad=" + privacidad + ", tipo=" + tipo + ", categoria=" + categoria + '}'; - } - -} diff --git a/UyTube_aplicacion/src/Logica/DataType/DtPersona.java b/UyTube_aplicacion/src/Logica/DataType/DtPersona.java deleted file mode 100644 index 11ec6aa8588e5969b3788e4fcdf7ab998be88b2a..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/DataType/DtPersona.java +++ /dev/null @@ -1,33 +0,0 @@ -package Logica.DataType; - -public abstract class DtPersona { - private String nombre; - private String apellido; - private String contrasenia; - - public DtPersona(String nombre, String apellido, String contrasenia) { - // esta clase es abstracta, eso se define arriba al hacer 'public abstract class...' - // aca se setean los valores recibidos - this.nombre = nombre; - this.apellido = apellido; - this.contrasenia = contrasenia; - } - - public String getNombre() { - return nombre; - } - - public String getApellido() { - return apellido; - } - - public String getContrasenia() { - return contrasenia; - } - - @Override - public String toString() { - return "DtPersona{" + "nombre=" + nombre + ", apellido=" + apellido + ", contrasenia=" + contrasenia + '}'; - } - -} diff --git a/UyTube_aplicacion/src/Logica/DataType/DtUsuario.java b/UyTube_aplicacion/src/Logica/DataType/DtUsuario.java deleted file mode 100644 index 10f8db084d1efd87171278e46b34a50b74343795..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/DataType/DtUsuario.java +++ /dev/null @@ -1,68 +0,0 @@ -package Logica.DataType; - -import java.sql.Date; - -public class DtUsuario extends DtPersona{ - private String nickname; - private String correo; - private Date fechaNacimiento; - private Date fechaEliminado; - private String imagen; - private int cantSeguidores; - - public DtUsuario(String nickname, String contrasenia, String nombre, String apellido, String correo, Date fechaNacimiento, String imagen, int cantSeguidores) { - // Antes de leer esto, lee el constructor de DtPersona... - // para setear los atributos de la clase padre, se utiliza super(..) y - // sele asan los atributos que recibe el constructor de la clase padre - super(nombre, apellido, contrasenia); - // y ahora se setean los atributos propios - this.nickname = nickname; - this.correo = correo; - this.fechaNacimiento = fechaNacimiento; - this.imagen = imagen; - this.cantSeguidores = cantSeguidores; - } - - public DtUsuario(String nickname, String contrasenia, String nombre, String apellido, String correo, Date fechaNacimiento, Date fechaEliminado, String imagen, int cantSeguidores) { - // Antes de leer esto, lee el constructor de DtPersona... - // para setear los atributos de la clase padre, se utiliza super(..) y - // sele asan los atributos que recibe el constructor de la clase padre - super(nombre, apellido, contrasenia); - // y ahora se setean los atributos propios - this.nickname = nickname; - this.correo = correo; - this.fechaNacimiento = fechaNacimiento; - this.fechaEliminado = fechaEliminado; - this.imagen = imagen; - this.cantSeguidores = cantSeguidores; - } - - public String getNickname() { - return nickname; - } - - public String getCorreo() { - return correo; - } - - public Date getFechaNacimiento() { - return fechaNacimiento; - } - - public Date getFechaEliminado() { - return fechaEliminado; - } - - public String getImagen() { - return imagen; - } - - public int getCantSeguidores() { - return cantSeguidores; - } - - @Override - public String toString() { - return "DtUsuario{" + super.toString() + ", nickname=" + nickname + ", correo=" + correo + ", fechaNacimiento=" + fechaNacimiento + ", fechaEliminado=" + fechaEliminado + ", imagen=" + imagen + ", cantSeguidores=" + cantSeguidores + '}'; - } -} diff --git a/UyTube_aplicacion/src/Logica/DataType/DtValoracion.java b/UyTube_aplicacion/src/Logica/DataType/DtValoracion.java deleted file mode 100644 index bb167e88e9703dafa2773e0d16b5cec676e460de..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/DataType/DtValoracion.java +++ /dev/null @@ -1,25 +0,0 @@ -package Logica.DataType; - -import Logica.Enumerados.TipoValoracion; - -public class DtValoracion { - private TipoValoracion val; - private String nickname; - - public DtValoracion(TipoValoracion val, String nickname) { - this.val = val; - this.nickname = nickname; - } - public String getNickname() { - return nickname; - } - public TipoValoracion getVal() { - return val; - } - - @Override - public String toString() { - return "DtValoracion{" + "val=" + val + ", nickname=" + nickname + '}'; - } - -} diff --git a/UyTube_aplicacion/src/Logica/DataType/DtVideo.java b/UyTube_aplicacion/src/Logica/DataType/DtVideo.java deleted file mode 100644 index e7d99e7a706e376c305ba1c55232674f9cd30b39..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/DataType/DtVideo.java +++ /dev/null @@ -1,92 +0,0 @@ -package Logica.DataType; - -import java.sql.Time; -import java.sql.Date; -import Logica.Enumerados.Privacidad; - -public class DtVideo { - private int id; - private String nombre; - private String descripcion; - private Time duracion; - private Date fechaPublicacion; - private String urlVideoOriginal; - private Privacidad privacidad; - private String categoria; - private int cantLikes; - private int cantDisLikes; - private String nombreDuenio; - - public DtVideo(int id, String nombre, String descripcion, Time duracion, Date fechaPublicacion, String urlVideoOriginal, Privacidad privacidad, String categoria, int cantLikes, int cantDisLikes) { - this.id = id; - this.nombre = nombre; - this.descripcion = descripcion; - this.duracion = duracion; - this.fechaPublicacion = fechaPublicacion; - this.urlVideoOriginal = urlVideoOriginal; - this.privacidad = privacidad; - this.categoria = categoria; - this.cantLikes = cantLikes; - this.cantDisLikes = cantDisLikes; - } - - public DtVideo(int id, String nombre, String descripcion, Time duracion, Date fechaPublicacion, String urlVideoOriginal, Privacidad privacidad, String categoria, int cantLikes, int cantDisLikes, String nombreDuenio) { - this.id = id; - this.nombre = nombre; - this.descripcion = descripcion; - this.duracion = duracion; - this.fechaPublicacion = fechaPublicacion; - this.urlVideoOriginal = urlVideoOriginal; - this.privacidad = privacidad; - this.categoria = categoria; - this.cantLikes = cantLikes; - this.cantDisLikes = cantDisLikes; - this.nombreDuenio = nombreDuenio; - } - - public int getId() { - return id; - } - - public String getNombre() { - return nombre; - } - - public String getDescripcion() { - return descripcion; - } - - public Time getDuracion() { - return duracion; - } - - public Date getFechaPublicacion() { - return fechaPublicacion; - } - - public String getUrlVideoOriginal() { - return urlVideoOriginal; - } - - public Privacidad getPrivacidad() { - return privacidad; - } - - public String getCategoria() { - return categoria; - } - - public int getCantLikes() { - return cantLikes; - } - - public int getCantDisLikes() { - return cantDisLikes; - } - - @Override - public String toString() { - return "DtVideo{" + "id=" + id + ", nombre=" + nombre + ", descripcion=" + descripcion + ", duracion=" + duracion + ", fechaPublicacion=" + fechaPublicacion + ", urlVideoOriginal=" + urlVideoOriginal + ", privacidad=" + privacidad + ", categoria=" + categoria + ", cantLikes=" + cantLikes + ", cantDisLikes=" + cantDisLikes + '}'; - } - -} diff --git a/UyTube_aplicacion/src/Logica/DatosDePrueba.java b/UyTube_aplicacion/src/Logica/DatosDePrueba.java deleted file mode 100644 index a5b672710f670331fb6baef631962bdd585e4843..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/DatosDePrueba.java +++ /dev/null @@ -1,54 +0,0 @@ -package Logica; - -import JPAControllerClasses.BusquedaEnBDD; -import Logica.Clases.Canal; -import Logica.Clases.ListaDeReproduccion; -import Logica.Clases.Video; -import Logica.DataType.DtCanal; -import Logica.DataType.DtListaDeReproduccion; -import Logica.DataType.DtVideo; -import Logica.Enumerados.Filtrado; -import Logica.Enumerados.Ordenacion; -import Logica.Interfaces.IAdmin; -import Logica.Interfaces.IUsuario; -import java.util.ArrayList; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; - -public class DatosDePrueba { - private static IAdmin adminSys = null; - private static IUsuario usuSys = null; - - public static void main(String[] args) { - probar(); - System.exit(0); - } - - private static void probar(){ - Fabrica f = Fabrica.getInstancia(); - usuSys = f.getIUsuario(); - //CUsuario su = CUsuario.getInstancia(); - try { - - } catch (Exception e) { - System.out.println("//////////////////////////"); - System.out.println(e.getMessage()); - System.out.println("//////////////////////////"); - } - } - /* - private static void mostrarLista(ArrayList<Object> lst){ - // Prueba de búsqueda por categorÃa - for (Object o : lst){ - System.out.println("> " + o.toString()); - } - } - */ - private static void mostrarLista(Object lst){ - // Prueba de búsqueda por categorÃa - for (Object o : (ArrayList<Object>)lst){ - System.out.println("> " + o.toString()); - } - } -} diff --git a/UyTube_aplicacion/src/Logica/Enumerados/Filtrado.java b/UyTube_aplicacion/src/Logica/Enumerados/Filtrado.java deleted file mode 100644 index dd06c818f98badd67271d3bd71fefd3eb5a7dccb..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Enumerados/Filtrado.java +++ /dev/null @@ -1,5 +0,0 @@ -package Logica.Enumerados; - -public enum Filtrado { - CANALES, VIDEOS, LISTAS_DE_REPRODUCCION, TODO -} diff --git a/UyTube_aplicacion/src/Logica/Enumerados/Ordenacion.java b/UyTube_aplicacion/src/Logica/Enumerados/Ordenacion.java deleted file mode 100644 index 0b06e2d1460137e6fa26e5640b234fb7ffae971e..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Enumerados/Ordenacion.java +++ /dev/null @@ -1,5 +0,0 @@ -package Logica.Enumerados; - -public enum Ordenacion { - ALFABETICA_ASCENDENTE, FECHA_DESCENDENTE -} diff --git a/UyTube_aplicacion/src/Logica/Enumerados/Privacidad.java b/UyTube_aplicacion/src/Logica/Enumerados/Privacidad.java deleted file mode 100644 index 0c63d6170d85f6fb855421a86a53d43ba48ff4e7..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Enumerados/Privacidad.java +++ /dev/null @@ -1,5 +0,0 @@ -package Logica.Enumerados; - -public enum Privacidad { - PUBLICO, PRIVADO -} diff --git a/UyTube_aplicacion/src/Logica/Enumerados/TipoListaDeReproduccion.java b/UyTube_aplicacion/src/Logica/Enumerados/TipoListaDeReproduccion.java deleted file mode 100644 index d5b5ca1a06b7afca03fd4e69fcddfe86d481feeb..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Enumerados/TipoListaDeReproduccion.java +++ /dev/null @@ -1,5 +0,0 @@ -package Logica.Enumerados; - -public enum TipoListaDeReproduccion { - POR_DEFECTO, PARTICULAR -} diff --git a/UyTube_aplicacion/src/Logica/Enumerados/TipoValoracion.java b/UyTube_aplicacion/src/Logica/Enumerados/TipoValoracion.java deleted file mode 100644 index 7334f06676973b907ac36b783da8cfcb6dd6d442..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Enumerados/TipoValoracion.java +++ /dev/null @@ -1,5 +0,0 @@ -package Logica.Enumerados; - -public enum TipoValoracion { - LIKE, DISLIKE -} diff --git a/UyTube_aplicacion/src/Logica/Fabrica.java b/UyTube_aplicacion/src/Logica/Fabrica.java deleted file mode 100644 index 2405684b805827ab1ced98afd8aaaaf5b30a44ce..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Fabrica.java +++ /dev/null @@ -1,33 +0,0 @@ -package Logica; - -import Logica.Controladores.CAdmin; -import Logica.Controladores.CUsuario; -import Logica.Interfaces.IAdmin; -import Logica.Interfaces.IUsuario; - - -/* Clase Singleton */ -public class Fabrica { - private static Fabrica instancia = null; - - private Fabrica(){ - - } - - public static Fabrica getInstancia(){ - if( instancia == null ){ - instancia = new Fabrica(); - } - return instancia; - } - - /* Crea una unicia instancia del controlador CAdmin */ - public IAdmin getIAdmin(){ - return CAdmin.getInstancia(); - } - - /* Crea una unicia instancia del controlador CUsuario */ - public IUsuario getIUsuario(){ - return CUsuario.getInstancia(); - } -} diff --git a/UyTube_aplicacion/src/Logica/Interfaces/IAdmin.java b/UyTube_aplicacion/src/Logica/Interfaces/IAdmin.java deleted file mode 100644 index 11e3c771c7026bd29dbf6fa62a36f387e7473ef9..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Interfaces/IAdmin.java +++ /dev/null @@ -1,361 +0,0 @@ -package Logica.Interfaces; - -import Logica.DataType.*; -import java.util.ArrayList; - -public interface IAdmin { - - /** - * Agrega el video idVideoSeleccionado a la lista indicada - * - * @param idLista ID de la lista a la cual se agrega el video - */ - public void agregarVideoAListaDeReproduccion(int idLista); - - /** - * Crea la categoria con el nombre indicado - * - * @param categoria nombre de la categoria - */ - public void altaCategoria(String categoria); - - /** - * Comenta el video idVideoSeleccionado a nombre de usuarioActual - * - * @param dtCom Comentario a agregar - */ - public void altaComentario(DtComentario dtCom); - - /** - * Comenta el comentario con dicho ID a nombre de usuarioActual - * - * @param dtCom Comentario a agregar - * @param idComPadre ID del comentario a responder - */ - public void altaComentario(DtComentario dtCom, int idComPadre); - - /** - * Crea la lista de reproduccion para usuarioSeleccionado - * - * @param lista Lista particular a agregar - */ - public void altaListaDeReproduccionParticular(DtListaDeReproduccion lista); - - /** - * Crea la lista de reproduccion para todos los usuarios del sistema y la - * agrega listas por defecto (para que se creen al crear un usuario nuevo) - * - * @param lista Lista por defecto a agregar - */ - public void altaListaDeReproduccionPorDefecto(DtListaDeReproduccion lista); - - /** - * Crea un usuario y su canal a partir de los datos recibidos - * - * @param usr Datos del usuario a dar de alta - * @param canal Datos del canal del usuario - */ - public void altaUsuarioCanal(DtUsuario usr, DtCanal canal); - - /** - * Se ingresa la nueva valoracion dada por usuarioActual al video - * idVideoSeleccionado Si el usuario ya habia valorado, se actualiza la - * valoracion dada - * - * @param val Valoracion dada - */ - public void altaValoracion(DtValoracion val); - - /** - * Se crea un video nuevo en el canal de usuarioSeleccionado - * - * @param video Datos del video a dar de alta - */ - public void altaVideo(DtVideo video); - - /** - * Elimina el usuario actual seleccionado - */ - public void bajaUsuario(); - - /** - * Verifica si existe una categoria con el nombre recibido - * - * @param cat Nombre de la categoria a verificar - * @return true si la categoria ya existe - */ - public boolean existeCategoria(String cat); - - /** - * Verifica si existe un usuario con el mail recibido - * - * @param email Correo a verificar - * @return true si el correo ya esta en uso - */ - public boolean existeEmail(String email); - - /** - * Verifica si existe un usuario con el nickname recibido - * - * @param nickname Nickname a verificar - * @return true si el nickname ya esta en uso - */ - public boolean existeNickname(String nickname); - - /** - * Inicio de sesion para administradores - * - * @param id ID del administrador - * @param pass contraseña del administrador - * @return true si el ID existe y la contraseña es correcta - */ - public boolean iniciarSesionAdministrador(int id, String pass); - - /** - * Libera memoria de la lista de reproduccion seleccionada - */ - public void liberarMemoriaListaDeReproduccion(); - - /** - * Libera memoria del usuario seleccionado - */ - public void liberarMemoriaUsuario(); - - /** - * Libera memoria del usuario actual seleccionado - */ - public void liberarMemoriaUsuarioActual(); - - /** - * Libera memoria del video seleccionado - */ - public void liberarMemoriaVideo(); - - /** - * Devuelve todas las categorias existentes en el sistema - * - * @return Conjunto de nombres de categorÃas - */ - public ArrayList<String> listarCategorias(); - - /** - * Devuelve en forma ordenada (recursiva ) todos los comentarios de - * idVideoSeleccionado - * - * @return Conjunto de comentarios - */ - public ArrayList<DtComentario> listarComentariosDeVideo(); - - /** - * Devuelve todos las listas de reproduccion del sistema que pertenezcan a - * la categoria indicada - * - * @param cat Nombre de categorÃa - * @return Conjunto de listas de reproduccion - */ - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionEnCategoria(String cat); - - /** - * Devuelve todas las listas de reproduccion de usuarioSeleccionado o de - * usuarioActual segun el nickname indicado - * - * @param nickname Nickname del usuario seleccionado o del usuario actual - * @return Conjunto de listas de reproduccion - */ - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeUsuario(String nickname); - - /** - * Devuelve las listas de reproduccion particulares de usuarioSeleccionado - * - * @return Conjunto de listas de reproduccion - */ - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionParticularesDeUsuario(); - - /** - * Devuelve todos los usuarios que siguen a usuarioSeleccionado - * - * @return Conjunto de usuarios - */ - public ArrayList<DtUsuario> listarUsuarioSeguidores(); - - /** - * Devuelve todos los usuarios a quienes NO sigue usuarioSeleccionado - * - * @return Conjunto de usuarios - */ - public ArrayList<DtUsuario> listarUsuarioNoSeguidos(); - - /** - * Devuelve todos los usuarios a quienes sigue usuarioSeleccionado - * - * @return Conjunto de usuarios - */ - public ArrayList<DtUsuario> listarUsuarioSeguidos(); - - /** - * Devuelve todos los datos de todos los usuarios - * - * @return Conjunto de usuarios - */ - public ArrayList<DtUsuario> listarUsuarios(); - - /** - * Devuelve todos los datos de todos los usuarios eliminados - * - * @return Conjunto de usuarios - */ - public ArrayList<DtUsuario> listarUsuariosEliminados(); - - /** - * Devuelve todos los videos del sistema que pertenezcan a la categoria - * indicada - * - * @param cat Nombre de categorÃa - * @return Conjunto de videos - */ - public ArrayList<DtVideo> listarVideosEnCategoria(String cat); - - /** - * Devuelve todos los videos de usuarioSeleccionado - * - * @return Conjunto de videos - */ - public ArrayList<DtVideo> listarVideosDeUsuario(); - - /** - * Devuelve los videos de la lista de reproduccion idListaSeleccionada - * - * @return Conjunto de videos - */ - public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(); - - /** - * Se modifican los datos de la lista idListaSeleccionada - * - * @param lista Datos de la lista de reproduccion - */ - public void modificarListaDeReproduccion(DtListaDeReproduccion lista); - - /** - * Se modifican los datos de usuarioActual y su canal - * - * @param usr Datos del usuario - * @param canal Datos del canal - */ - public void modificarUsuarioYCanal(DtUsuario usr, DtCanal canal); - - /** - * Se modifican los datos del video idVideoSeleccionado - * - * @param video Datos del video - */ - public void modificarVideo(DtVideo video); - - /** - * Busca entre todos los usuarios al propietario del video con ese ID - * - * @param idVideo ID del video - * @return Datos del usuario - */ - public DtUsuario obtenerPropietarioDeVideo(int idVideo); - - /** - * Devuelve los datos del canal del usuario en memoria usuarioSeleccionado - * - * @return Datos del canal - */ - public DtCanal obtenerCanalDeUsuario(); - - /** - * Devuelve las valoraciones de idVideoSeleccionado - * - * @return Conjunto de valoraciones - */ - public ArrayList<DtValoracion> obtenerValoracionesDeVideo(); - - /** - * Devuelve la valoracion dada por usuarioActual al video - * idVideoSeleccionado - * - * @return Valoracion dada o null si no ha valorado - */ - public DtValoracion obtenerValoracionDada(); - - /** - * Quita el video idVideoSeleccionado de la lista idListaSeleccionada - * @param idVideo ID del video - */ - public void quitarVideoDeListaDeReproduccion(int idVideo); - - /** - * Quita el video idVideoSeleccionado de la lista idListaSeleccionada - * - * @param nickname Nickname del usuario - * @return Datos del usuario - */ - public DtUsuario seleccionarUsuario(String nickname); - - /** - * El sistema recuerda un link al usuario como usuarioActual Devuelve los - * datos de usuarioActual - * - * @param nickname Nickname del usuario - * @return Datos del usuario - */ - public DtUsuario seleccionarUsuarioActual(String nickname); - - /** - * El sistema recuerda un link al usuario eliminado como usuarioSeleccionado - * Devuelve los datos de usuarioActual - * - * @param nickname Nickname del usuario - * @return Datos del usuario - */ - public DtUsuario seleccionarUsuarioEliminado(String nickname); - - /** - * El sistema recuerda el ID del video como idVideoSeleccionado Devuelve los - * datos del video seleccionado - * - * @param idVideo ID del video - * @return Datos del video - */ - public DtVideo seleccionarVideo(int idVideo); - - /** - * El sistema recuerda el ID de la lista como idListaSeleccionada Devuelve - * los datos de la lista de reproduccion seleccionada perteneciente a - * usuarioSeleccionado - * - * @param idLista ID de la lista de reproduccion - * @return Datos de la lista de reproduccion - */ - public DtListaDeReproduccion seleccionarListaDeReproduccion(int idLista); - - /** - * El usuario usuarioActual comienza a seguir a usuarioSeleccionado En caso - * de que este ya lo este siguiendo, lo deja de seguir - */ - public void seguirUsuario(); - - /** - * Devuelve false si usuarioSeleccionado posee una lista de reproducion con - * ese nombre - * - * @param nombre Nombre de la lista de reproduccion - * @return true si el usuario no posee ya una lista de reproduccion con ese - * nombre - */ - public boolean validarNuevaListaParticular(String nombre); - - /** - * Devuelve false si existe algun usuario en el sistema que posea una lista - * de reproduccion con ese nombre - * - * @param nombre Nombre de la lista de reproduccion - * @return true si ningun usuario posee una lista con ese nombre, y ademas - * no existen listas por defecto con ese nombre - */ - public boolean validarNuevaListaPorDefecto(String nombre); - -} diff --git a/UyTube_aplicacion/src/Logica/Interfaces/IUsuario.java b/UyTube_aplicacion/src/Logica/Interfaces/IUsuario.java deleted file mode 100644 index e94a4890cd0f6967ead47bf3d409c278ad116e5e..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/Logica/Interfaces/IUsuario.java +++ /dev/null @@ -1,361 +0,0 @@ -package Logica.Interfaces; - -import Logica.DataType.*; -import Logica.Enumerados.*; -import java.util.ArrayList; - -public interface IUsuario { - - /** - * Agrega el video idVideoSeleccionado que pertenece a usuarioSeleccionado, - * a la lista indicada perteneciente a usuarioActual - * - * @param idLista ID de la lista de reproduccon - */ - public void agregarVideoAListaDeReproduccion(int idLista); - - /** - * Comenta el video idVideoSeleccionado perteneciente a usuarioSeleccionado, - * a nombre de usuarioActual - * - * @param dtCom Comentario a agregar - */ - public void altaComentario(DtComentario dtCom); - - /** - * Comenta a nombre de usuarioActual, el comentario con el ID indicado, que - * pertenece al video idVideoSeleccionado, que pertenece a - * usuarioSeleccionado - * - * @param dtCom Comentario a agregar - * @param idComPadre ID del comentario a responder - */ - public void altaComentario(DtComentario dtCom, int idComPadre); - - /** - * Da de alta la lista de reproduccion particular para usuarioActual - * - * @param lista Lista particular a dar de alta - */ - public void altaListaDeReproduccionParticular(DtListaDeReproduccion lista); - - /** - * Da de alta un usuario y su canal a partir de los datos recibidos - * Luego de darlo de alta, el usuario queda con la sesión iniciada - * - * @param usr Datos del usuario a dar de alta - * @param canal Datos del canal del usuario - */ - public void altaUsuarioCanal(DtUsuario usr, DtCanal canal); - - /** - * Da de alta un video en el canal de usuarioActual - * - * @param video Datos del video a dar de alta - */ - public void altaVideo(DtVideo video); - - /** - * Da de baja al usuarioActual - * En el proceso se cierra la sesion - */ - public void bajaUsuario(); - - /** - * Busca contenido por coincidencia de texto en nombre o descripcion de los - * contenidos del sistema En el resultado se incluirán (si corresponde segun - * el filtrado) los videos privados del usuarioActual - * Si no se ha iniciado sesión, se muestran sólo los contenidos públicos - * - * @param busqueda Texto a buscar (si es vacÃo incluye todo el contenido) - * @param filtro Tipo de contenido en el cual se realizará la búsqueda - * @param orden Manera de ordenar el resultado de la búsqueda - * @return Resultado de la busqueda. Puede contener DtVideo, - * DtListaDeReproduccion y/o DtCanal. (para usar los elementos devueltos hay - * que castearlos) - */ - public ArrayList<Object> buscar(String busqueda, Filtrado filtro, Ordenacion orden); - - /** - * Busca contenido que pertenezcan a la categoria indicada El Resultado - * contendrá todos los contenidos publicos, y los contenidos privados del - * usuarioActual - * Si no se ha iniciado sesión, se muestran sólo los contenidos públicos - * - * @param categoria Nombre de la categoria a buscar - * @return Resultado de la busqueda. Puede contener DtVideo y - * DtListaDeReproduccion. (para usar los elementos devueltos hay que - * castearlos) - */ - public ArrayList<Object> buscar(String categoria); - - /** - * Cierra la sesión del usuarioActual (lo quita de memoria) - */ - public void cerrarSesion(); - - /** - * Como el nombre de la funcion lo indica, es para saber si el usuario que - * se ha seleccionado, es el usuario que tiene la inicion sesiada - * - * @return true si el usuario seleccionado es el usuario que inicio la - * sesion - */ - public boolean elUsuarioSeleccionadoEsElUsuarioActual(); - - /** - * Verifica si existe un usuario con el email indicado - * - * @param email Email a verificar - * @return true si el email ya esta en uso - */ - public boolean existeEmail(String email); - - /** - * Verifica si existe un usuario con el nickname indicado - * - * @param nickname Nickname a verificar - * @return true si el nickname ya esta en uso - */ - public boolean existeNickname(String nickname); - - /** - * Inicia la sesión del usuario. Si los datos son correctos se guarda al - * usuario como usuarioActual - * - * @param nickOEmail Nickname o email del usuario - * @param contrasenia Contraseña del usuario - * @return true si el usuario con el nickname o email existe y ademas la - * contrasenia es correcta - */ - public boolean iniciarSesionUsuario(String nickOEmail, String contrasenia); - - /** - * Libera memoria de la lista de reproduccion seleccionada - */ - public void liberarMemoriaListaDeReproduccion(); - - /** - * Libera memoria del usuario seleccionado - */ - public void liberarMemoriaUsuario(); - - /** - * Libera memoria del video seleccionado - */ - public void liberarMemoriaVideo(); - - /** - * Devuelve todas las categorias existentes en el sistema - * - * @return Conjunto de nombres de categorÃas - */ - public ArrayList<String> listarCategorias(); - - /** - * Devuelve en forma ordenada (recursiva) todos los comentarios de - * idVideoSeleccionado perteneciente a usuarioSeleccionado - * - * @return Conjunto de comentarios - */ - public ArrayList<DtComentario> listarComentariosDeVideo(); - - /** - * Devuelve las listas de reproduccion del usuarioSeleccionado Si el - * usuarioSeleccionado es el usuarioActual, y se incluyen las listas por - * defecto: devuelve todas las listas del usuarioSeleccionado. Si el - * usuarioSeleccionado es el usuarioActual, y NO se incluyen las listas por - * defecto: devuelve las listas particulares (privadas y publicas) del - * usuarioSeleccionado Si el usuarioSeleccionado NO ES el usuarioActual: - * devuelve solo las listas publicas - * - * @param incluirListasPorDefecto True si se desea incluir en el listado las - * listas por defecto - * @return Conjunto de listas de reproduccion - */ - public ArrayList<DtListaDeReproduccion> listarListasDeReproduccionDeUsuario(boolean incluirListasPorDefecto); - - /** - * Devuelve todos los usuarios que siguen a usuarioSeleccionado - * - * @return Conjunto de usuarios - */ - public ArrayList<DtUsuario> listarUsuarioSeguidores(); - - /** - * Devuelve todos los usuarios a los que sigue usuarioSeleccionado - * - * @return Conjunto de usuarios - */ - public ArrayList<DtUsuario> listarUsuarioSeguidos(); - - /** - * Devuelve todos los datos de todos los usuarios del sistema - * - * @return Conjunto de usuarios - */ - public ArrayList<DtUsuario> listarUsuarios(); - - /** - * Lista los videos contenidos en la lista idListaSeleccionada perteneciente - * al usuarioSeleccionado Si la lista contiene video privado que no - * pertenezca a usuarioActual, estos no se incluiran en el resultado - * Si no se ha iniciado sesion solo lista los videos publicos - * - * @return Conjunto de videos - */ - public ArrayList<DtVideo> listarVideosDeListaDeReproduccion(); - - /** - * Devuelve los videos públicos del usuarioSeleccionado Si el - * usuarioSeleccionado es el usuarioActual: Se incluirán los videos privados - * - * @return Conjunto de videos - */ - public ArrayList<DtVideo> listarVideosDeUsuario(); - - /** - * Se modifican los datos de la lista idListaSeleccionada que pertenece a - * usuarioActual - * - * @param lista Nuevos datos de la lista de reproduccion - */ - public void modificarListaDeReproduccion(DtListaDeReproduccion lista); - - /** - * Se modifican los datos de usuarioActual y su canal - * - * @param usr Nuevos datos del usuario - * @param canal Nuevos datos del canal - */ - public void modificarUsuarioYCanal(DtUsuario usr, DtCanal canal); - - /** - * Se modifican los datos del video idVideoSeleccionado que pertenece a - * usuarioActual - * - * @param video Nuevos datos del video - */ - public void modificarVideo(DtVideo video); - - /** - * Devuelve los datos del canal del usuarioSeleccionado - * - * @return Datos del canal - */ - public DtCanal obtenerCanalDeUsuario(); - - /** - * Busca entre todos los usuarios al propietario del video con el ID indicado - * - * @param idVideo ID del video - * @return Datos del usuario - */ - public DtUsuario obtenerPropietarioDeVideo(int idVideo); - - /** - * Busca entre todos los usuarios al propietario de la lista de reproduccion con el ID indicado - * - * @param idLista ID de la lista de reproduccion - * @return Datos del usuario - */ - public DtUsuario obtenerPropietarioDeListaDeReproduccion(int idLista); - - /** - * Devuelve la valoracion dada por usuarioActual al video - * idVideoSeleccionado perteneciente al usuarioSeleccionado - * - * @return Valoracion dada o null si no ha valorado - */ - public DtValoracion obtenerValoracionDada(); - - /** - * Devuelve las valoraciones de idVideoSeleccionado perteneciente a - * usuarioSeleccionado - * - * @return Conjunto de valoraciones - */ - public ArrayList<DtValoracion> obtenerValoracionesDeVideo(); - - /** - * Quita el video indicado de la lista idListaSeleccionada perteneciente al - * usuarioActual - * - * @param idVideo ID del video a quitar - */ - public void quitarVideoDeListaDeReproduccion(int idVideo); - - /** - * El usuarioActual comienza a seguir a usuarioSeleccionado En caso de que - * este ya lo esté siguiendo, lo deja de seguir - */ - public void seguirUsuario(); - - /** - * Selecciona un usuario del sistema El sistema recuerda el usuario como - * usuarioSeleccionado Devuelve los datos de usuarioSeleccionado - * - * @param nickname Nickname del usuario - * @return Datos del usuario - */ - public DtUsuario seleccionarUsuario(String nickname); - - /** - * Selecciona una lista de reproduccion del usuarioSeleccionado El sistema - * recuerda el ID de la lista como idListaSeleccionada. Si no hay un - * usuarioSeleccionado, el sistema busca al propietario de la lista y lo - * selecciona - * - * @param idLista ID de la lista de reproduccion - * @return Datos de la lista de reproduccion seleccionada - */ - public DtListaDeReproduccion seleccionarListaDeReproduccion(int idLista); - - /** - * Selecciona un video del usuarioSeleccionado El sistema recuerda el ID del - * video como idVideoSeleccionado. Si no hay un usuarioSeleccionado, el - * sistema busca al propietario del video y lo selecciona - * - * @param idVideo ID del video - * @return Datos del video seleccionado - */ - public DtVideo seleccionarVideo(int idVideo); - - /** - * Permite saber si hay una sesion iniciada - * @return true si hay una sesion iniciada - */ - public boolean sesionIniciada(); - - /** - * Verifica si el usuarioActual puede agregar una lista de reproduccion con - * el nombre indicado (Si hay una idListaSeleccionada y su nombre coincide - * con el nombre a verificar, retorna true) - * - * @param nombre Nombre de la lista de reproduccion - * @return true si el usuarioActual puede agregar una lista de reproduccion - * con ese nombre - */ - public boolean validarNuevaListaParticular(String nombre); - - /** - * Verifica si el usuarioActual puede agregar un video con el nombre - * indicado (Si hay un idVideoSeleccionado y su nombre coincide con el - * nombre a verificar, retorna true) - * - * @param nombre Nombre del video - * @return true si el usuarioActual puede agregar un video con ese nombre - */ - public boolean validarNuevoVideo(String nombre); - - /** - * Se ingresa la nueva valoracion dada por usuarioActual al video - * idVideoSeleccionado perteneciente a usuarioSeleccionado Si el usuario ya - * habia valorado, se actualiza la valoracion dada Si la valoracion recibida - * es null, se quita la valoracion dada - * - * @param val Valoracion dada (puede ser null) - */ - public void valorarVideo(DtValoracion val); - -} diff --git a/UyTube_aplicacion/src/META-INF/persistence.xml b/UyTube_aplicacion/src/META-INF/persistence.xml deleted file mode 100644 index aa020d7a75891bd8952307dfcedf3e57ed4a037b..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/src/META-INF/persistence.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> - <persistence-unit name="UyTubePU" transaction-type="RESOURCE_LOCAL"> - <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> - <class>Logica.Clases.Administrador</class> - <class>Logica.Clases.Canal</class> - <class>Logica.Clases.Categoria</class> - <class>Logica.Clases.Comentario</class> - <class>Logica.Clases.ListaDeReproduccion</class> - <class>Logica.Clases.ListaPorDefecto</class> - <class>Logica.Clases.Persona</class> - <class>Logica.Clases.Usuario</class> - <class>Logica.Clases.Valoracion</class> - <class>Logica.Clases.Video</class> - <properties> - <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/UyTube"/> - <property name="javax.persistence.jdbc.user" value="postgres"/> - <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/> - <property name="javax.persistence.jdbc.password" value="1234"/> - <property name="javax.persistence.schema-generation.database.action" value="create"/> - </properties> - </persistence-unit> -</persistence> diff --git a/UyTube_aplicacion/src/Presentacion/frmPrincipal.java b/UyTube_aplicacion/src/Presentacion/frmPrincipal.java index 6c6e2b0a976696be023ee3ecbb55a167391e1bf7..9227c567af181a7e10695e8aa67c2ef093f99a49 100644 --- a/UyTube_aplicacion/src/Presentacion/frmPrincipal.java +++ b/UyTube_aplicacion/src/Presentacion/frmPrincipal.java @@ -28,7 +28,7 @@ public class frmPrincipal extends javax.swing.JFrame { lbFondo.setIcon(img4); //####### Descomentar la siguiente linea ###### // - //activarBarraDeMenu(false); + activarBarraDeMenu(false); // hecho... sesionIniciada = false; mitCerrarSesion.setEnabled(false); } diff --git a/UyTube_aplicacion/test/Logica/Clases/AdministradorTest.java b/UyTube_aplicacion/test/Logica/Clases/AdministradorTest.java deleted file mode 100644 index c497d6dbbe58e9e4046bb09243562e35f199452f..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Clases/AdministradorTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Clases; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class AdministradorTest { - - public AdministradorTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getNuevoID method, of class Administrador. - */ - @Test - public void testGetNuevoID() { - System.out.println("getNuevoID"); - int expResult = 1; - int result = Administrador.getNuevoID(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getIdAdmin method, of class Administrador. - */ - @Test - public void testGetIdAdmin() { - System.out.println("getIdAdmin"); - Administrador instance = new Administrador(0, "contrasenia", "nombre", "apellido"); - int expResult = 0; - int result = instance.getIdAdmin(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/Clases/CanalTest.java b/UyTube_aplicacion/test/Logica/Clases/CanalTest.java deleted file mode 100644 index 6e370186be3f0454dfe4da3d373ecbd691035726..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Clases/CanalTest.java +++ /dev/null @@ -1,1059 +0,0 @@ -package Logica.Clases; - -import Logica.DataType.DtCanal; -import Logica.DataType.DtComentario; -import Logica.DataType.DtListaDeReproduccion; -import Logica.DataType.DtValoracion; -import Logica.DataType.DtVideo; -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoListaDeReproduccion; -import Logica.Enumerados.TipoValoracion; -import java.sql.Date; -import java.sql.Time; -import java.util.ArrayList; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @Carlos_Facundo - */ -public class CanalTest { - - Canal c; - Canal c1; - - ListaDeReproduccion ldr; - int idLista; - - Video v1; - - Usuario u1; - - Comentario com; - - public CanalTest() { - c = new Canal(0, "nombre", "descripcion", Privacidad.PRIVADO); - c1 = new Canal(0, "nombre", "descripcion", Privacidad.PRIVADO); - idLista = ListaDeReproduccion.getNuevoId(); - ldr = new ListaDeReproduccion(idLista+1, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "categoria"); - v1 = new Video(0, "_nombre", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - u1 = new Usuario("nickname","email" ,new Date(2019-1900, 2, 2), "imagen", "contrasenia", "nombre","apellido" , c1.getDT()); - com = new Comentario(12,new Date(2019-1900, 2, 2) , "texto", 0, u1); - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - @Test - public void testCanal_nombreMal() { //-------------------------anda - System.out.println("setNombre"); - Canal instance = null; - try{ - instance = new Canal(0, "", "descripcion", Privacidad.PRIVADO); - }catch(Exception e){ - assertNull(instance); - } - - } - - @Test - public void testGetNombre() { - System.out.println("getNombre"); - Canal instance = c; - String expResult = "nombre"; - String result = instance.getNombre(); - assertEquals(expResult, result); - } - - @Test - public void testGetDescripcion() { - System.out.println("getDescripcion"); - Canal instance = c; - String expResult = "descripcion"; - String result = instance.getDescripcion(); - assertEquals(expResult, result); - } - - @Test - public void testGetPrivacidad() { - System.out.println("getPrivacidad"); - Canal instance = c; - Privacidad expResult = Privacidad.PRIVADO; - Privacidad result = instance.getPrivacidad(); - assertEquals(expResult, result); - } - - @Test - public void testGetId() { - System.out.println("testGetId"); - Canal instance = c; - int expResult = 0; - int result = instance.getId(); - assertEquals(expResult, result); - } - - @Test - public void testSetPrivacidad() { - System.out.println("setPrivacidad"); - Canal instance = c; - instance.setPrivacidad(Privacidad.PUBLICO); - assertEquals(Privacidad.PUBLICO, c.getPrivacidad()); - } - @Test - public void testSetPrivacidad2() { - System.out.println("setPrivacidad"); - Canal instance = new Canal(0, "nombre", "descripcion", Privacidad.PRIVADO); - instance.setPrivacidad(Privacidad.PUBLICO); - int id = Video.getNuevoId(); - DtVideo dt1 = new DtVideo(id+1, "vid1", "desc", new Time(1, 2, 3), new Date(2010-1900, 5, 25), "url_vid", Privacidad.PUBLICO, "MUSICA", 0, 0); - DtVideo dt2 = new DtVideo(id+2, "vid2", "desc", new Time(1, 2, 3), new Date(2010-1900, 5, 25), "url_vid", Privacidad.PRIVADO, "MUSICA", 0, 0); - DtVideo dt3 = new DtVideo(id+3, "vid3", "desc", new Time(1, 2, 3), new Date(2010-1900, 5, 25), "url_vid", Privacidad.PUBLICO, "MUSICA", 0, 0); - instance.agregarVideo(dt1); - instance.agregarVideo(dt2); - instance.agregarVideo(dt3); - instance.modificarVideo(dt1); - instance.modificarVideo(dt2); - instance.modificarVideo(dt3); - - instance.agregarListaParticular(new DtListaDeReproduccion(id, "nombre_l1", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "categoria")); - instance.agregarListaParticular(new DtListaDeReproduccion(id, "nombre_l2", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "categoria")); - instance.agregarListaParticular(new DtListaDeReproduccion(id, "nombre_l3", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "categoria")); - - instance.setPrivacidad(Privacidad.PRIVADO); - - ArrayList<DtVideo> lv = instance.listarVideos(); - ArrayList<DtListaDeReproduccion> lldr = instance.listarListasDeReproduccion(false); - - for (int i = 0; i < lv.size(); i++){ - if (lv.get(i).getPrivacidad() != Privacidad.PRIVADO){ - assertTrue(false); - return; - } - } - for (int i = 0; i < lldr.size(); i++){ - if (lldr.get(i).getPrivacidad() != Privacidad.PRIVADO){ - assertTrue(false); - return; - } - } - assertTrue(true); - } - - - - - @Test - public void testSetNombre() { - System.out.println("setNombre"); - Canal instance = c; - instance.setNombre("nombre"); - String expResult = "nombre"; - assertEquals(expResult, instance.getNombre()); - } - - @Test - public void testSetNombre_basura() { //------------------------anda - System.out.println("setNombre"); - Canal instance = c; - try{ - instance.setNombre(""); - }catch(Exception e){ - assertNull(null); - } - - } - - @Test - public void testSetDescripcion() { - System.out.println("setDescripcion"); - Canal instance = c; - instance.setDescripcion("descripcion"); - String expResult = "descripcion"; - assertEquals(expResult, instance.getDescripcion()); - } - - @Test - public void testGetDT() { - System.out.println("getDT"); - Canal instance = c; - DtCanal expResult = new DtCanal(0, "nombre", "descripcion", Privacidad.PRIVADO); - DtCanal result = instance.getDT(); - assertEquals(expResult.toString(), result.toString()); - } - - @Test - public void testGetNuevoId() { - System.out.println("getNuevoId"); - int expResult = Canal.getNuevoId() + 1; - int result = Canal.getNuevoId(); - assertEquals(expResult, result); - } - - @Test - public void testActualizarListasPorDefecto() { - System.out.println("actualizarListasPorDefecto"); - Canal instance = c1; - instance.actualizarListasPorDefecto(); - - // TODO review the generated test code and remove the default call to fail. - //***************************fail("The test case is a prototype."); - } - - @Test - public void testAgregarComentarioAVideo_3args() { - System.out.println("agregarComentarioAVideo"); - Canal instance = c; - int id = Video.getNuevoId()+1; - Video v = new Video(id, "_nombre", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - instance.agregarVideo(v.getDt()); - int expResult = instance.listarComentariosDeVideo(v.getId()).size() + 1; - Comentario comentario = new Comentario(0, new Date(0, 0, 0), "texto", 0, u1); - instance.agregarComentarioAVideo(v.getId(), comentario.getDT(), u1); - int result = instance.listarComentariosDeVideo(v.getId()).size(); - assertEquals(expResult, result); - } - - - @Test(expected = RuntimeException.class) - public void testAgregarComentarioAVideo_3args2() { - System.out.println("agregarComentarioAVideo"); - Canal instance = c; - - Comentario comentario = new Comentario(0, new Date(0, 0, 0), "texto", 0, u1); - instance.agregarComentarioAVideo(5879, 1, comentario.getDT(), u1); - } - -/* - @Test - public void testAgregarComentarioAVideo_4args() { - System.out.println("agregarComentarioAVideo"); - Canal instance = c; - int id = Video.getNuevoId()+1; - Video v = new Video(id, "_nombre", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - instance.agregarVideo(v.getDt()); - - int idC = Comentario.getNuevoID()+1; - Comentario comentario1 = new Comentario(idC, new Date(0, 0, 0), "texto", 0, u1); - - int expResult = instance.listarComentariosDeVideo(v.getId()).size() + 1; - - Comentario comentario = new Comentario(0, new Date(0, 0, 0), "texto", 0, u1); - instance.agregarComentarioAVideo(v.getId(),comentario1.getId(), comentario.getDT(), u1); - int result = instance.listarComentariosDeVideo(v.getId()).size(); - assertEquals(expResult, result); - } - */ -// @Test -// public void testAgregarComentarioAVideo2_4args() { -// System.out.println("agregarComentarioAVideo"); -// Canal instance = c; -// int idC = Comentario.getNuevoID()+1; -// Comentario comentario1 = new Comentario(idC, new Date(0, 0, 0), "texto", 0, u1); -// Comentario comentario = new Comentario(0, new Date(0, 0, 0), "texto", 0, u1); -// instance.agregarComentarioAVideo(v1.getId(),comentario1.getId(), comentario.getDT(), u1); -// int result = instance.listarComentariosDeVideo(v1.getId()).size(); -// assertEquals(result+1, result); -// } - - @Test - public void testAgregarListaParticular() { //------------------------anda - System.out.println("agregarListaParticular"); - DtListaDeReproduccion listaReproduccion = ldr.getDt(); - Canal instance = c1; - instance.agregarListaParticular(listaReproduccion); - } - - @Test - public void testAgregarListaParticular_DtLdrNull() { //--------------anda - System.out.println("agregarListaParticular"); - DtListaDeReproduccion listaReproduccion = ldr.getDt(); - Canal instance = c1; - try{ - instance.agregarListaParticular(null); - }catch(Exception e){ - assertNull(null); - } - } - - @Test - public void testAgregarListaParticular_NombreLdrVacio() { //---------anda - System.out.println("agregarListaParticular"); - - DtListaDeReproduccion listaReproduccion = new DtListaDeReproduccion(78, "", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "musical"); - Canal instance = c1; - try{ - instance.agregarListaParticular(listaReproduccion); - }catch(Exception e){ - assertNull(null); - } - } - - @Test - public void testAgregarListaParticular_PublicaBien() { //----------------anda - System.out.println("agregarListaParticular"); - - DtListaDeReproduccion listaReproduccion = new DtListaDeReproduccion(78, "gfd", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "musical"); - Canal instance = c1; - try{ - instance.agregarListaParticular(listaReproduccion); - }catch(Exception e){ - assertNull(null); - } - } - @Test - public void testAgregarListaParticular_PublicaMal() { //----------------anda - System.out.println("agregarListaParticular"); - - DtListaDeReproduccion listaReproduccion = new DtListaDeReproduccion(78, "gfd", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "musical"); - Canal instance = c1; - c1.setPrivacidad(Privacidad.PUBLICO); - try{ - instance.agregarListaParticular(listaReproduccion); - }catch(Exception e){ - assertNull(null); - } - } - - @Test - public void testAgregarListaParticular_CategoriaVacia() { //------------anda - System.out.println("agregarListaParticular"); - - DtListaDeReproduccion listaReproduccion = new DtListaDeReproduccion(78, "gfd", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, ""); - Canal instance = c1; - try{ - instance.agregarListaParticular(listaReproduccion); - }catch(Exception e){ - assertNull(null); - } - } - - @Test - public void testAgregarListaParticular_Repetida() { //------------anda - System.out.println("agregarListaParticular"); - - DtListaDeReproduccion listaReproduccion = new DtListaDeReproduccion(78, "gfd", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "fghgh"); - Canal instance = c1; - DtListaDeReproduccion listaReproduccion2 = new DtListaDeReproduccion(78, "gfd", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "fghgh"); - c1.agregarListaParticular(listaReproduccion); - try{ - c1.agregarListaParticular(listaReproduccion2); - }catch(Exception e){ - assertNull(null); - } - } - - @Test - public void testAgregarListaParticular_Otra() { //----------------------anda - System.out.println("agregarListaParticular"); - - DtListaDeReproduccion listaReproduccion = new DtListaDeReproduccion(78, "gfd", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "fghgh"); - Canal instance = c1; - DtListaDeReproduccion listaReproduccion2 = new DtListaDeReproduccion(78, "fdgfd", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "fghgh"); - c1.agregarListaParticular(listaReproduccion); - try{ - c1.agregarListaParticular(listaReproduccion2); - }catch(Exception e){ - assertNull(null); - } - } - - @Test(expected = RuntimeException.class) - public void testQuitarValoracion() { - System.out.println("quitarValoracion"); - Canal instance = c; - - instance.quitarValoracion(0, "nickname"); - try { - instance.quitarValoracion(0, "Usu"); - assertNull(null); - } catch (Exception e) { - assertNotNull(null); - } - - - } - - @Test(expected = RuntimeException.class) - public void testAgregarModificarValoracion() { - System.out.println("agregarModificarValoracion"); - int id = 0; - DtValoracion valoracion = null; - Usuario usuario = null; - Canal instance = null; - instance.agregarModificarValoracion(id, valoracion, usuario); - // TODO review the generated test code and remove the default call to fail. - //**************************************** fail("The test case is a prototype."); - } - - @Test(expected = RuntimeException.class) - public void testAgregarModificarValoracion2() { - System.out.println("agregarModificarValoracion"); - int id = 0; - DtValoracion valoracion = null; - Usuario usuario = null; - Canal instance = c; - instance.agregarModificarValoracion(5792, valoracion, usuario); - // TODO review the generated test code and remove the default call to fail. - //**************************************** fail("The test case is a prototype."); - } - - @Test - public void testAgregarVideo() { //------------------------------anda - ArrayList<DtVideo> l = c.listarVideos(); - int esperado = l.size(); - c.agregarVideo(v1.getDt()); - int resultado=28; - - Video v2 = new Video(2, "nombre2", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - DtVideo dtv = v2.getDt(); - try{ - c.agregarVideo(dtv); - ArrayList<DtVideo> l2 = c.listarVideos(); - resultado = l2.size(); - - }catch(Exception e){ - assertEquals(esperado+1, resultado); - } - } - - @Test - public void testAgregarVideo_DtNULL() { //------------------------------anda - ArrayList<DtVideo> l = c.listarVideos(); - int esperado = l.size(); - c.agregarVideo(v1.getDt()); - int resultado=1; - - Video v2 = new Video(3, "nombre3", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - DtVideo dtv = v2.getDt(); - try{ - c.agregarVideo(null); - ArrayList<DtVideo> l2 = c.listarVideos(); - resultado = l2.size(); - - }catch(Exception e){ - assertEquals(esperado+1, resultado); - } - } - - @Test - public void testAgregarVideo_nombreVacio() { //------------------------------anda - - Canal instance = c; - try{ - instance.agregarVideo(new DtVideo(6, "", "_descripcion", new Time(0, 0, 0), new Date(119, 5, 8), "_urlVideoOriginal", Privacidad.PUBLICO, "_categoria", 0, 0)); - }catch(Exception e){ - assertNull(null); - } - } - - @Test - public void testAgregarVideo_DuracionNull() { //------------------------------anda - ArrayList<DtVideo> l = c.listarVideos(); - int esperado = l.size(); - c.agregarVideo(v1.getDt()); - int resultado=28; - - try{ - c.agregarVideo(new DtVideo(6, "nombre6", "_descripcion", null, new Date(119, 5, 8), "_urlVideoOriginal", Privacidad.PUBLICO, "_categoria", 0, 0)); - }catch(Exception e){ - ArrayList<DtVideo> l2 = c.listarVideos(); - resultado = l2.size(); - assertEquals(esperado+1, resultado); - } - } - - @Test - public void testAgregarVideo_FechaPNull() { //------------------------------anda - ArrayList<DtVideo> l = c.listarVideos(); - int esperado = l.size(); - c.agregarVideo(v1.getDt()); - int resultado=28; - - try{ - c.agregarVideo(new DtVideo(6, "nombre6", "_descripcion", new Time(0, 0, 0), null, "_urlVideoOriginal", Privacidad.PUBLICO, "_categoria", 0, 0)); - }catch(Exception e){ - ArrayList<DtVideo> l2 = c.listarVideos(); - resultado = l2.size(); - assertEquals(esperado+1, resultado); - } - } - - @Test - public void testAgregarVideo_UrlVacia() { //------------------------------anda - ArrayList<DtVideo> l = c.listarVideos(); - int esperado = l.size(); - c.agregarVideo(v1.getDt()); - int resultado=28; - - try{ - c.agregarVideo(new DtVideo(6, "nombre6", "_descripcion", new Time(0, 0, 0), new Date(119, 5, 8), "", Privacidad.PUBLICO, "_categoria", 0, 0)); - }catch(Exception e){ - ArrayList<DtVideo> l2 = c.listarVideos(); - resultado = l2.size(); - assertEquals(esperado+1, resultado); - } - } - - @Test - public void testAgregarVideo_CatVacia() { //------------------------------anda - ArrayList<DtVideo> l = c.listarVideos(); - int esperado = l.size(); - c.agregarVideo(v1.getDt()); - int resultado=28; - - try{ - c.agregarVideo(new DtVideo(6, "nombre6", "_descripcion", new Time(0, 0, 0), new Date(119, 5, 8), "_urlVideoOriginal", Privacidad.PUBLICO, "", 0, 0)); - }catch(Exception e){ - ArrayList<DtVideo> l2 = c.listarVideos(); - resultado = l2.size(); - assertEquals(esperado+1, resultado); - } - } - - @Test - public void testAgregarVideo_malPrivacidad() { //------------------- anda - System.out.println("agregarVideo"); - Canal instance = c1; - c1.setPrivacidad(Privacidad.PUBLICO); - instance.agregarVideo(v1.getDt()); - assertEquals(c1.getPrivacidad(), Privacidad.PUBLICO); - } - - @Test - public void testAgregarVideo_elMismoVideo() { //------------------- anda - ArrayList<DtVideo> l = c.listarVideos(); - int esperado = l.size(); - - c.agregarVideo(v1.getDt()); - int resultado=28; - - Video v3 = new Video(10, "nombre9", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - DtVideo dtv2 = v3.getDt(); - c.agregarVideo(dtv2); - - try { - Video v2 = new Video(9, "nombre9", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - c.agregarVideo(v2.getDt()); - } catch (Exception e) { - } - - ArrayList<DtVideo> l2 = c.listarVideos(); - resultado = l2.size(); - - assertEquals(esperado + 2, resultado); - } - - @Test - public void testAgregarVideo_otroVideo() { //------------------- anda - ArrayList<DtVideo> l = c.listarVideos(); - - int esperado = l.size(); - c.agregarVideo(v1.getDt()); - int resultado=28; - - Video v3 = new Video(10, "nombre10", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - DtVideo dtv2 = v3.getDt(); - c.agregarVideo(dtv2); - - Video v2 = new Video(9, "nombre9", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - try{ - c.agregarVideo(v2.getDt()); - ArrayList<DtVideo> l2 = c.listarVideos(); - resultado = l2.size(); - - }catch(Exception e){ - assertEquals(esperado+2, resultado); - } - } - - @Test - public void testAgregarVideoALista() { - System.out.println("agregarVideoALista"); - Canal instance = c; - int id = ListaDeReproduccion.getNuevoId(); - ListaDeReproduccion lr = new ListaDeReproduccion(id+1, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "categoria"); - instance.agregarListaParticular(lr.getDt()); - ArrayList<DtVideo> dtv = instance.listarVideosDeListaDeReproduccion(lr.getId()); - int esperado = dtv.size()+1; - - instance.agregarVideoALista(lr.getId(), v1); - int resultado = instance.listarVideosDeListaDeReproduccion(lr.getId()).size(); - - assertEquals(esperado, resultado); - } - @Test(expected = RuntimeException.class) - public void testAgregarVideoALista2() { - System.out.println("agregarVideoALista"); - Canal instance = c; - instance.agregarVideoALista(2, v1); - - ArrayList<DtVideo> dtv = instance.listarVideosDeListaDeReproduccion(ldr.getId()); - int esperado = dtv.size()+1; - - int resultado = instance.listarVideosDeListaDeReproduccion(ldr.getId()).size(); - - assertEquals(esperado, resultado); - } - - @Test(expected = RuntimeException.class) - public void testListarComentariosDeVideo() { - System.out.println("listarComentariosDeVideo"); - Canal instance = c; - DtVideo v = new DtVideo(0, "nombre", "descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "urlVideoOriginal", Privacidad.PRIVADO, "categoria", 0, 0); - DtComentario DtCom = new DtComentario(0, u1.getNickname(), new Date(0, 0, 0), "texto", 0); - c.agregarVideo(v); - c.agregarComentarioAVideo(v.getId(),DtCom , u1); - ArrayList<DtComentario> expResult = new ArrayList<>(); - expResult.add(DtCom); - ArrayList<DtComentario> result = instance.listarComentariosDeVideo(v.getId()); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //****************************************fail("The test case is a prototype."); - } - - @Test(expected = RuntimeException.class) - public void testListarComentariosDeVideo2() { - System.out.println("listarComentariosDeVideo"); - Canal instance = c; - ArrayList<DtComentario> result = instance.listarComentariosDeVideo(9005); - // TODO review the generated test code and remove the default call to fail. - //****************************************fail("The test case is a prototype."); - } - - @Test - public void testListarListasDeReproduccion() { - System.out.println("listarListasDeReproduccionPORDEFECTO"); - Canal instance = c; - ArrayList<DtListaDeReproduccion> ArrayResult = instance.listarListasDeReproduccion(true); - assertEquals(ArrayResult.toString().contains("PARTICULAR"), false); - // TODO review the generated test code and remove the default call to fail. - //**************************************** fail("The test case is a prototype."); - } - - @Test - public void testListarValoracionesDeVideo() { - System.out.println("listarValoracionesDeVideo"); - Canal instance = c; - int id = Video.getNuevoId()+1; - Video v2 = new Video(id, "_nombre_", "_descripcion", new Time(1, 1, 1), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - instance.agregarVideo(v2.getDt()); - - Valoracion val = new Valoracion(TipoValoracion.LIKE, u1); - instance.agregarModificarValoracion(id, val.getDT(), u1); - - ArrayList<DtValoracion> expResult = new ArrayList(); - expResult.add(val.getDT()); - ArrayList<DtValoracion> result = instance.listarValoracionesDeVideo(id); - assertEquals(expResult.size(), result.size()); - } - - @Test(expected = RuntimeException.class) - public void testListarValoracionesDeVideo2() { - System.out.println("listarValoracionesDeVideo"); - Canal instance = c; - ArrayList<DtValoracion> result = instance.listarValoracionesDeVideo(922); - } - - @Test - public void testListarVideos() { - System.out.println("listarVideos"); - Canal instance = c; - instance.agregarVideo(v1.getDt()); - - ArrayList<DtVideo> expResult = new ArrayList(); - expResult.add(v1.getDt()); - - ArrayList<DtVideo> result = instance.listarVideos(); - assertEquals(expResult.size(), result.size()); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - - } - - @Test(expected = RuntimeException.class) - public void testListarVideosDeListaDeReproduccion() { - System.out.println("listarVideosDeListaDeReproduccion"); - Canal instance = c; - ArrayList<DtVideo> result = instance.listarVideosDeListaDeReproduccion(456789); - } - - - @Test - public void testModificar() { //--------------------------------anda - System.out.println("modificar"); - Canal can1 = new Canal(Canal.getNuevoId(), "nombre", "descripcion", Privacidad.PRIVADO); - DtCanal dtc = can1.getDT(); - String antes = dtc.toString(); - - DtCanal dtc2 = new DtCanal(Canal.getNuevoId(), "otronombre", "otradescripcion", Privacidad.PRIVADO); - String despues = dtc2.toString(); - assertNotEquals(despues, antes); - } - - @Test - public void testModificar_privacidad() {//----------------------------- anda - System.out.println("modificar"); - Canal instance = new Canal(0, "dsd", "dfs", Privacidad.PUBLICO); - instance.agregarVideo(v1.getDt()); - instance.modificar(new DtCanal(0, "nombre", "descripcion", Privacidad.PRIVADO)); - assertNull(null); - } - @Test - public void testModificar_privacidad_otra() {//--------------------------------------- anda - System.out.println("modificar"); - Canal instance = new Canal(0, "dsd", "dfs", Privacidad.PRIVADO); - instance.agregarVideo(v1.getDt()); - instance.modificar(new DtCanal(0, "nombre", "descripcion", Privacidad.PUBLICO)); - assertNull(null); - } - - @Test - public void testModificar_basura() { //--------------------------------anda - System.out.println("modificar"); - Canal instance = c; - try{ - instance.modificar(new DtCanal(0, "", "descripcion", Privacidad.PRIVADO)); - }catch(Exception e){ - assertEquals(true,true); - } - } - - @Test(expected = RuntimeException.class) - public void testModificarListaDeReproduccion() {//-------------------No anda - System.out.println("modificarListaDeReproduccion"); - Canal instance = c; - instance.modificarListaDeReproduccion(null); - } - - - @Test(expected = RuntimeException.class) - public void testModificarListaDeReproduccion1() { - System.out.println("modificarListaDeReproduccion"); - Canal instance = c; - int x = Canal.getNuevoId(); - ListaDeReproduccion l = new ListaDeReproduccion(x+1, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "categoria"); - c.agregarListaParticular(l.getDt()); - instance.modificarListaDeReproduccion(l.getDt()); - assertNull(null); - } - - @Test - public void testModificarListaDeReproduccion2() { - System.out.println("modificarLdr"); - Canal instance = c; - int id = ListaDeReproduccion.getNuevoId() + 1; - DtListaDeReproduccion dt1 = new DtListaDeReproduccion(id+1, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "categoria"); - instance.agregarListaParticular(dt1); - DtListaDeReproduccion dt2 = new DtListaDeReproduccion(id, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "categoria"); - - try { - instance.modificarListaDeReproduccion(dt2); - assertNull(null); - } catch (Exception e) { - assertNotNull(null); - } - } - - @Test(expected = RuntimeException.class) - public void testModificarListaDeReproduccion3() { - System.out.println("modificarListaDeReproduccion"); - Canal instance = new Canal(0, "dsd", "dfs", Privacidad.PRIVADO);; - - int id = ListaDeReproduccion.getNuevoId() +1; - instance.agregarListaParticular(new DtListaDeReproduccion(id, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "categoria")); - - instance.modificarListaDeReproduccion(new DtListaDeReproduccion(id, "nombre", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "categoria")); - } - - - - @Test - public void testModificarVideo() { - System.out.println("modificarVideo"); - Canal instance = c1; - - - try{ - instance.modificarVideo(null); - }catch(Exception e){ - assertNull(null); - } - } - - @Test - public void testModificarVideo1() { - System.out.println("modificarVideo"); - Canal instance = c1; - c1.agregarVideo(v1.getDt()); - - - try{ - instance.modificarVideo(v1.getDt()); - }catch(Exception e){ - assertNull(null); - } - } - - - - @Test - public void testModificarVideo2() { - System.out.println("modificarVideo"); - Canal instance = c; - int id = Video.getNuevoId() + 1; - DtVideo dt1 = new DtVideo(id, "videito", "descripcioncita", new Time(1, 2, 3), new Date(2010-1900, 5, 25), "urlcita", Privacidad.PRIVADO, "MUSICA", 0, 0); - instance.agregarVideo(dt1); - DtVideo dt2 = new DtVideo(id, "vid", "desc", new Time(1, 2, 3), new Date(2010-1900, 5, 25), "url_vid", Privacidad.PRIVADO, "MUSICA", 0, 0); - - try { - instance.modificarVideo(dt2); - assertNull(null); - } catch (Exception e) { - assertNotNull(null); - } - } - - @Test - public void testModificarVideo3() { - System.out.println("modificarVideo"); - Canal instance = c1; - int x = Video.getNuevoId(); - Video v = new Video(x+1, "_nombre", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - v.setPrivacidad(Privacidad.PUBLICO); - c1.agregarVideo(v.getDt()); - - - try{ - instance.modificarVideo(v.getDt()); - }catch(Exception e){ - assertNull(null); - } - } - - - - @Test - public void testObtenerListaDeReproduccion() { - System.out.println("obtenerListaDeReproduccion"); - int id = ListaDeReproduccion.getNuevoId()+1; - Canal instance = c; - ListaDeReproduccion l = new ListaDeReproduccion(id, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "categoria"); - DtListaDeReproduccion expResult = l.getDt(); - instance.agregarListaParticular(l.getDt()); - DtListaDeReproduccion result = instance.obtenerListaDeReproduccion(id); - assertEquals(expResult.toString(), result.toString()); - // TODO review the generated test code and remove the default call to fail. - //**************************************** fail("The test case is a prototype."); - } - @Test(expected = RuntimeException.class) - public void testObtenerListaDeReproduccion2() { - System.out.println("obtenerListaDeReproduccion"); - Canal instance = c; - DtListaDeReproduccion expResult = ldr.getDt(); - DtListaDeReproduccion result = instance.obtenerListaDeReproduccion(ldr.getId()); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //**************************************** fail("The test case is a prototype."); - } - - @Test - public void testObtenerListasEnCategoria() { - System.out.println("obtenerListasEnCategoria"); - Canal instance = c; - ListaDeReproduccion l = new ListaDeReproduccion(0, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "Arctic Monkeys"); - c.agregarListaParticular(l.getDt()); - ArrayList<DtListaDeReproduccion> ArrayResult = instance.obtenerListasEnCategoria("Arctic Monkeys"); - - - for (int i = 0; i < ArrayResult.size(); i++){ - if (ArrayResult.get(i).getCategoria() != "Arctic Monkeys") { - assertTrue(false); - return; - } - } - assertTrue(true); - - } - - @Test - public void testObtenerListasEnCategoria1() { - System.out.println("obtenerVideosEnCategoria"); - Canal instance = c; - ArrayList<DtListaDeReproduccion> ArrayResult = instance.obtenerListasEnCategoria("Monos Articos"); - - assertEquals(0, ArrayResult.size()); - } - - @Test - public void testObtenerDtVideo() { - System.out.println("obtenerDtVideo"); - Canal instance = c; - int id = Video.getNuevoId()+1; - Video v = new Video(id, "_nombre", "_descripcion",new Time(0, 0, 0) ,new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - instance.agregarVideo(v.getDt()); - String expResult = v.getDt().toString(); - String resultado = c.obtenerDtVideo(id).toString(); - assertEquals(expResult, resultado); - } - @Test(expected = RuntimeException.class) - public void testObtenerDtVideo2() { - System.out.println("obtenerDtVideo"); - DtVideo dtv = v1.getDt(); - String esperado = dtv.toString(); - c1.agregarVideo(dtv); - - String resultado = c1.obtenerDtVideo(1).toString(); - assertEquals(esperado, resultado); - } - - @Test - public void testObtenerDtVideo_noPertenece() { - System.out.println("obtenerDtVideo"); - Canal instance = c; - DtVideo result = null; - try{ - result = instance.obtenerDtVideo(54654); - }catch(Exception e){ - assertNull(null); - } - } - - @Test - public void testObtenerVideo() { - System.out.println("obtenerVideo"); - - Canal instance = c; - c.agregarVideo(v1.getDt()); - int idVideo = c.listarVideos().get(0).getId(); - - Video result = null; - result = instance.obtenerVideo(idVideo); - assertNotNull(result); - } - - @Test - public void testObtenerVideo_noPertenece() { - System.out.println("obtenerVideo"); - Canal instance = c; - Video result = null; - try{ - result = instance.obtenerVideo(6546); - }catch(Exception e){ - assertNull(null); - } - } - - @Test - public void testObtenerVideosEnCategoria() { - System.out.println("obtenerVideosEnCategoria"); - Canal instance = c; - Video v = new Video(0, "_nombre", "_descripcion", new Time(0, 0, 0), new Date(0, 0, 0), "_urlVideoOriginal", "Deporte"); - c.agregarVideo(v.getDt()); - ArrayList<DtVideo> ArrayResult = instance.obtenerVideosEnCategoria("Deporte"); - - for (int i = 0; i < ArrayResult.size(); i++){ - if (ArrayResult.get(i).getCategoria() != "Deporte") { - assertTrue(false); - return; - } - } - assertTrue(true); - } - - @Test - public void testObtenerVideosEnCategoria1() { - System.out.println("obtenerVideosEnCategoria"); - Canal instance = c; - ArrayList<DtVideo> ArrayResult = instance.obtenerVideosEnCategoria("_categoria"); - - for (int i = 0; i < ArrayResult.size(); i++){ - if (ArrayResult.get(i).getCategoria().equals("Deporte")) { - assertTrue(false); - return; - } - } - assertTrue(true); - } - - @Test - public void testQuitarVideoDeListaDeReproduccion() { - System.out.println("quitarVideoDeListaDeReproduccion"); - Canal instance = c; - int id = ListaDeReproduccion.getNuevoId()+1; - int idV = Video.getNuevoId()+1; - ListaDeReproduccion l = new ListaDeReproduccion(id, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "categoria"); - Video v = new Video(idV, "_nombre", "_descripcion", new Time(1, 1, 1), new Date(0, 0, 0), "_urlVideoOriginal", "_categoria"); - instance.agregarListaParticular(ldr.getDt()); - instance.agregarVideoALista(id, v); - - - ArrayList<DtVideo> expResult = new ArrayList(); - - instance.quitarVideoDeListaDeReproduccion(l.getId(), v.getId()); - assertEquals(expResult.size(), instance.listarVideosDeListaDeReproduccion(id).size()); - } - - @Test(expected = RuntimeException.class) - public void testQuitarVideoDeListaDeReproduccion2() { - System.out.println("quitarVideoDeListaDeReproduccion"); - Canal instance = c; - instance.quitarVideoDeListaDeReproduccion(ldr.getId(), v1.getId()); - assertEquals(true,true); - } - // TODO review the generated test code and remove the default call to fail. - //**************************************** fail("The test case is a prototype."); - - - @Test - public void testValidarListaParticular() { //--------------mas o menos anda - System.out.println("validarListaParticular"); - String nombreLista = "nombre"; - Canal instance = c1; - boolean expResult = true; - boolean result = instance.validarListaParticular(nombreLista); - assertEquals(expResult, result); - } - - @Test - public void testObtenerValoracion() {//-------------------------------- anda - System.out.println("obtenerValoracion"); - Canal instance = c; - - c.agregarVideo(v1.getDt()); - int idVideo = c.listarVideos().get(0).getId(); - - DtValoracion result = null; - result = instance.obtenerValoracion(idVideo, u1.getNickname()); - assertNull(null); - } - @Test - public void testObtenerValoracion_basura() {//--------------------------anda - System.out.println("obtenerVideo"); - Canal instance = c; - DtValoracion result = null; - try{ - result = instance.obtenerValoracion(4654, u1.getNickname()); - }catch(Exception e){ - assertNull(null); - } - } - -} diff --git a/UyTube_aplicacion/test/Logica/Clases/CategoriaTest.java b/UyTube_aplicacion/test/Logica/Clases/CategoriaTest.java deleted file mode 100644 index b415e375e14518f6a0ad480e2106b9edfccfaed1..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Clases/CategoriaTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Clases; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class CategoriaTest { - - public CategoriaTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of constructor method, of class Categoria. - */ - @Test - public void testCategoria_vacia() { - System.out.println("testCategoria_vacia"); - Categoria result = null; - try { - result = new Categoria(""); - } catch (Exception e) { - assertNull(result); - } - - - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - /** - * Test of getNombre method, of class Categoria. - */ - @Test - public void testGetNombre() { - System.out.println("getNombre"); - Categoria instance = new Categoria("Cat test"); - String expResult = "Cat test"; - String result = instance.getNombre(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/Clases/ComentarioTest.java b/UyTube_aplicacion/test/Logica/Clases/ComentarioTest.java deleted file mode 100644 index ef9656856b4056fcb27f9834f1c2b6a8491b80cd..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Clases/ComentarioTest.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Clases; - -import Logica.DataType.DtCanal; -import Logica.DataType.DtComentario; -import Logica.Enumerados.Privacidad; -import java.sql.Date; -import java.util.ArrayList; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Carlos BM - */ -public class ComentarioTest { - - Usuario user; - Comentario com; - Date fecha; - public ComentarioTest() { - fecha = new Date(190,7,4); - user = new Usuario("MCbolso", "mcbolso@gmail.com",fecha, "imagen.jpg", "dsfsdf", "mariano", "Castro", new DtCanal(0, "mi_canal", "un_canal_mas", Privacidad.PRIVADO)); - com = new Comentario(0, fecha, "una cagada", 0, user); - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getNuevoID method, of class Comentario. - */ - @Test - public void testGetNuevoID() { - System.out.println("getNuevoID"); - Comentario instance = com; - int expResult = 1; - int result = instance.getNuevoID(); - assertEquals(expResult, result); - } - - /** - * Test of getId method, of class Comentario. - */ - @Test - public void testGetId() { - System.out.println("getId"); - Comentario instance = com; - int expResult = 0; - int result = instance.getId(); - assertEquals(expResult, result); - } - - /** - * Test of getFecha method, of class Comentario. - */ - @Test - public void testGetFecha() { - System.out.println("getFecha"); - Comentario instance = com; - Date expResult = fecha; - Date result = instance.getFecha(); - assertEquals(expResult, result); - } - - /** - * Test of getTexto method, of class Comentario. - */ - @Test - public void testGetTexto() { - System.out.println("getTexto"); - Comentario instance = com; - String expResult = "una cagada"; - String result = instance.getTexto(); - assertEquals(expResult, result); - } - - /** - * Test of getNivelSubComentario method, of class Comentario. - */ - @Test - public void testGetNivelSubComentario() { - System.out.println("getNivelSubComentario"); - Comentario instance = com; - int expResult = 0; - int result = instance.getNivelSubComentario(); - assertEquals(expResult, result); - } - - /** - * Test of getUsr method, of class Comentario. - */ - @Test - public void testGetUsr() { - System.out.println("getUsr"); - Comentario instance = com; - Usuario expResult = user; - Usuario result = instance.getUsr(); - assertEquals(expResult, result); - } - - /** - * Test of toString method, of class Comentario. - */ - @Test - public void testToString() { - System.out.println("toString"); - Comentario instance = com; - String expResult = "Comentario{id=0, fecha=2090-08-04, texto=una cagada, nivelSubComentario=0}"; - String result = instance.toString(); - assertEquals(expResult, result); - } - - @Test - public void testComentario_basuraFecha() { - System.out.println("comentario"); - try { - Comentario comy = new Comentario(0, null, "una cagada", 0, user); - } catch (Exception e) { - assertEquals(true, true); - } - } - - @Test - public void testComentario_basura_usuario() { - System.out.println("comentario"); - try { - Comentario comy = new Comentario(5, fecha, "una cagada", 0, null); - } catch (Exception e) { - assertEquals(true, true); - } - } - - /** - * Test of agregarSubComentario method, of class Comentario. - */ - @Test - public void testAgregarSubComentario() { - System.out.println("agregarSubComentario"); - int idComPadre = 0; - DtComentario dtC = new DtComentario(1, "otroNickname", fecha, "otra cagada", 1); - Usuario usr = user; - Comentario instance = com; - boolean expResult = true; - boolean result = instance.agregarSubComentario(idComPadre, dtC, usr); - assertEquals(expResult, result); - } - - @Test - public void testAgregarSubComentarioNoagrega() { - System.out.println("agregarSubComentario"); - com.agregarSubComentario(1, new DtComentario(1, "otroNickname", fecha, "otra cagada", 1), user); - int idComPadre = 1; - DtComentario dtC = new DtComentario(2, "otroNickname", fecha, "otra cagada", 1); - Usuario usr = user; - Comentario instance = com; - boolean expResult = false; - boolean result = instance.agregarSubComentario(idComPadre, dtC, usr); - assertEquals(expResult, result); - } - - @Test - public void testAgregarSubComentarioNoagrega_basura_1() { - System.out.println("agregarSubComentario"); - int idComPadre = 1; - Usuario usr = user; - Comentario instance = com; - boolean expResult = false; - boolean result =false; - try{ - result = instance.agregarSubComentario(idComPadre, null, usr); - }catch(Exception e){ - assertEquals(true, true); - } - } - - @Test - public void testAgregarSubComentarioNoagrega_basura_2() { - System.out.println("agregarSubComentario"); - int idComPadre = 1; - DtComentario dtC = new DtComentario(2, "otroNickname", fecha, "otra cagada", 1); - Comentario instance = com; - boolean expResult = false; - boolean result = false; - try{ - result = instance.agregarSubComentario(idComPadre, dtC, null); - }catch(Exception e){ - assertEquals(true, true); - } - } - - /** - * Test of getDT method, of class Comentario. - */ - @Test - public void testGetDT() { - System.out.println("getDT"); - Comentario instance = com; - DtComentario expResult = new DtComentario(0, "MCbolso", fecha, "una cagada", 0); - DtComentario result = instance.getDT(); - assertEquals(expResult.toString(), result.toString()); - } - - /** - * Test of listarSubComentarios method, of class Comentario. - */ - @Test - public void testListarSubComentarios() { - System.out.println("listarSubComentarios"); - Comentario instance = com; - com.agregarSubComentario(0, new DtComentario(1, "otroNickname", fecha, "otra cagada", 1), user); - com.agregarSubComentario(0, new DtComentario(1, "otroNickname2", fecha, "otra cagada", 1), user); - com.agregarSubComentario(0, new DtComentario(1, "otroNickname3", fecha, "otra cagada", 1), user); - com.agregarSubComentario(2, new DtComentario(1, "otroNickname4", fecha, "otra cagada", 1), user); - com.agregarSubComentario(4, new DtComentario(1, "otroNickname5", fecha, "otra cagada", 1), user); - com.agregarSubComentario(3, new DtComentario(1, "otroNickname6", fecha, "otra cagada", 1), user); - - ArrayList<DtComentario> expResult = new ArrayList(); - ArrayList<DtComentario> result = instance.listarSubComentarios(); - assertEquals(6, result.size()); - } - -} diff --git a/UyTube_aplicacion/test/Logica/Clases/ListaDeReproduccionTest.java b/UyTube_aplicacion/test/Logica/Clases/ListaDeReproduccionTest.java deleted file mode 100644 index 2869506f754d17b95e582c721d31dff90c6b49a6..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Clases/ListaDeReproduccionTest.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Clases; - -import Logica.DataType.DtListaDeReproduccion; -import Logica.DataType.DtVideo; -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoListaDeReproduccion; -import java.sql.Date; -import java.sql.Time; -import java.util.ArrayList; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class ListaDeReproduccionTest { - private ListaDeReproduccion ldrParticular = null; - private ListaDeReproduccion ldrPorDefecto = null; - Video v = null; - - public ListaDeReproduccionTest() { - ldrParticular = new ListaDeReproduccion(0, "mi lista", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - ldrPorDefecto = new ListaDeReproduccion(0, "mi lista", Privacidad.PRIVADO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED"); - - v = new Video(0, "_nombre", "_descripcion", new Time(0, 10, 15), new Date(2019-1900, 5, 15), "_urlVideoOriginal", "UNDEFINED"); - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getNuevoId method, of class ListaDeReproduccion. - */ - @Test - public void testGetNuevoId() { - System.out.println("getNuevoId"); - int expResult = 1; - int result = ListaDeReproduccion.getNuevoId(); - assertEquals(expResult, result); - - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - @Test - public void testGetNuevoId2() { - System.out.println("getNuevoId2"); - int expResult = 2; - int result = ListaDeReproduccion.getNuevoId(); - assertEquals(expResult, result); - - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of listarNombresDeListasPorDefecto method, of class ListaDeReproduccion. - */ - @Test - public void testListarNombresDeListasPorDefecto() { - System.out.println("listarNombresDeListasPorDefecto"); - ArrayList<String> expResult = new ArrayList(); - expResult.add("Ver mas tarde"); - ArrayList<String> result = ListaDeReproduccion.listarNombresDeListasPorDefecto(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - /** - * Test of agregarListaPorDefecto method, of class ListaDeReproduccion. - */ - @Test - public void testAgregarListaPorDefecto() { - System.out.println("agregarListaPorDefecto"); - ArrayList<String> expResult = new ArrayList(); - expResult.add("Ver mas tarde"); - expResult.add("Favoritos"); - ListaDeReproduccion.agregarListaPorDefecto("Favoritos"); - ArrayList<String> result = ListaDeReproduccion.listarNombresDeListasPorDefecto(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - @Test - public void testAgregarListaPorDefecto2() { - System.out.println("agregarListaPorDefecto2"); - ArrayList<String> expResult = new ArrayList(); - ArrayList<String> result = null; - expResult.add("Ver mas tarde"); - - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - try { - ListaDeReproduccion.agregarListaPorDefecto(""); - assertEquals(expResult, result); - } catch (Exception e) { - result = ListaDeReproduccion.listarNombresDeListasPorDefecto(); - assertEquals(expResult, result); - } - } - - /** - * Test of getId method, of class ListaDeReproduccion. - */ - @Test - public void testGetId() { - System.out.println("testGetId"); - ListaDeReproduccion instance = ldrParticular; - int expResult = 0; - int result = instance.getId(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - /** - * Test of getNombre method, of class ListaDeReproduccion. - */ - @Test - public void testGetNombre() { - System.out.println("getNombre"); - ListaDeReproduccion instance = ldrParticular; - String expResult = "mi lista"; - String result = instance.getNombre(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getPrivacidad method, of class ListaDeReproduccion. - */ - @Test - public void testGetPrivacidad() { - System.out.println("getPrivacidad"); - ListaDeReproduccion instance = ldrParticular; - Privacidad expResult = Privacidad.PRIVADO; - Privacidad result = instance.getPrivacidad(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of setPrivacidad method, of class ListaDeReproduccion. - */ - @Test - public void testSetPrivacidad() { - System.out.println("setPrivacidad"); - ListaDeReproduccion instance = ldrParticular; - instance.setPrivacidad(Privacidad.PUBLICO); - assertEquals(Privacidad.PUBLICO, ldrParticular.getPrivacidad()); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - instance.setPrivacidad(Privacidad.PRIVADO); - } - - /** - * Test of getTipo method, of class ListaDeReproduccion. - */ - @Test - public void testGetTipo() { - System.out.println("getTipo"); - ListaDeReproduccion instance = ldrParticular; - TipoListaDeReproduccion expResult = TipoListaDeReproduccion.PARTICULAR; - TipoListaDeReproduccion result = instance.getTipo(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of toString method, of class ListaDeReproduccion. - */ - @Test - public void testToString() { - System.out.println("toString"); - ListaDeReproduccion instance = ldrParticular; - String expResult = "ListaDeReproduccion{id=0, nombre=mi lista, privacidad=PRIVADO, tipo=PARTICULAR, categoria=UNDEFINED, misVideos.size=0}"; - String result = instance.toString(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - - /** - * Test of getCategoria method, of class ListaDeReproduccion. - */ - @Test - public void testGetCategoria() { - System.out.println("getCategoria"); - ListaDeReproduccion instance = ldrParticular; - String expResult = "UNDEFINED"; - String result = instance.getCategoria(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getDt method, of class ListaDeReproduccion. - */ - @Test - public void testGetDt() { - System.out.println("getDt"); - ListaDeReproduccion instance = null; - DtListaDeReproduccion expResult = new DtListaDeReproduccion(0, "mi lista", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - DtListaDeReproduccion result = ldrParticular.getDt(); - assertEquals(expResult.toString(), result.toString()); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - - /////////////////////////////////////////////////////////////////////////////////////////////////// - - - /** - * Test of agregarVideoA method, of class ListaDeReproduccion. - */ - @Test - public void testAgregarVideoA_null() { - System.out.println("agregarVideoA"); - ListaDeReproduccion instance = ldrParticular; - int expResult = instance.listarVideos().size(); - - try { - instance.agregarVideoA(null); - } catch (Exception e) { - assertEquals(expResult, instance.listarVideos().size()); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - - /** - * Test of agregarVideoA method, of class ListaDeReproduccion. - */ - @Test - public void testAgregarVideoA() { - System.out.println("agregarVideoA"); - int expResult = ldrParticular.listarVideos().size() +1; - ListaDeReproduccion instance = ldrParticular; - instance.agregarVideoA(v); - assertEquals(expResult, ldrParticular.listarVideos().size()); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - /** - * Test of constructor method, of class ListaDeReproduccion. - */ - @Test - public void testListaDeReproduccion_1() { - System.out.println("agregarVideoA"); - - try { - ListaDeReproduccion instance = new ListaDeReproduccion(0, "", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - } catch (Exception e) { - assertEquals(true, true); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - @Test - public void testListaDeReproduccion_2() { - System.out.println("agregarVideoA"); - - try { - ListaDeReproduccion instance = new ListaDeReproduccion(0, "mi lista", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, ""); - } catch (Exception e) { - assertEquals(true, true); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - @Test - public void testListaDeReproduccion_3() { - System.out.println("agregarVideoA"); - - try { - ListaDeReproduccion instance = new ListaDeReproduccion(0, "mi lista", Privacidad.PUBLICO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED"); - } catch (Exception e) { - assertEquals(true, true); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - @Test - public void testListaDeReproduccion_4() { - System.out.println("agregarVideoA"); - - try { - ListaDeReproduccion instance = new ListaDeReproduccion(0, "mi lista", Privacidad.PRIVADO, TipoListaDeReproduccion.POR_DEFECTO, "MUSICA"); - } catch (Exception e) { - assertEquals(true, true); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - - /** - * Test of listarVideos method, of class ListaDeReproduccion. - */ - - @Test - public void testListarVideos() { - System.out.println("listarVideos"); - ListaDeReproduccion instance = new ListaDeReproduccion(0, "mi lista", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED");; - instance.agregarVideoA(v); - - ArrayList<DtVideo> expResult = new ArrayList(); - expResult.add(v.getDt()); - - ArrayList<DtVideo> result = instance.listarVideos(); - assertEquals(expResult.size(), result.size()); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - - } - - /** - * Test of modificar method, of class ListaDeReproduccion. - */ - @Test - public void testModificar() { - System.out.println("modificar"); - DtListaDeReproduccion ldr = new DtListaDeReproduccion(0, "mi musica", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "MUSICA"); - ListaDeReproduccion instance = ldrParticular; - instance.modificar(ldr); - assertEquals(ldr.toString(), instance.getDt().toString()); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - @Test - public void testModificar_exp_1() { - System.out.println("testModificar_exp_1"); - ListaDeReproduccion instance = ldrPorDefecto; - DtListaDeReproduccion esperado = instance.getDt(); - try { - DtListaDeReproduccion ldr = new DtListaDeReproduccion(0, "mi musica", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "MUSICA"); - instance.modificar(ldr); - } catch (Exception e) { - assertEquals(esperado.toString(), instance.getDt().toString()); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - @Test - public void testModificar_exp_2() { - System.out.println("testModificar_exp_1"); - ListaDeReproduccion instance = ldrParticular; - DtListaDeReproduccion esperado = instance.getDt(); - try { - instance.modificar(null); - } catch (Exception e) { - assertEquals(esperado.toString(), instance.getDt().toString()); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - @Test - public void testModificar_exp_3() { - System.out.println("testModificar_exp_1"); - ListaDeReproduccion instance = ldrParticular; - DtListaDeReproduccion esperado = instance.getDt(); - try { - DtListaDeReproduccion ldr = new DtListaDeReproduccion(0, "", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "MUSICA"); - instance.modificar(ldr); - } catch (Exception e) { - assertEquals(esperado.toString(), instance.getDt().toString()); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - - /** - * Test of quitarVideo method, of class ListaDeReproduccion. - */ - - @Test - public void testQuitarVideo() { - System.out.println("quitarVideo"); - ListaDeReproduccion instance = new ListaDeReproduccion(0, "mi lista", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED");; - instance.agregarVideoA(v); - - ArrayList<DtVideo> expResult = new ArrayList(); - - instance.quitarVideo(v.getId()); - assertEquals(expResult.size(), instance.listarVideos().size()); - - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/Clases/PersonaTest.java b/UyTube_aplicacion/test/Logica/Clases/PersonaTest.java deleted file mode 100644 index 4a086f78e6482b8680d11b9b99be4d1ea458ad14..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Clases/PersonaTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Clases; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class PersonaTest { - - public PersonaTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of constructor method, of class Persona. - */ - @Test - public void testPersona() { - System.out.println("getNombre"); - Administrador instance = null; - try { - instance = new Administrador(0, "", "nombre", "apellido"); - } catch (Exception e) { - assertNull(instance); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getNombre method, of class Persona. - */ - @Test - public void testGetNombre() { - System.out.println("getNombre"); - Administrador instance = new Administrador(0, "contrasenia", "nombre", "apellido"); - String expResult = "nombre"; - String result = instance.getNombre(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getApellido method, of class Persona. - */ - @Test - public void testGetApellido() { - System.out.println("getApellido"); - Administrador instance = new Administrador(0, "contrasenia", "nombre", "apellido"); - String expResult = "apellido"; - String result = instance.getApellido(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of validarContrasenia method, of class Persona. - */ - @Test - public void testValidarContrasenia_correcta() { - System.out.println("testValidarContrasenia_correcta"); - String pass = "contrasenia"; - Administrador instance = new Administrador(0, "contrasenia", "nombre", "apellido"); - boolean expResult = true; - boolean result = instance.validarContrasenia(pass); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of validarContrasenia method, of class Persona. - */ - @Test - public void testValidarContrasenia_incorrecta() { - System.out.println("testValidarContrasenia_correcta"); - String pass = "contrasenia mala"; - Administrador instance = new Administrador(0, "contrasenia", "nombre", "apellido"); - boolean expResult = false; - boolean result = instance.validarContrasenia(pass); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/Clases/UsuarioTest.java b/UyTube_aplicacion/test/Logica/Clases/UsuarioTest.java deleted file mode 100644 index 61e7df375fff4978986102789437ee9aca2a19f1..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Clases/UsuarioTest.java +++ /dev/null @@ -1,1036 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Clases; - -import Logica.DataType.DtCanal; -import Logica.DataType.DtComentario; -import Logica.DataType.DtListaDeReproduccion; -import Logica.DataType.DtUsuario; -import Logica.DataType.DtValoracion; -import Logica.DataType.DtVideo; -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoListaDeReproduccion; -import Logica.Enumerados.TipoValoracion; -import java.sql.Date; -import java.sql.Time; -import java.util.ArrayList; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author pc01 - */ -public class UsuarioTest { - Usuario instance = null; - Video v = null; - ListaDeReproduccion ldr= null; - - public UsuarioTest() { - instance = new Usuario("nickname", "correo", new Date(2019 - 1900, 1, 1), - "imagen", "contrasenia", "nombre", "apellido", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - v = new Video(0, "nombre", "descripcion", new Time(1, 2, 3), new Date(2019 - 1900, 1, 2), "urlVideo", "UNDEFINED"); - ldr = new ListaDeReproduccion(0, "nombre", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - instance.agregarVideoACanal(v.getDt()); - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of constructor method, of class Usuario. - */ - @Test - public void testUsuario_exp1() { - System.out.println("testUsuario_exp1"); - Usuario instancia = null; - try { - instancia = new Usuario("", "correo", new Date(2019 - 1900, 1, 1), - "imagen", "contrasenia", "nombre", "apellido", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - } catch (Exception e) { - assertNull(instancia); - } - } - @Test - public void testUsuario_exp2() { - System.out.println("testUsuario_exp2"); - Usuario instancia = null; - try { - instancia = new Usuario("nickname", "", new Date(2019 - 1900, 1, 1), - "imagen", "contrasenia", "nombre", "apellido", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - } catch (Exception e) { - assertNull(instancia); - } - } - @Test - public void testUsuario_exp3() { - System.out.println("testUsuario_exp3"); - Usuario instancia = null; - try { - instancia = new Usuario("nickname", "correo", null, - "imagen", "contrasenia", "nombre", "apellido", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - } catch (Exception e) { - assertNull(instancia); - } - } - @Test - public void testUsuario_exp4() { - System.out.println("testUsuario_exp4"); - Usuario instancia = null; - try { - instancia = new Usuario("nickname", "correo", new Date(2019 - 1900, 1, 1), - "imagen", "contrasenia", "nombre", "apellido", - null); - } catch (Exception e) { - assertNull(instancia); - } - } - //---------------------------------------------------------------------------------------------- - /** - * Test of getNickname method, of class Usuario. - */ - @Test - public void testGetNickname() { - System.out.println("getNickname"); - String expResult = "nickname"; - String result = instance.getNickname(); - assertEquals(expResult, result); - } - - /** - * Test of getCorreo method, of class Usuario. - */ - @Test - public void testGetCorreo() { - System.out.println("getCorreo"); - String expResult = "correo"; - String result = instance.getCorreo(); - assertEquals(expResult, result); - } - - /** - * Test of getFechaNacimiento method, of class Usuario. - */ - @Test - public void testGetFechaNacimiento() { - System.out.println("getFechaNacimiento"); - Date expResult = new Date(2019 - 1900, 1, 1); - Date result = instance.getFechaNacimiento(); - assertEquals(expResult.toString(), result.toString()); - } - - /** - * Test of getImagen method, of class Usuario. - */ - @Test - public void testGetImagen() { - System.out.println("getImagen"); - String expResult = "imagen"; - String result = instance.getImagen(); - assertEquals(expResult, result); - } - - /** - * Test of getSeguidores method, of class Usuario. - */ - @Test - public void testGetSeguidores() { - System.out.println("getSeguidores"); - int expResult = 0; - int result = instance.getSeguidores(); - assertEquals(expResult, result); - } - - /** - * Test of getDT method, of class Usuario. - */ - @Test - public void testGetDT() { - System.out.println("getDT"); - DtUsuario expResult = new DtUsuario("nickname", "contrasenia", "nombre", "apellido", "correo", new Date(2019 - 1900, 1, 1), "imagen", 0); - DtUsuario result = instance.getDT(); - assertEquals(expResult.toString(), result.toString()); - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** - * Test of actualizarListasPorDefecto method, of class Usuario. - */ - @Test - public void testActualizarListasPorDefecto() { - System.out.println("actualizarListasPorDefecto"); - instance.actualizarListasPorDefecto(); - assertNull(null); - } - - /** - * Test of agregarComentarioAVideo method, of class Usuario. - */ - @Test - public void testAgregarComentarioAVideo_3args_1() { - System.out.println("agregarComentarioAVideo"); - int idVideo = 0; - DtComentario DtComentario = null; - Usuario Usu = instance; - try { - instance.agregarComentarioAVideo(idVideo, DtComentario, Usu); - assertNull(instance); // por poner algo que no sea null... - } catch (Exception e) { - assertNull(null); - } - } - @Test - public void testAgregarComentarioAVideo_3args_2() { - System.out.println("agregarComentarioAVideo"); - int idVideo = 0; - DtComentario DtComentario = new DtComentario(2, "nick", new Date(2019-1900, 1, 1), "texto", 0); - Usuario Usu = null; - try { - instance.agregarComentarioAVideo(idVideo, DtComentario, Usu); - assertEquals(false, true); - } catch (Exception e) { - assertEquals(true, true); - } - } - @Test - public void testAgregarComentarioAVideo_3args_3() { - System.out.println("testAgregarComentarioAVideo_3args_3"); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - DtComentario DtComentario = new DtComentario(2, "nick", new Date(2019-1900, 1, 1), "texto", 0); - Usuario Usu = instance; - try { - instance.agregarComentarioAVideo(idVideo, DtComentario, Usu); - assertEquals(true, true); - } catch (Exception e) { - assertEquals(false, true); - } - } - - /** - * Test of agregarComentarioAVideo method, of class Usuario. - */ - @Test - public void testAgregarComentarioAVideo_4args_1() { - System.out.println("testAgregarComentarioAVideo_4args_1"); - Usuario Usu = instance; - DtComentario DtComentario = new DtComentario(0, "nick", new Date(2019-1900, 1, 1), "texto", 0); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - instance.agregarComentarioAVideo(idVideo, DtComentario, Usu); - int idCom = instance.listarComentariosDeVideo(idVideo).get(0).getId(); - try { - instance.agregarComentarioAVideo(idVideo, idCom, DtComentario, Usu); - assertNull(null); - } catch (Exception e) { - assertNull(instance); // por poner algo que no sea null... - } - } - @Test - public void testAgregarComentarioAVideo_4args_2() { - System.out.println("testAgregarComentarioAVideo_4args_2"); - Usuario Usu = instance; - DtComentario DtComentario = new DtComentario(0, "nick", new Date(2019-1900, 1, 1), "texto", 0); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - instance.agregarComentarioAVideo(idVideo, DtComentario, Usu); - int idCom = instance.listarComentariosDeVideo(idVideo).get(0).getId(); - try { - instance.agregarComentarioAVideo(idVideo, idCom, DtComentario, null); - assertNull(instance); // por poner algo que no sea null... - } catch (Exception e) { - assertNull(null); - } - } - @Test - public void testAgregarComentarioAVideo_4args_3() { - System.out.println("testAgregarComentarioAVideo_4args_3"); - Usuario Usu = instance; - DtComentario DtComentario = new DtComentario(0, "nick", new Date(2019-1900, 1, 1), "texto", 0); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - instance.agregarComentarioAVideo(idVideo, DtComentario, Usu); - int idCom = instance.listarComentariosDeVideo(idVideo).get(0).getId(); - try { - instance.agregarComentarioAVideo(idVideo, idCom, null, Usu); - assertNull(instance); // por poner algo que no sea null... - } catch (Exception e) { - assertNull(null); - } - } - - /** - * Test of agregarListaParticular method, of class Usuario. - */ - @Test - public void testAgregarListaParticular_1() { - System.out.println("testAgregarListaParticular_1"); - DtListaDeReproduccion dt = ldr.getDt(); - //System.out.println(ldr.toString()); - //System.out.println(dt.toString()); - try { - instance.agregarListaParticular(dt); - assertNull(null); - } catch (Exception e) { - assertNull(dt); - } - } - @Test - public void testAgregarListaParticular_2() { - System.out.println("agregarListaParticular_2"); - DtListaDeReproduccion dt = null; - try { - instance.agregarListaParticular(dt); - assertNull(dt); - } catch (Exception e) { - assertNull(null); - } - } - - /** - * Test of agregarModificarValoracionDeVideo method, of class Usuario. - */ - @Test - public void testAgregarModificarValoracionDeVideo_1() { - System.out.println("testAgregarModificarValoracionDeVideo_1"); - DtValoracion DtValoracion = new DtValoracion(TipoValoracion.LIKE, "instance"); - Usuario Usu = instance; - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - - try { - instance.agregarModificarValoracionDeVideo(idVideo, DtValoracion, Usu); - assertNull(null); - } catch (Exception e) { - assertNotNull(null); - } - } - @Test - public void testAgregarModificarValoracionDeVideo_2() { - System.out.println("testAgregarModificarValoracionDeVideo_2"); - DtValoracion DtValoracion = new DtValoracion(TipoValoracion.LIKE, "instance"); - Usuario Usu = null; - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - - try { - instance.agregarModificarValoracionDeVideo(idVideo, DtValoracion, Usu); - assertNotNull(null); - } catch (Exception e) { - assertNull(null); - } - } - @Test - public void testAgregarModificarValoracionDeVideo_3() { - System.out.println("testAgregarModificarValoracionDeVideo_3"); - DtValoracion DtValoracion = null; - Usuario Usu = instance; - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - - try { - instance.agregarModificarValoracionDeVideo(idVideo, DtValoracion, Usu); - assertNotNull(null); - } catch (Exception e) { - assertNull(null); - } - } - - /** - * Test of agregarOQuitarSeguido method, of class Usuario. - */ - @Test - public void testAgregarOQuitarSeguido_1() { - System.out.println("testAgregarOQuitarSeguido_1"); - Usuario Usu = new Usuario("nickname", "correo", new Date(2019 - 1900, 1, 1), - "imagen", "contrasenia", "nombre", "apellido", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - int antes = Usu.getSeguidores() +1; - instance.agregarOQuitarSeguido(Usu); - int despues = Usu.getSeguidores(); - - boolean parte1 = antes == despues; - - antes = Usu.getSeguidores() -1; - instance.agregarOQuitarSeguido(Usu); - despues = Usu.getSeguidores(); - - boolean parte2 = antes == despues; - - if (parte1 && parte2){ - assertNull(null); - }else{ - assertNotNull(null); - } - } - @Test - public void testAgregarOQuitarSeguido_2() { - System.out.println("testAgregarOQuitarSeguido_2"); - Usuario Usu = new Usuario("nickname", "correo", new Date(2019 - 1900, 1, 1), - "imagen", "contrasenia", "nombre", "apellido", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - - int antes = Usu.getSeguidores(); - try { - instance.agregarOQuitarSeguido(null); - } catch (Exception e) { - int despues = Usu.getSeguidores(); - assertEquals(antes, despues); - } - } - @Test - public void testAgregarOQuitarSeguido_3() { - System.out.println("testAgregarOQuitarSeguido_3"); - Usuario Usu = new Usuario("nickname", "correo", new Date(2019 - 1900, 1, 1), - "imagen", "contrasenia", "nombre", "apellido", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - - int antes = Usu.getSeguidores(); - try { - instance.agregarOQuitarSeguido(instance); - } catch (Exception e) { - int despues = Usu.getSeguidores(); - assertEquals(antes, despues); - } - } - - /** - * Test of agregarVideoACanal method, of class Usuario. - */ - @Test - public void testAgregarVideoACanal_1() { - System.out.println("agregarVideoACanal_1"); - int antes, despues; - antes = instance.listarVideosDeCanal().size(); - Video v2 = new Video(0, "nombre de otro video", "descripcion", new Time(1, 2, 3), new Date(2019 - 1900, 1, 2), "urlVideo", "UNDEFINED"); - - try { - instance.agregarVideoACanal(v2.getDt()); - despues = instance.listarVideosDeCanal().size(); - assertNotEquals(despues, antes); - } catch (Exception e) { - despues = instance.listarVideosDeCanal().size(); - assertNotEquals(despues, antes); - } - } - @Test - public void testAgregarVideoACanal_2() { - System.out.println("agregarVideoACanal_2"); - int antes, despues; - antes = instance.listarVideosDeCanal().size(); - try { - instance.agregarVideoACanal(null); - } catch (Exception e) { - despues = instance.listarVideosDeCanal().size(); - assertEquals(despues, antes); - } - } - - /** - * Test of agregarVideoALista method, of class Usuario. - */ - @Test - public void testAgregarVideoALista_1() { - System.out.println("agregarVideoALista_1"); - int idLista = instance.listarListasDeReproduccionDeCanal(false).get(0).getId(); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - Usuario Usu = instance; - int antes, despues; - antes = instance.listarVideosDeListaDeReproduccion(idLista).size(); - instance.agregarVideoALista(idLista, idVideo, Usu); - despues = instance.listarVideosDeListaDeReproduccion(idLista).size(); - assertNotEquals(despues, antes); - } - @Test - public void testAgregarVideoALista_2() { - System.out.println("agregarVideoALista_2"); - int idLista = instance.listarListasDeReproduccionDeCanal(false).get(0).getId(); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - Usuario Usu = instance; - int antes, despues; - antes = instance.listarVideosDeListaDeReproduccion(idLista).size(); - - try { - instance.agregarVideoALista(idLista, -5, Usu); - } catch (Exception e) { - despues = instance.listarVideosDeListaDeReproduccion(idLista).size(); - assertEquals(despues, antes); - } - } - @Test - public void testAgregarVideoALista_3() { - System.out.println("agregarVideoALista_3"); - int idLista = instance.listarListasDeReproduccionDeCanal(false).get(0).getId(); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - Usuario Usu = instance; - int antes, despues; - antes = instance.listarVideosDeListaDeReproduccion(idLista).size(); - - try { - instance.agregarVideoALista(idLista, idVideo, null); - } catch (Exception e) { - despues = instance.listarVideosDeListaDeReproduccion(idLista).size(); - assertEquals(despues, antes); - } - } - - /** - * Test of listarUsuariosSeguidos method, of class Usuario. - */ - @Test - public void testListarUsuariosSeguidos() { - System.out.println("listarUsuariosSeguidos"); - Usuario Usu = new Usuario("nickname", "correo", new Date(2019 - 1900, 1, 1), - "imagen", "contrasenia", "nombre", "apellido", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - instance.agregarOQuitarSeguido(Usu); - - ArrayList<DtUsuario> expResult = new ArrayList(); - - ArrayList<DtUsuario> result = instance.listarUsuariosSeguidos(); - instance.agregarOQuitarSeguido(Usu); - assertNotEquals(expResult.size(), result.size()); - } - - /** - * Test of listarUsuariosSeguidores method, of class Usuario. - */ - @Test - public void testListarUsuariosSeguidores() { - System.out.println("listarUsuariosSeguidores"); - Usuario Usu = new Usuario("nickname", "correo", new Date(2019 - 1900, 1, 1), - "imagen", "contrasenia", "nombre", "apellido", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - instance.agregarOQuitarSeguido(Usu); - - ArrayList<DtUsuario> expResult = new ArrayList(); - - ArrayList<DtUsuario> result = Usu.listarUsuariosSeguidores(); - instance.agregarOQuitarSeguido(Usu); - assertNotEquals(expResult.size(), result.size()); - } - - /** - * Test of listarValoracionesDeVideo method, of class Usuario. - */ - @Test - public void testListarValoracionesDeVideo() { - System.out.println("listarValoracionesDeVideo"); - int id = instance.listarVideosDeCanal().get(0).getId(); - ArrayList<DtValoracion> expResult = new ArrayList(); - ArrayList<DtValoracion> result = null; - try { - result = instance.listarValoracionesDeVideo(id); - assertNull(null); - } catch (Exception e) { - assertNotNull(null); - } - } - - /** - * Test of listarVideosDeCanal method, of class Usuario. - */ - @Test - public void testListarVideosDeCanal() { - System.out.println("listarVideosDeCanal"); - int id = instance.listarVideosDeCanal().get(0).getId(); - ArrayList<DtVideo> expResult = new ArrayList(); - ArrayList<DtVideo> result = null; - try { - result = instance.listarVideosDeCanal(); - assertNull(null); - } catch (Exception e) { - assertNotNull(null); - } - } - - /** - * Test of listarVideosDeListaDeReproduccion method, of class Usuario. - */ - @Test - public void testListarVideosDeListaDeReproduccion() { - System.out.println("listarVideosDeListaDeReproduccion"); - int id = instance.listarListasDeReproduccionDeCanal(false).get(0).getId(); - ArrayList<DtVideo> expResult = new ArrayList(); - ArrayList<DtVideo> result = null; - try { - result = instance.listarVideosDeListaDeReproduccion(id); - assertNull(null); - } catch (Exception e) { - assertNotNull(null); - } - } - - /** - * Test of modificar method, of class Usuario. - */ - @Test - public void testModificar() { - System.out.println("modificar"); - Usuario Usu = new Usuario("nickname", "correo", new Date(2000 - 1900, 1, 1), - "img", "contra", "nom", "ape", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - DtUsuario DtUsu = Usu.getDT(); - DtCanal dtc = instance.obtenerCanal(); - instance.modificar(DtUsu, dtc); - assertEquals(DtUsu.toString(), instance.getDT().toString()); - } - @Test - public void testModificar_1() { - System.out.println("testModificar_1"); - Usuario Usu = new Usuario("nickn", "cor", new Date(2000 - 1900, 1, 1), - "img", "contra", "nom", "ape", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - DtUsuario DtUsu = Usu.getDT(); - DtCanal dtc = instance.obtenerCanal(); - - String antes = instance.getDT().toString(); - try { - instance.modificar(null, dtc); - } catch (Exception e) { - String despues = instance.getDT().toString(); - assertEquals(antes, despues); - } - } - @Test - public void testModificar_2() { - System.out.println("testModificar_2"); - Usuario Usu = new Usuario("nickn", "cor", new Date(2000 - 1900, 1, 1), - "img", "contra", "nom", "ape", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - DtUsuario DtUsu = Usu.getDT(); - DtCanal dtc = instance.obtenerCanal(); - - String antes = instance.getDT().toString(); - try { - instance.modificar(DtUsu, null); - } catch (Exception e) { - String despues = instance.getDT().toString(); - assertEquals(antes, despues); - } - } - @Test - public void testModificar_3() { - System.out.println("testModificar_3"); - Usuario Usu = new Usuario("nickn", "cor", new Date(2000 - 1900, 1, 1), - "img", "contra", "nom", "ape", - new DtCanal(0, "canal", "descripcion", Privacidad.PUBLICO)); - - DtUsuario DtUsu = new DtUsuario("nickname", "contrasenia", "nombre", "apellido", "correo", null, "imagen", 0); - DtCanal dtc = instance.obtenerCanal(); - - String antes = instance.getDT().toString(); - try { - instance.modificar(DtUsu, dtc); - } catch (Exception e) { - String despues = instance.getDT().toString(); - assertEquals(antes, despues); - } - } - - /** - * Test of modificarListaDeReproduccionDeCanal method, of class Usuario. - */ - @Test - public void testModificarListaDeReproduccionDeCanal_1() { - System.out.println("testModificarListaDeReproduccionDeCanal_1"); - DtListaDeReproduccion DtListaDeReproduccion = ldr.getDt(); - int id = ListaDeReproduccion.getNuevoId() +1; - instance.agregarListaParticular(ldr.getDt()); - DtListaDeReproduccion dt = new DtListaDeReproduccion(id, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "MUSICA"); - try { - instance.modificarListaDeReproduccionDeCanal(dt); - assertNull(null); - } catch (Exception e) { - assertNotNull(null); - } - } - @Test - public void testModificarListaDeReproduccionDeCanal_2() { - System.out.println("testModificarListaDeReproduccionDeCanal_2"); - DtListaDeReproduccion DtListaDeReproduccion = null; - - try { - instance.modificarListaDeReproduccionDeCanal(DtListaDeReproduccion); - assertNotNull(null); - } catch (Exception e) { - assertNull(null); - } - } - - /** - * Test of modificarVideoDeCanal method, of class Usuario. - */ - @Test - public void testModificarVideoDeCanal_1() { - System.out.println("testModificarVideoDeCanal_1"); - - int id = Video.getNuevoId() + 1; - DtVideo dt1 = new DtVideo(id, "videito", "descripcioncita", new Time(1, 2, 3), new Date(2010-1900, 5, 25), "urlcita", Privacidad.PRIVADO, "MUSICA", 0, 0); - instance.agregarVideoACanal(dt1); - DtVideo dt2 = new DtVideo(id, "vid", "desc", new Time(1, 2, 3), new Date(2010-1900, 5, 25), "url_vid", Privacidad.PRIVADO, "MUSICA", 0, 0); - - try { - instance.modificarVideoDeCanal(dt2); - assertNull(null); - } catch (Exception e) { - assertNotNull(null); - } - } - @Test - public void testModificarVideoDeCanal_2() { - System.out.println("testModificarVideoDeCanal_2"); - - try { - instance.modificarVideoDeCanal(null); - assertNotNull(null); - } catch (Exception e) { - assertNull(null); - } - } - - /** - * Test of obtenerCanal method, of class Usuario. - */ - @Test - public void testObtenerCanal() { - System.out.println("obtenerCanal"); - DtCanal result = instance.obtenerCanal(); - assertNotNull(result); - } - - /** - * Test of obtenerListaDeReproduccion method, of class Usuario. - */ - @Test - public void testObtenerListaDeReproduccion_1() { - System.out.println("obtenerListaDeReproduccion_1"); - int id = instance.listarListasDeReproduccionDeCanal(false).get(0).getId(); - DtListaDeReproduccion result = null; - try { - result = instance.obtenerListaDeReproduccion(id); - assertNotNull(result); - } catch (Exception e) { - assertNull(result); - } - } - @Test - public void testObtenerListaDeReproduccion_2() { - System.out.println("obtenerListaDeReproduccion_2"); - int id = 5000; - DtListaDeReproduccion result = null; - try { - result = instance.obtenerListaDeReproduccion(id); - assertNotNull(result); - } catch (Exception e) { - assertNull(result); - } - } - - /** - * Test of obtenerListasEnCategoria method, of class Usuario. - */ - @Test - public void testObtenerListasEnCategoria_1() { - System.out.println("obtenerListasEnCategoria_1"); - String cat = "DEPORTE"; - DtListaDeReproduccion dt = new DtListaDeReproduccion(0, "prueba", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "DEPORTE"); - instance.agregarListaParticular(dt); - - ArrayList<DtListaDeReproduccion> expResult = new ArrayList(); - ArrayList<DtListaDeReproduccion> result = new ArrayList(); - - try { - result = instance.obtenerListasEnCategoria(cat); - assertNotEquals(expResult.size(), result.size()); - } catch (Exception e) { - assertEquals(expResult.size(), result.size()); - } - } - @Test - public void testObtenerListasEnCategoria_2() { - System.out.println("testObtenerListasEnCategoria_2"); - String cat = ""; - - try { - ArrayList<DtListaDeReproduccion> result = instance.obtenerListasEnCategoria(cat); - assertNotNull(null); - } catch (Exception e) { - assertNull(null); - } - } - - /** - * Test of obtenerValoracion method, of class Usuario. - */ - @Test - public void testObtenerValoracion_1() { - System.out.println("obtenerValoracion_1"); - int id = instance.listarVideosDeCanal().get(0).getId(); - String nickname = instance.getNickname(); - instance.agregarModificarValoracionDeVideo(id, new DtValoracion(TipoValoracion.LIKE, instance.getNickname()), instance); - DtValoracion result = null; - try { - result = instance.obtenerValoracion(id, nickname); - assertNotNull(result); - } catch (Exception e) { - assertNotNull(result); - } - } - @Test - public void testObtenerValoracion_2() { - System.out.println("testObtenerValoracion_2"); - String nickname = ""; - DtValoracion result = null; - try { - result = instance.obtenerValoracion(0, nickname); - assertNull(result); - } catch (Exception e) { - assertNull(result); - } - } - - /** - * Test of obtenerVideo method, of class Usuario. - */ - @Test - public void testObtenerVideo_1() { - System.out.println("testObtenerVideo_1"); - int id = instance.listarVideosDeCanal().get(0).getId(); - Video result = null; - try { - result = instance.obtenerVideo(id); - assertNotNull(result); - } catch (Exception e) { - assertNotNull(result); - } - } - @Test - public void testObtenerVideo_2() { - System.out.println("testObtenerVideo_2"); - int id = 548; - Video result = null; - try { - result = instance.obtenerVideo(id); - assertNull(result); - } catch (Exception e) { - assertNull(result); - } - } - - /** - * Test of obtenerVideoDeCanal method, of class Usuario. - */ - @Test - public void testObtenerVideoDeCanal_1() { - System.out.println("testObtenerVideoDeCanal_1"); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - String expResult = instance.listarVideosDeCanal().get(0).getNombre(); - String result = ""; - try { - result = instance.obtenerVideoDeCanal(idVideo).getNombre(); - assertEquals(expResult, result); - } catch (Exception e) { - assertNotEquals(expResult, result); - } - } - @Test - public void testObtenerVideoDeCanal_2() { - System.out.println("testObtenerVideoDeCanal_2"); - int idVideo = 65487; - String expResult = ""; - String result = ""; - try { - result = instance.obtenerVideoDeCanal(idVideo).getNombre(); - assertEquals(expResult, result); - } catch (Exception e) { - assertEquals(expResult, result); - } - } - - /** - * Test of obtenerVideosEnCategoria method, of class Usuario. - */ - @Test - public void testObtenerVideosEnCategoria_1() { - System.out.println("testObtenerVideosEnCategoria_1"); - String cat = v.getCategoria(); - ArrayList<DtVideo> expResult = new ArrayList(); - ArrayList<DtVideo> result = null; - try { - result = instance.obtenerVideosEnCategoria(cat); - assertNotEquals(expResult.size(), result.size()); - } catch (Exception e) { - assertNotNull(null); - } - } - @Test - public void testObtenerVideosEnCategoria_2() { - System.out.println("testObtenerVideosEnCategoria_2"); - String cat = "CATEGORIA INEXISTENTE"; - ArrayList<DtVideo> expResult = new ArrayList(); - ArrayList<DtVideo> result = null; - try { - result = instance.obtenerVideosEnCategoria(cat); - assertEquals(expResult.size(), result.size()); - } catch (Exception e) { - assertNotNull(null); - } - } - @Test - public void testObtenerVideosEnCategoria_3() { - System.out.println("testObtenerVideosEnCategoria_3"); - String cat = ""; - ArrayList<DtVideo> expResult = new ArrayList(); - ArrayList<DtVideo> result = null; - try { - result = instance.obtenerVideosEnCategoria(cat); - assertNotNull(null); - } catch (Exception e) { - assertNull(null); - } - } - - /** - * Test of quitarValoracion method, of class Usuario. - */ - @Test - public void testQuitarValoracion_1() { - System.out.println("testQuitarValoracion_1"); - DtValoracion DtValoracion = new DtValoracion(TipoValoracion.LIKE, "instance"); - Usuario Usu = instance; - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - instance.agregarModificarValoracionDeVideo(idVideo, DtValoracion, Usu); - String nickname = Usu.getNickname(); - - int antes, despues; - antes = instance.listarValoracionesDeVideo(idVideo).size(); - - try { - instance.quitarValoracion(idVideo, nickname); - despues = instance.listarValoracionesDeVideo(idVideo).size(); - assertNotEquals(antes, despues); - } catch (Exception e) { - assertNotNull(null); - } - } - @Test - public void testQuitarValoracion_2() { - System.out.println("testQuitarValoracion_2"); - DtValoracion DtValoracion = new DtValoracion(TipoValoracion.LIKE, "instance"); - Usuario Usu = instance; - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - instance.agregarModificarValoracionDeVideo(idVideo, DtValoracion, Usu); - String nickname = ""; - - int antes, despues; - antes = instance.listarValoracionesDeVideo(idVideo).size(); - - try { - instance.quitarValoracion(idVideo, nickname); - despues = instance.listarValoracionesDeVideo(idVideo).size(); - assertNotNull(null); - } catch (Exception e) { - assertNull(null); - } - } - - /** - * Test of quitarVideoDeListaDeReproduccion method, of class Usuario. - */ - @Test - public void testQuitarVideoDeListaDeReproduccion_1() { - System.out.println("testQuitarVideoDeListaDeReproduccion_1"); - int idLista = instance.listarListasDeReproduccionDeCanal(false).get(0).getId(); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - Usuario Usu = instance; - Usu.agregarVideoALista(idLista, idVideo, instance); - int antes, despues; - antes = instance.listarVideosDeListaDeReproduccion(idLista).size(); - instance.quitarVideoDeListaDeReproduccion(idLista, idVideo); - despues = instance.listarVideosDeListaDeReproduccion(idLista).size(); - assertNotEquals(despues, antes); - } - @Test - public void testQuitarVideoDeListaDeReproduccion_2() { - System.out.println("testQuitarVideoDeListaDeReproduccion_2"); - int idLista = instance.listarListasDeReproduccionDeCanal(false).get(0).getId(); - int idVideo = instance.listarVideosDeCanal().get(0).getId(); - Usuario Usu = instance; - Usu.agregarVideoALista(idLista, idVideo, instance); - idVideo = 548876; - int antes, despues; - antes = instance.listarVideosDeListaDeReproduccion(idLista).size(); - instance.quitarVideoDeListaDeReproduccion(idLista, idVideo); - despues = instance.listarVideosDeListaDeReproduccion(idLista).size(); - assertEquals(despues, antes); - } - - /** - * Test of validarListaParticular method, of class Usuario. - */ - @Test - public void testValidarListaParticular_1() { - System.out.println("testValidarListaParticular_1"); - - DtListaDeReproduccion dt = new DtListaDeReproduccion(0, "nombre particular 1", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "MUSICA"); - instance.agregarListaParticular(dt); - String nombre = "nombre particular 1"; - boolean expResult = false; - boolean result = false; - try { - result = instance.validarListaParticular(nombre); - assertEquals(expResult, result); - } catch (Exception e) { - assertEquals(expResult, result); - } - } - @Test - public void testValidarListaParticular_2() { - System.out.println("testValidarListaParticular_2"); - - DtListaDeReproduccion dt = new DtListaDeReproduccion(0, "nombre particular 2", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "MUSICA"); - - String nombre = "lista inexistente"; - boolean expResult = true; - boolean result = true; - try { - result = instance.validarListaParticular(nombre); - assertEquals(expResult, result); - } catch (Exception e) { - assertEquals(expResult, result); - } - } - @Test - public void testValidarListaParticular_3() { - System.out.println("testValidarListaParticular_3"); - - String nombre = ""; - boolean expResult = false; - boolean result = true; - try { - result = instance.validarListaParticular(nombre); - assertNotNull(null); - } catch (Exception e) { - assertNull(null); - } - } - -} diff --git a/UyTube_aplicacion/test/Logica/Clases/ValoracionTest.java b/UyTube_aplicacion/test/Logica/Clases/ValoracionTest.java deleted file mode 100644 index 4081c75bf81db76cafe251782eddf27cd92b5805..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Clases/ValoracionTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Clases; - -import Logica.DataType.DtValoracion; -import Logica.Enumerados.TipoValoracion; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -import Logica.Clases.Usuario; -import Logica.DataType.DtCanal; -import Logica.Enumerados.Privacidad; -import java.sql.Date; - -/** - * - * @author Carlos BM - */ -public class ValoracionTest { - - Usuario user; - Valoracion valo; - - public ValoracionTest() { - user = new Usuario("MCbolso", "mcbolso@gmail.com", new Date(190,7,4), "imagen.jpg", "dsfsdf", "mariano", "Castro", new DtCanal(0, "mi_canal", "un_canal_mas", Privacidad.PRIVADO)); - valo = new Valoracion(TipoValoracion.LIKE, user); - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getVal method, of class Valoracion. - */ - @Test - public void testValoracion() { - System.out.println("getVal"); - Valoracion instance; - try{ - instance = new Valoracion(TipoValoracion.LIKE, null); - }catch(Exception e){ - assertEquals(true, true); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - @Test - public void testGetVal() { - System.out.println("getVal"); - Valoracion instance = valo; - TipoValoracion expResult = TipoValoracion.LIKE; - TipoValoracion result = instance.getVal(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of setVal method, of class Valoracion. - */ - @Test - public void testSetVal() { - System.out.println("setVal"); - TipoValoracion val = null; - Valoracion instance = valo; - instance.setVal(val); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getNicknameDeUsuario method, of class Valoracion. - */ - @Test - public void testGetNicknameDeUsuario() { - System.out.println("getNicknameDeUsuario"); - Valoracion instance = valo; - String expResult = "MCbolso"; - String result = instance.getNicknameDeUsuario(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getDT method, of class Valoracion. - */ - @Test - public void testGetDT_0args() { - System.out.println("getDT"); - Valoracion instance = valo; - DtValoracion expResult = new DtValoracion(TipoValoracion.LIKE, "MCbolso"); - DtValoracion result = instance.getDT(); - assertEquals(expResult.toString(), result.toString()); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getDT method, of class Valoracion. - */ - @Test - public void testGetDT_String() { - - System.out.println("getDT"); - String nickname = "MCbolso"; - Valoracion instance = valo; - DtValoracion expResult = new DtValoracion(TipoValoracion.LIKE, "MCbolso"); - DtValoracion result = instance.getDT(nickname); - assertEquals(expResult.toString(), result.toString()); - } - - @Test - public void testGetDT_String_mal() { - - System.out.println("getDT"); - Valoracion instance = valo; - //DtValoracion result = instance.getDT("Lucas"); - assertNull(instance.getDT("Lucas")); - } - - @Test - public void testGetDT_String_null_basura() { - System.out.println("getDT"); - String nickname = null; - Valoracion instance = valo; - try { - instance.getDT(nickname); - } catch (Exception e) { - assertEquals(true, true); - } - - } - - /** - * Test of modificar method, of class Valoracion. - */ - @Test - public void testModificar() { - System.out.println("modificar"); - DtValoracion dtV = new DtValoracion(TipoValoracion.DISLIKE, "MCbolso"); - String nickname = "MCbolso"; - Valoracion instance = valo; - boolean expResult = true; - boolean result = instance.modificar(dtV, nickname); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - @Test - public void testModificar_false() { - System.out.println("modificar"); - DtValoracion dtV = new DtValoracion(TipoValoracion.DISLIKE, "MCbolso"); - String nickname = "Lucas"; - Valoracion instance = valo; - boolean expResult = false; - boolean result = instance.modificar(dtV, nickname); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - @Test - public void testModificar_null_1() { - System.out.println("modificar"); - DtValoracion dtV = new DtValoracion(TipoValoracion.DISLIKE, "MCbolso"); - String nickname = null; - Valoracion instance = valo; - boolean expResult = false; - boolean result = false; - - try{ - result = instance.modificar(dtV, nickname); - }catch(Exception e){ - assertEquals(expResult, result); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - @Test - public void testModificar_null_2() { - System.out.println("modificar"); - DtValoracion dtV = null; - String nickname = "MCbolso"; - Valoracion instance = valo; - boolean expResult = false; - boolean result = false; - - try{ - result = instance.modificar(dtV, nickname); - }catch(Exception e){ - assertEquals(expResult, result); - } - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/Clases/VideoTest.java b/UyTube_aplicacion/test/Logica/Clases/VideoTest.java deleted file mode 100644 index e6a474fbb3ce795501d58ebc31a19db6802d2206..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Clases/VideoTest.java +++ /dev/null @@ -1,817 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Clases; - -import Logica.DataType.DtCanal; -import Logica.DataType.DtComentario; -import Logica.DataType.DtValoracion; -import Logica.DataType.DtVideo; -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoValoracion; -import java.sql.Date; -import java.sql.Time; -import java.util.ArrayList; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -/** - * - * @author administrador - */ -public class VideoTest { - Usuario usrActual; - Usuario usrSeleccionado; - Usuario usrSeleccionado2; - Video videoPrueba; - Categoria miCategoria = new Categoria("Prueba"); - - public VideoTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(0, 2, 40); - videoPrueba = new Video(1, "MiVideo", "Video para comentar",duracion1, fecha1,"url","categoria"); - DtCanal canalusractual = new DtCanal(Canal.getNuevoId(), "usractual", "Canal de usuario actual", Privacidad.PUBLICO); - usrActual = new Usuario("usrActual", "usractual@gmail.com", fecha1, "url:imagen", "password", "usractual", "actual", canalusractual ); - DtVideo dtVideoTest = new DtVideo(Video.getNuevoId(), "videoTest", "video de pruebas", duracion1, fecha1, "http://video.com", Privacidad.PRIVADO, miCategoria.getNombre(), 0, 0); - usrActual.agregarVideoACanal(dtVideoTest); - Date fecha2 = new Date(1998,5,12); - DtCanal canalusrseleccionado = new DtCanal(Canal.getNuevoId(), "usrseleccionado", "Canal de usuario seleccionado", Privacidad.PUBLICO); - usrSeleccionado = new Usuario("usrseleccionado", "usrseleccionado@gmail.com", fecha2, "url:imagen","password","usrseleccionado","seleccionado",canalusrseleccionado); - DtCanal canalusrseleccionado2 = new DtCanal(Canal.getNuevoId(), "usrseleccionado2", "Canal de usuario seleccionado2", Privacidad.PUBLICO); - usrSeleccionado2 = new Usuario("usrseleccionado2", "usrseleccionado2@gmail.com", fecha2, "url:imagen","password","usrseleccionado2","seleccionado2",canalusrseleccionado2); - } - - @After - public void tearDown() { - } - - /** - * Test constructor id negativo - */ - @Test(expected = RuntimeException.class) - public void testCostructorVideo(){ - System.out.println("testCostructorVideo"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(0, 2, 40); - Video video = new Video(-1, "MiVideo", "Video para comentar",duracion1, fecha1,"url","categoria"); - } - - /** - * Test constructor nombre vacio - */ - @Test(expected = RuntimeException.class) - public void testCostructorVideo2(){ - System.out.println("testCostructorVideo2"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(0, 2, 40); - Video video = new Video(3, "", "Video para comentar",duracion1, fecha1,"url","categoria"); - } - - /** - * Test constructor con descripcion vacia - */ - @Test - public void testCostructorVideo3(){ - System.out.println("testCostructorVideo3"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(0, 2, 40); - Video video = new Video(3, "MiVideo", "",duracion1, fecha1,"url","categoria"); - } - - /** - * Test constructor con duracion null - */ - @Test(expected = RuntimeException.class) - public void testCostructorVideo4(){ - System.out.println("testCostructorVideo4"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = null; - Video video = new Video(3, "MiVideo", "Video para comentar",duracion1, fecha1,"url","categoria"); - } - - /** - * Test constructor con fecha null - */ - @Test(expected = RuntimeException.class) - public void testCostructorVideo5(){ - System.out.println("testCostructorVideo5"); - Date fecha1 = null; - Time duracion1 = new Time(0, 2, 40); - Video video = new Video(3, "MiVideo", "Video para comentar",duracion1, fecha1,"url","categoria"); - } - - /** - * Test constructor con url vacia - */ - @Test(expected = RuntimeException.class) - public void testCostructorVideo6(){ - System.out.println("testCostructorVideo6"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(0, 2, 40); - Video video = new Video(3, "MiVideo", "Video para comentar",duracion1, fecha1,"","categoria"); - } - - /** - * Test constructor con categoria vacia - */ - @Test(expected = RuntimeException.class) - public void testCostructorVideo7(){ - System.out.println("testCostructorVideo7"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(0, 2, 40); - Video video = new Video(3, "MiVideo", "Video para comentar",duracion1, fecha1,"url",""); - } - - /** - * Test ok - */ - @Test - public void testAgregarComentario_DtComentario_Usuario() { - System.out.println("agregarComentario"); - Date fecha = new Date(2019, 8, 25); - DtComentario dtComentario = new DtComentario(2, "usrseleccionado", fecha, "comentario de prueba", 0); - videoPrueba.agregarComentario(dtComentario, usrSeleccionado); - ArrayList<DtComentario> listaComentarios = videoPrueba.listarComentarios(); - String esperado = dtComentario.toString(); - String resultado = new String(); - for (DtComentario item : listaComentarios) { //Obtengo el comentario recien ingresado, lo busca por texto - if(item.getTexto() == dtComentario.getTexto()){ - resultado = item.toString(); - } - } - assertEquals(esperado, resultado); - } - - /** - * Test OK - */ - @Test - public void testAgregarComentario_3args() { - System.out.println("agregarComentario"); - Date fecha = new Date(2019,07,10); - DtComentario dtComentario = new DtComentario(Comentario.getNuevoID(), "usrseleccionado", fecha, "texto1", 1); - DtComentario dtComentario2 = new DtComentario(Comentario.getNuevoID(), "usrseleccionado", fecha, "texto2", 2); - videoPrueba.agregarComentario(dtComentario, usrSeleccionado); - ArrayList<DtComentario> listaCom1 = videoPrueba.listarComentarios(); - int id = 0; - for (DtComentario item : listaCom1) {//Obtiene el id del comentario1 que se agrego (lo busca por el texto) - if(item.getTexto() == dtComentario.getTexto()){ - id = item.getId(); - } - } - videoPrueba.agregarComentario(id, dtComentario2, usrSeleccionado); - ArrayList<DtComentario> listaCom = videoPrueba.listarComentarios(); - String esperado = dtComentario2.getTexto(); - String resultado = new String(); - for (DtComentario item : listaCom) { - if(item.getTexto() == dtComentario2.getTexto()){ - resultado = item.getTexto(); - } - } - assertEquals(esperado, resultado); - } - - /** - * Test OK dtComentario null - */ - @Test(expected = RuntimeException.class) - public void testAgregarComentario_3args2() { - System.out.println("agregarComentario_3args2"); - Date fecha = new Date(2019,07,10); - DtComentario dtComentario = new DtComentario(Comentario.getNuevoID(), "usrseleccionado", fecha, "texto1", 1); - DtComentario dtComentario2 = null; - videoPrueba.agregarComentario(dtComentario, usrSeleccionado); - ArrayList<DtComentario> listaCom1 = videoPrueba.listarComentarios(); - int id = 0; - for (DtComentario item : listaCom1) {//Obtiene el id del comentario1 que se agrego (lo busca por el texto) - if(item.getTexto() == dtComentario.getTexto()){ - id = item.getId(); - } - } - videoPrueba.agregarComentario(id, dtComentario2, usrSeleccionado); - } - - /** - * Test OK dtComentario null - */ - @Test(expected = RuntimeException.class) - public void testAgregarComentario_3args4() { - System.out.println("agregarComentario_3args4"); - Date fecha = new Date(2019,07,10); - DtComentario dtComentario = new DtComentario(Comentario.getNuevoID(), "usrseleccionado", fecha, "texto1", 1); - DtComentario dtComentario2 = new DtComentario(Comentario.getNuevoID(), "usrseleccionado", fecha, "texto2", 2); - Usuario usuario = null; - videoPrueba.agregarComentario(dtComentario, usrSeleccionado); - ArrayList<DtComentario> listaCom1 = videoPrueba.listarComentarios(); - int id = 0; - for (DtComentario item : listaCom1) {//Obtiene el id del comentario1 que se agrego (lo busca por el texto) - if(item.getTexto() == dtComentario.getTexto()){ - id = item.getId(); - } - } - videoPrueba.agregarComentario(id, dtComentario2, usuario); - } - - /** - * Test OK - */ - @Test - public void testAgregarComentario_3args5() { - System.out.println("agregarComentario"); - Date fecha = new Date(2019,07,10); - DtComentario dtComentario = new DtComentario(Comentario.getNuevoID(), "usrseleccionado", fecha, "texto1", 1); - DtComentario dtComentario2 = new DtComentario(Comentario.getNuevoID(), "usrseleccionado", fecha, "texto2", 2); - videoPrueba.agregarComentario(dtComentario, usrSeleccionado); - - ArrayList<DtComentario> listaCom1 = videoPrueba.listarComentarios(); - videoPrueba.agregarComentario(5000, dtComentario2, usrSeleccionado); - ArrayList<DtComentario> listaCom2 = videoPrueba.listarComentarios(); - - assertEquals(listaCom1.size(), listaCom2.size()); - } - - /** - * Test OK dtComentario null - */ - @Test(expected = RuntimeException.class) - public void testAgregarComentario4() { - System.out.println("agregarComentario4"); - DtComentario dtComentario = null; - videoPrueba.agregarComentario(dtComentario, usrSeleccionado); - } - - /** - * Test OK usuario null - */ - @Test(expected = RuntimeException.class) - public void testAgregarComentario5() { - System.out.println("agregarComentario5"); - Date fecha = new Date(2019,07,10); - DtComentario dtComentario = new DtComentario(Comentario.getNuevoID(), "usrseleccionado", fecha, "un desastre el 1", 1); - Usuario usuario = null; - videoPrueba.agregarComentario(dtComentario, usuario); - } - - /** - * Test OK - */ - @Test - public void testAgregarModificarValoracion() { - System.out.println("agregarModificarValoracion"); - DtValoracion val1 = new DtValoracion(TipoValoracion.DISLIKE, "usrseleccionado"); - videoPrueba.agregarModificarValoracion(val1, usrSeleccionado); - TipoValoracion resultado = videoPrueba.obtenerValoracion("usrseleccionado").getVal(); - assertEquals(resultado, TipoValoracion.DISLIKE); - } - - /** - * Test OK DtValoracion = null - */ - @Test(expected = RuntimeException.class) - public void testAgregarModificarValoracion2() { - System.out.println("agregarModificarValoracion2"); - DtValoracion val1 = null; - videoPrueba.agregarModificarValoracion(val1, usrSeleccionado); - } - - /** - * Test OK Usuario = null - */ - @Test(expected = RuntimeException.class) - public void testAgregarModificarValoracion3() { - System.out.println("agregarModificarValoracion3"); - DtValoracion val1 = new DtValoracion(TipoValoracion.DISLIKE, "usrseleccionado"); - Usuario usuario = null; - videoPrueba.agregarModificarValoracion(val1, usuario); - } - - /** - * Test OK modificando la valoracion de dislike a like - */ - @Test - public void testAgregarModificarValoracion4() { - System.out.println("agregarModificarValoracion4"); - DtValoracion val1 = new DtValoracion(TipoValoracion.DISLIKE, "usrseleccionado"); - videoPrueba.agregarModificarValoracion(val1, usrSeleccionado);//Agrega una valoración - DtValoracion val2 = new DtValoracion(TipoValoracion.LIKE, "usrseleccionado"); - videoPrueba.agregarModificarValoracion(val2, usrSeleccionado);//modifica la valoración - TipoValoracion resultado = videoPrueba.obtenerValoracion("usrseleccionado").getVal(); - assertEquals(resultado, TipoValoracion.LIKE); - } - - /** - * Test OK modificando la valoracion de like a dislike - */ - @Test - public void testAgregarModificarValoracion5() { - System.out.println("agregarModificarValoracion5"); - DtValoracion val1 = new DtValoracion(TipoValoracion.LIKE, "usrseleccionado"); - videoPrueba.agregarModificarValoracion(val1, usrSeleccionado);//Agrega una valoración - DtValoracion val2 = new DtValoracion(TipoValoracion.DISLIKE, "usrseleccionado"); - videoPrueba.agregarModificarValoracion(val2, usrSeleccionado);//modifica la valoración - TipoValoracion resultado = videoPrueba.obtenerValoracion("usrseleccionado").getVal(); - assertEquals(resultado, TipoValoracion.DISLIKE); - } - - /** - * Test ok - */ - @Test - public void testGetDt() { - System.out.println("getDt"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(0, 2, 40); - DtVideo expResult = new DtVideo(1, "MiVideo", "Video para comentar",duracion1, fecha1,"url",Privacidad.PRIVADO,"categoria",0,0); - DtVideo result = videoPrueba.getDt(); - assertEquals(expResult.toString(), result.toString()); - } - - /** - * Test OK - */ - @Test - public void testListarComentarios() { - System.out.println("listarComentarios"); - Date fecha1 = new Date(1976,1,31); - DtComentario dtComentario = new DtComentario(3, "usrseleccionado", fecha1, "comentario del video", 0); - ArrayList<DtComentario> expResult = new ArrayList<>(); - expResult.add(dtComentario); - videoPrueba.agregarComentario(dtComentario, usrSeleccionado); - ArrayList<DtComentario> result = videoPrueba.listarComentarios(); - assertEquals(expResult.toString(), result.toString()); - } - - /** - * Test OK - */ - @Test - public void testListarValoraciones() { - System.out.println("listarValoraciones"); - DtValoracion dtValoracion1 = new DtValoracion(TipoValoracion.LIKE, "usrseleccionado"); - videoPrueba.agregarModificarValoracion(dtValoracion1, usrSeleccionado); - DtValoracion dtValoracion2 = new DtValoracion(TipoValoracion.LIKE, "usrseleccionado2"); - videoPrueba.agregarModificarValoracion(dtValoracion2, usrSeleccionado2); - ArrayList<DtValoracion> listaVal = new ArrayList<>(); - listaVal.add(dtValoracion1); - listaVal.add(dtValoracion2); - ArrayList<DtValoracion> result = videoPrueba.listarValoraciones(); - boolean esperado=true, resultado=false; - for (int i = 0; i < result.size(); i++) { - if(listaVal.get(i).getVal()==result.get(i).getVal()){ - resultado = true; - }else{ - resultado = false; - break; - } - } - assertEquals(esperado, resultado); - } - - /** - * Test OK - */ - @Test - public void testModificar() { - System.out.println("modificar"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(0, 2, 40); - DtVideo dtVideo = new DtVideo(1, "MiVideo", "Video modificado",duracion1, fecha1,"url",Privacidad.PRIVADO,"categoria",0,0); - videoPrueba.modificar(dtVideo); - Video video2 = new Video(1, "MiVideo", "Video modificado",duracion1, fecha1,"url","categoria"); - String esperado = video2.toString(); - String resultado = videoPrueba.toString(); - assertEquals(esperado, resultado); - } - - /** - * Test OK con dtVideo null - */ - @Test(expected = RuntimeException.class) - public void testModificar2() { - System.out.println("modificar2"); - DtVideo dtVideo = null; - videoPrueba.modificar(dtVideo); - } - - /** - * Test OK nombre vacio - */ - @Test(expected = RuntimeException.class) - public void testModificar3() { - System.out.println("modificar3"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(0, 2, 40); - DtVideo dtVideo = new DtVideo(1, "", "Video modificado",duracion1, fecha1,"url",Privacidad.PRIVADO,"categoria",0,0); - videoPrueba.modificar(dtVideo); - } - - /** - * Test OK duracion es null - */ - @Test(expected = RuntimeException.class) - public void testModificar4() { - System.out.println("modificar4"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = null; - DtVideo dtVideo = new DtVideo(1, "MiVideo", "Video modificado",duracion1, fecha1,"url",Privacidad.PRIVADO,"categoria",0,0); - videoPrueba.modificar(dtVideo); - } - - /** - * Test OK categoria es vacÃa - */ - @Test(expected = RuntimeException.class) - public void testModificar5() { - System.out.println("modificar5"); - Date fecha1 = new Date(1976,1,31); - Time duracion1 = new Time(00,29,00); - DtVideo dtVideo = new DtVideo(1, "MiVideo", "Video modificado",duracion1, fecha1,"url",Privacidad.PRIVADO,"",0,0); - videoPrueba.modificar(dtVideo); - } - - /** - * Test OK fecha null - */ - @Test(expected = RuntimeException.class) - public void testModificar6() { - System.out.println("modificar6"); - Date fecha1 = null; - Time duracion1 = new Time(00,29,00); - DtVideo dtVideo = new DtVideo(1, "MiVideo", "Video modificado",duracion1, fecha1,"url",Privacidad.PRIVADO,"categoria",0,0); - videoPrueba.modificar(dtVideo); - } - - /** - * Test of obtenerValoracion method, of class Video. - */ - @Test - public void testObtenerValoracion() { - System.out.println("obtenerValoracion"); - String nickname = "usrseleccionado"; - DtValoracion val = new DtValoracion(TipoValoracion.LIKE, nickname); - videoPrueba.agregarModificarValoracion(val, usrSeleccionado); - String expResult = val.toString(); - String result = videoPrueba.obtenerValoracion(nickname).toString(); - assertEquals(expResult, result); - } - - /** - * Test ok nickname vacio - */ - @Test(expected = RuntimeException.class) - public void testObtenerValoracion2() { - System.out.println("obtenerValoracion2"); - String nickname = "usrseleccionado"; - DtValoracion val = new DtValoracion(TipoValoracion.LIKE, nickname); - videoPrueba.agregarModificarValoracion(val, usrSeleccionado); - videoPrueba.obtenerValoracion(""); - } - - /** - * Test OK - */ - @Test - public void testQuitarValoracion() { - System.out.println("quitarValoracion"); - String nickname = "usrseleccionado"; - DtValoracion dtValoracion = new DtValoracion(TipoValoracion.LIKE, nickname); - videoPrueba.agregarModificarValoracion(dtValoracion, usrSeleccionado); - videoPrueba.quitarValoracion(nickname); - int esperado = 0, resultado = videoPrueba.listarValoraciones().size(); - assertEquals(esperado, resultado); - } - - /** - * Test OK - */ - @Test - public void testQuitarValoracion1() { - System.out.println("quitarValoracion"); - String nickname = "usrseleccionado"; - DtValoracion dtValoracion = new DtValoracion(TipoValoracion.DISLIKE, nickname); - videoPrueba.agregarModificarValoracion(dtValoracion, usrSeleccionado); - videoPrueba.quitarValoracion(nickname); - int esperado = 0, resultado = videoPrueba.listarValoraciones().size(); - assertEquals(esperado, resultado); - } - /** - * Test OK - */ - @Test - public void testQuitarValoracion2() { - System.out.println("quitarValoracion2"); - - Video video = new Video(50, "MiVideo", "Video para comentar", new Time(0, 1, 2), new Date(19, 5, 2), "url", "categoria"); - videoPrueba.quitarValoracion("nickname"); - int esperado = 0, resultado = videoPrueba.listarValoraciones().size(); - assertEquals(esperado, resultado); - } - - /** - * Test OK nickname vacio - */ - @Test(expected = RuntimeException.class) - public void testQuitarValoracion3() { - System.out.println("quitarValoracion3"); - DtValoracion dtValoracion = new DtValoracion(TipoValoracion.LIKE, "usrseleccionado"); - videoPrueba.agregarModificarValoracion(dtValoracion, usrSeleccionado); - videoPrueba.quitarValoracion(""); - } - - @Test - public void testQuitarValoracion4() { - System.out.println("quitarValoracion"); - String nickname = "mc_bolso"; - DtValoracion dtValoracion = new DtValoracion(TipoValoracion.DISLIKE, nickname); - videoPrueba.agregarModificarValoracion(dtValoracion, usrSeleccionado); - videoPrueba.quitarValoracion(nickname); - int esperado = 1, resultado = videoPrueba.listarValoraciones().size(); - assertEquals(esperado, resultado); - } - - /** - * Test of getNuevoId method, of class Video. - */ - @Test - public void testGetNuevoId() { - System.out.println("getNuevoId"); - int expResult = Video.getNuevoId(); - int result = Video.getNuevoId(); - assertEquals(expResult +1, result); - } - - /** - * Test OK - */ - @Test - public void testGetId() { - System.out.println("getId"); - int expResult = 1; - int result = videoPrueba.getId(); - assertEquals(expResult, result); - } - - /** - * Test OK - */ - @Test - public void testSetId() { - System.out.println("setId"); - int id = 100; - Video instance = new Video(); - instance.setId(id); - assertEquals(id, instance.getId()); - } - - /** - * Test OK - */ - @Test - public void testGetNombre() { - System.out.println("getNombre"); - String expResult = "MiVideo"; - String result = videoPrueba.getNombre(); - assertEquals(expResult, result); - } - - /** - * Test ok - */ - @Test - public void testSetNombre() { - System.out.println("setNombre"); - String nombre = "Nuevo nombre"; - videoPrueba.setNombre(nombre); - assertEquals(nombre, videoPrueba.getNombre()); - } - - /** - * Test OK - */ - @Test - public void testGetDescripcion() { - System.out.println("getDescripcion"); - String expResult = "Video para comentar"; - String result = videoPrueba.getDescripcion(); - assertEquals(expResult, result); - } - - /** - * Tes ok - */ - @Test - public void testSetDescripcion() { - System.out.println("setDescripcion"); - String descripcion = "Nueva Descripcion"; - videoPrueba.setDescripcion(descripcion); - assertEquals(descripcion, videoPrueba.getDescripcion()); - } - - /** - * Test ok - */ - @Test - public void testGetDuracion() { - System.out.println("getDuracion"); - Time expResult = new Time(0, 2, 40); - videoPrueba.setDuracion(expResult); - Time result = videoPrueba.getDuracion(); - assertEquals(expResult, result); - } - - /** - * Test ok - */ - @Test - public void testSetDuracion() { - System.out.println("setDuracion"); - Time expResult = new Time(0,4,30); - videoPrueba.setDuracion(expResult); - assertEquals(expResult, videoPrueba.getDuracion()); - } - - /** - * Test OK - */ - @Test - public void testGetFechaPublicacion() { - System.out.println("getFechaPublicacion"); - Video instance = new Video(); - Date expResult = new Date(1978,1,31); - videoPrueba.setFechaPublicacion(expResult); - Date result = videoPrueba.getFechaPublicacion(); - assertEquals(expResult, result); - } - - /** - * Test OK - */ - @Test - public void testSetFechaPublicacion() { - System.out.println("setFechaPublicacion"); - Date fechaPublicacion = new Date(1999,6,4); - videoPrueba.setFechaPublicacion(fechaPublicacion); - assertEquals(fechaPublicacion, videoPrueba.getFechaPublicacion()); - } - - /** - * Test OK - */ - @Test - public void testGetUrlVideoOriginal() { - System.out.println("getUrlVideoOriginal"); - String expResult = "url test"; - videoPrueba.setUrlVideoOriginal(expResult); - String result = videoPrueba.getUrlVideoOriginal(); - assertEquals(expResult, result); - } - - /** - * Test OK - */ - @Test - public void testSetUrlVideoOriginal() { - System.out.println("setUrlVideoOriginal"); - String urlVideoOriginal = "url test2"; - videoPrueba.setUrlVideoOriginal(urlVideoOriginal); - assertEquals(urlVideoOriginal, videoPrueba.getUrlVideoOriginal()); - } - - /** - * Test OK - */ - @Test - public void testGetPrivacidad() { - System.out.println("getPrivacidad"); - Privacidad expResult = Privacidad.PRIVADO; - videoPrueba.setPrivacidad(expResult); - Privacidad result = videoPrueba.getPrivacidad(); - assertEquals(expResult, result); - } - - /** - * Test OK - */ - @Test - public void testSetPrivacidad() { - System.out.println("setPrivacidad"); - Privacidad expPrivacidad; - if(videoPrueba.getPrivacidad() == Privacidad.PRIVADO){ - expPrivacidad = Privacidad.PUBLICO; - videoPrueba.setPrivacidad(expPrivacidad); - }else{ - expPrivacidad = Privacidad.PRIVADO; - videoPrueba.setPrivacidad(expPrivacidad); - } - assertEquals(expPrivacidad, videoPrueba.getPrivacidad()); - } - - /** - * Test OK - */ - @Test - public void testGetCategoria() { - System.out.println("getCategoria"); - String expResult = "categoria"; - String result = videoPrueba.getCategoria(); - assertEquals(expResult, result); - } - - /** - * Test OK - */ - @Test - public void testSetCategoria() { - System.out.println("setCategoria"); - String categoria = "Nueva Categoria"; - videoPrueba.setCategoria(categoria); - assertEquals(categoria, videoPrueba.getCategoria()); - } - - /** - * Test of getCantLikes method, of class Video. - */ - @Test - public void testGetCantLikes() { - System.out.println("getCantLikes"); - Video instance = new Video(); - int expResult = 0; - int result = instance.getCantLikes(); - assertEquals(expResult, result); - } - - /** - * Test of setCantLikes method, of class Video. - */ - @Test - public void testSetCantLikes() { - System.out.println("setCantLikes"); - int cantLikes = videoPrueba.getCantLikes(); - cantLikes++; - videoPrueba.setCantLikes(cantLikes); - assertEquals(cantLikes, videoPrueba.getCantLikes()); - } - - /** - * Test of getCantDisLikes method, of class Video. - */ - @Test - public void testGetCantDisLikes() { - System.out.println("getCantDisLikes"); - int expResult = 0; - - int result = videoPrueba.getCantDisLikes(); - assertEquals(expResult, result); - } - - /** - * Test OK - */ - @Test - public void testSetCantDisLikes() { - System.out.println("setCantDisLikes"); - int expResult = videoPrueba.getCantDisLikes(); - expResult++; - videoPrueba.setCantDisLikes(expResult); - assertEquals(expResult, videoPrueba.getCantDisLikes()); - } - - /** - * Test OK - */ - @Test - public void testToString() { - System.out.println("toString"); - String expResult = "Video{id=1, nombre=MiVideo, descripcion=Video para comentar, duracion=00:02:40, fechaPublicacion=3876-03-02, urlVideoOriginal=url, privacidad=PRIVADO, categoria=categoria, cantLikes=0, cantDisLikes=0}"; - String result = videoPrueba.toString(); - assertEquals(expResult, result); - } - - @RunWith(Parameterized.class) - public class VideoTestParemetrizado{ - - } - -} - - diff --git a/UyTube_aplicacion/test/Logica/Controladores/CAdminTest.java b/UyTube_aplicacion/test/Logica/Controladores/CAdminTest.java deleted file mode 100644 index c1e5f28650e817caa6013c543d92a3f47839abcb..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Controladores/CAdminTest.java +++ /dev/null @@ -1,1619 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Controladores; - -import Logica.Clases.ListaDeReproduccion; -import Logica.Clases.Usuario; -import Logica.DataType.*; -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoListaDeReproduccion; -import Logica.Enumerados.TipoValoracion; -import Logica.Fabrica; -import Logica.Interfaces.IAdmin; -import java.sql.Date; -import java.sql.Time; -import java.util.ArrayList; -import javax.management.RuntimeErrorException; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class CAdminTest { - private static boolean sistemaInicializado = false; - private IAdmin instance = null; - - public CAdminTest() { - Fabrica f = Fabrica.getInstancia(); - instance = f.getIAdmin(); - - if (sistemaInicializado){ - return; - } - - System.out.println("Agregando usuarios"); - instance.altaUsuarioCanal( - new DtUsuario("usu1", "contrasenia1", "nombre1", "apellido1", "correo1", new Date(86, 5, 18), "imagen1", 0), - new DtCanal(0, "canal1", "descripcion1", Privacidad.PUBLICO) - ); - instance.altaUsuarioCanal( - new DtUsuario("usu2", "contrasenia2", "nombre2", "apellido2", "correo2", new Date(95, 9, 23), "imagen2", 0), - new DtCanal(0, "canal2", "descripcion2", Privacidad.PUBLICO) - ); - instance.altaUsuarioCanal( - new DtUsuario("usu3", "contrasenia3", "nombre3", "apellido3", "correo3", new Date(95, 10, 3), "imagen3", 0), - new DtCanal(0, "canal3", "descripcion3", Privacidad.PUBLICO) - ); - - System.out.println("Agregando categoria y lista por defecto"); - instance.altaCategoria("ARTE"); - instance.altaListaDeReproduccionPorDefecto( - new DtListaDeReproduccion(0, "Favoritos", Privacidad.PRIVADO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED") - ); - - System.out.println("Agregando a usu1 3 videos y una lista"); - instance.seleccionarUsuario("usu1"); - instance.altaVideo( - new DtVideo(0, "video1", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "UNDEFINED", 0, 0) - ); - instance.altaVideo( - new DtVideo(0, "video2", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "ARTE", 0, 0) - ); - instance.altaVideo( - new DtVideo(0, "video3", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "UNDEFINED", 0, 0) - ); - instance.altaListaDeReproduccionParticular( - new DtListaDeReproduccion(0, "mi lista", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED") - ); - - System.out.println("Agregando a usu2 3 videos y una lista"); - instance.seleccionarUsuario("usu2"); - instance.altaVideo( - new DtVideo(0, "video1", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "UNDEFINED", 0, 0) - ); - instance.altaVideo( - new DtVideo(0, "video2", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "ARTE", 0, 0) - ); - instance.altaVideo( - new DtVideo(0, "video3", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "UNDEFINED", 0, 0) - ); - instance.altaListaDeReproduccionParticular( - new DtListaDeReproduccion(0, "mi lista", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED") - ); - - System.out.println("Agregando a usu3 3 videos y una lista"); - instance.seleccionarUsuario("usu3"); - instance.altaVideo( - new DtVideo(0, "video1", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "ARTE", 0, 0) - ); - instance.altaVideo( - new DtVideo(0, "video2", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "UNDEFINED", 0, 0) - ); - instance.altaVideo( - new DtVideo(0, "video3", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "ARTE", 0, 0) - ); - instance.altaListaDeReproduccionParticular( - new DtListaDeReproduccion(0, "mi lista", Privacidad.PUBLICO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED") - ); - - System.out.println("--- Carga de datos de prueba finalizada ---"); - sistemaInicializado = true; - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - instance.liberarMemoriaListaDeReproduccion(); - instance.liberarMemoriaUsuario(); - instance.liberarMemoriaUsuarioActual(); - instance.liberarMemoriaVideo(); - } - - @After - public void tearDown() { - instance.liberarMemoriaListaDeReproduccion(); - instance.liberarMemoriaUsuario(); - instance.liberarMemoriaUsuarioActual(); - instance.liberarMemoriaVideo(); - } - - /** - * Test of getInstancia method, of class CAdmin. - */ - @Test - public void testGetInstancia_1() { - System.out.println("getInstancia"); - CAdmin result = null; - try { - result = CAdmin.getInstancia(); - assertNotNull(result); - } catch (Exception e) { - assertNull(null); - } - } - @Test - public void testGetInstancia_2() { - System.out.println("getInstancia"); - CAdmin expResult = CAdmin.getInstancia(); - CAdmin result = null; - try { - result = CAdmin.getInstancia(); - assertSame(expResult, result); - } catch (Exception e) { - assertNull(null); - } - } - - /** - * Test of agregarVideoAListaDeReproduccion method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_AgregarVideoAListaDeReproduccion() { - System.out.println("agregarVideoAListaDeReproduccion"); - // el sistema no tiene ningun usuario seleccionado, - // osea, apunta a null - // entonces debe saltar una excepcion - instance.agregarVideoAListaDeReproduccion(0); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_AgregarVideoAListaDeReproduccion() { - System.out.println("agregarVideoAListaDeReproduccion"); - instance.seleccionarUsuario("usu1"); - instance.agregarVideoAListaDeReproduccion(0); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_AgregarVideoAListaDeReproduccion() { - System.out.println("agregarVideoAListaDeReproduccion"); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.agregarVideoAListaDeReproduccion(0); - } - @Test(expected = RuntimeException.class) - public void testThrow_4_AgregarVideoAListaDeReproduccion() { - System.out.println("agregarVideoAListaDeReproduccion"); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarVideo(1); - instance.agregarVideoAListaDeReproduccion(0); - } - @Test - public void test_AgregarVideoAListaDeReproduccion() { - System.out.println("agregarVideoAListaDeReproduccion"); - - instance.seleccionarUsuario("usu2"); - instance.seleccionarListaDeReproduccion(5); - int antes = instance.listarVideosDeListaDeReproduccion().size(); - - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarVideo(1); - - instance.agregarVideoAListaDeReproduccion(5); - - instance.seleccionarUsuario("usu2"); - int despues = instance.listarVideosDeListaDeReproduccion().size(); - - assertNotEquals(antes, despues); - } - - - /** - * Test of altaCategoria method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_AltaCategoria() { - System.out.println("altaCategoria"); - String categoria = ""; - instance.altaCategoria(categoria); - - } - @Test(expected = RuntimeException.class) - public void testThrow_2_AltaCategoria() { - System.out.println("altaCategoria"); - String categoria = "UNDEFINED"; - instance.altaCategoria(categoria); - } - @Test - public void test_AltaCategoria() { - System.out.println("altaCategoria"); - String categoria = "MUSICA"; - instance.altaCategoria(categoria); - assertNull(null); - } - - /** - * Test of altaComentario method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_AltaComentario_DtComentario() { - System.out.println("altaComentario"); - DtComentario dtCom = null; - instance.altaComentario(dtCom); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_AltaComentario_DtComentario() { - System.out.println("altaComentario"); - DtComentario dtCom = null; - instance.seleccionarUsuario("usu1"); - instance.altaComentario(dtCom); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_AltaComentario_DtComentario() { - System.out.println("altaComentario"); - DtComentario dtCom = null; - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.altaComentario(dtCom); - } - @Test(expected = RuntimeException.class) - public void testThrow_4_AltaComentario_DtComentario() { - System.out.println("altaComentario"); - DtComentario dtCom = new DtComentario(0, "esto no deberia aparecer", new Date(119, 8, 24), "texto del comentario", 0); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.altaComentario(dtCom); - } - @Test - public void test_AltaComentario_DtComentario() { - System.out.println("altaComentario"); - DtComentario dtCom = new DtComentario(0, "esto no deberia aparecer", new Date(119, 8, 24), "texto del comentario", 0); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarVideo(1); - instance.altaComentario(dtCom); - ArrayList<DtComentario> result = instance.listarComentariosDeVideo(); - for (int i = 0; i < result.size(); i++){ - if (result.get(i).getTexto().equals("texto del comentario")){ - assertTrue(true); - return; - } - } - assertTrue(false); - } - - /** - * Test of altaComentario method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_AltaComentario_DtComentario_int() { - System.out.println("altaComentario"); - DtComentario dtCom = null; - instance.altaComentario(dtCom, 0); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_AltaComentario_DtComentario_int() { - System.out.println("altaComentario"); - DtComentario dtCom = null; - instance.seleccionarUsuario("usu1"); - instance.altaComentario(dtCom, 0); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_AltaComentario_DtComentario_int() { - System.out.println("altaComentario"); - DtComentario dtCom = null; - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.altaComentario(dtCom, 0); - } - @Test(expected = RuntimeException.class) - public void testThrow_4_AltaComentario_DtComentario_int() { - System.out.println("altaComentario"); - DtComentario dtCom = new DtComentario(0, "esto no deberia aparecer", new Date(119, 8, 24), "texto del comentario", 0); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.altaComentario(dtCom, 0); - } - @Test - public void test_AltaComentario_DtComentario_int() { - System.out.println("altaComentario"); - DtComentario dtCom = new DtComentario(0, "esto no deberia aparecer", new Date(119, 8, 24), "texto del comentario", 0); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarVideo(1); - instance.altaComentario(dtCom, 0); - ArrayList<DtComentario> result = instance.listarComentariosDeVideo(); - for (int i = 0; i < result.size(); i++){ - if (result.get(i).getTexto().equals("texto del comentario")){ - assertTrue(false); - return; - } - } - assertTrue(true); - } - - /** - * Test of altaListaDeReproduccionParticular method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_AltaListaDeReproduccionParticular() { - System.out.println("altaListaDeReproduccionParticular"); - DtListaDeReproduccion lista = null; - instance.altaListaDeReproduccionParticular(lista); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_AltaListaDeReproduccionParticular() { - System.out.println("altaListaDeReproduccionParticular"); - DtListaDeReproduccion lista = null; - instance.seleccionarUsuario("usu1"); - instance.altaListaDeReproduccionParticular(lista); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_AltaListaDeReproduccionParticular() { - System.out.println("altaListaDeReproduccionParticular"); - DtListaDeReproduccion lista = new DtListaDeReproduccion(0, "Videos de maincraf", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "deporte"); - instance.seleccionarUsuario("usu1"); - instance.altaListaDeReproduccionParticular(lista); - } - @Test - public void test_AltaListaDeReproduccionParticular() { - System.out.println("altaListaDeReproduccionParticular"); - DtListaDeReproduccion lista = new DtListaDeReproduccion(0, "Videos de maincraf", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - instance.seleccionarUsuario("usu1"); - instance.altaListaDeReproduccionParticular(lista); - } - - /** - * Test of altaListaDeReproduccionPorDefecto method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_AltaListaDeReproduccionPorDefecto() { - System.out.println("altaListaDeReproduccionPorDefecto"); - DtListaDeReproduccion lista = null; - instance.altaListaDeReproduccionPorDefecto(lista); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_AltaListaDeReproduccionPorDefecto() { - System.out.println("altaListaDeReproduccionPorDefecto"); - DtListaDeReproduccion lista = new DtListaDeReproduccion(0, "", Privacidad.PRIVADO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED"); - instance.altaListaDeReproduccionPorDefecto(lista); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_AltaListaDeReproduccionPorDefecto() { - System.out.println("altaListaDeReproduccionPorDefecto"); - DtListaDeReproduccion lista = new DtListaDeReproduccion(0, "Ver mas tarde", Privacidad.PRIVADO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED"); - instance.altaListaDeReproduccionPorDefecto(lista); - } - @Test - public void test_AltaListaDeReproduccionPorDefecto() { - System.out.println("altaListaDeReproduccionPorDefecto"); - DtListaDeReproduccion lista = new DtListaDeReproduccion(0, "Tutoriales", Privacidad.PRIVADO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED"); - instance.altaListaDeReproduccionPorDefecto(lista); - - boolean agregadoAClase = ListaDeReproduccion.listarNombresDeListasPorDefecto().contains("Tutoriales"); - instance.seleccionarUsuario("usu3"); - ArrayList<DtListaDeReproduccion> lsts = instance.listarListasDeReproduccionDeUsuario("usu3"); - boolean agregadoACanal = false; - for (int i = 0; i < lsts.size(); i++){ - if (lsts.get(i).getNombre().equals(lista.getNombre())){ - agregadoACanal = true; - break; - } - } - assertTrue(agregadoAClase && agregadoACanal); - } - - - - /** - * Test of altaUsuarioCanal method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_AltaUsuarioCanal() { - System.out.println("altaUsuarioCanal"); - DtUsuario usr = null; - DtCanal canal = null; - instance.altaUsuarioCanal(usr, canal); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_AltaUsuarioCanal() { - System.out.println("altaUsuarioCanal"); - DtUsuario usr = new DtUsuario("usu4", "contrasenia2", "nombre2", "apellido2", "correo2", new Date(95, 9, 23), "imagen2", 0); - DtCanal canal = null; - instance.altaUsuarioCanal(usr, canal); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_AltaUsuarioCanal() { - System.out.println("altaUsuarioCanal"); - DtUsuario usr = new DtUsuario("", "contrasenia2", "nombre2", "apellido2", "correo2", new Date(95, 9, 23), "imagen2", 0); - DtCanal canal = new DtCanal(0, "canal2", "descripcion2", Privacidad.PUBLICO); - instance.altaUsuarioCanal(usr, canal); - } - @Test(expected = RuntimeException.class) - public void testThrow_4_AltaUsuarioCanal() { - System.out.println("altaUsuarioCanal"); - DtUsuario usr = new DtUsuario("usu4", "contrasenia2", "nombre2", "apellido2", "correo2", new Date(95, 9, 23), "imagen2", 0); - DtCanal canal = new DtCanal(0, "canal2", "descripcion2", Privacidad.PUBLICO); - instance.altaUsuarioCanal(usr, canal); - } - - @Test - public void testThrow_5_AltaUsuarioCanal() { - System.out.println("altaUsuarioCanal"); - DtUsuario usr = new DtUsuario("usu4", "contrasenia4", "nombre4", "apellido4", "correo4", new Date(95, 9, 23), "imagen4", 0); - DtCanal canal = new DtCanal(0, "canal4", "descripcion4", Privacidad.PRIVADO); - instance.altaUsuarioCanal(usr, canal); - } - - - /** - * Test of altaValoracion method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_AltaValoracion() { - System.out.println("altaValoracion"); - DtValoracion val = null; - instance.altaValoracion(val); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_AltaValoracion() { - System.out.println("altaValoracion"); - DtValoracion val = null; - instance.seleccionarUsuario("usu1"); - instance.altaValoracion(val); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_AltaValoracion() { - System.out.println("altaValoracion"); - DtValoracion val = null; - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.altaValoracion(val); - } - @Test(expected = RuntimeException.class) - public void testThrow_4_AltaValoracion() { - System.out.println("altaValoracion"); - DtValoracion val = new DtValoracion(TipoValoracion.LIKE, ""); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.altaValoracion(val); - } - @Test - public void test_AltaValoracion() { - System.out.println("altaValoracion"); - DtValoracion val = new DtValoracion(TipoValoracion.LIKE, ""); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarVideo(1); - instance.altaValoracion(val); - } - - /** - * Test of altaVideo method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_AltaVideo() { - System.out.println("altaVideo"); - DtVideo video = null; - instance.altaVideo(video); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_AltaVideo() { - System.out.println("altaVideo"); - DtVideo video = null; - instance.seleccionarUsuario("usu1"); - instance.altaVideo(video); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_AltaVideo() { - System.out.println("altaVideo"); - DtVideo video = new DtVideo(0, "video4", "descripcio4", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "DEPORTE", 0, 0); - instance.seleccionarUsuario("usu1"); - int antes = instance.listarVideosDeUsuario().size(); - instance.altaVideo(video); - int despues = instance.listarVideosDeUsuario().size(); - assertNotEquals(antes, despues); - } - @Test - public void test_AltaVideo() { - System.out.println("altaVideo"); - DtVideo video = new DtVideo(0, "video4", "descripcio4", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "UNDEFINED", 0, 0); - instance.seleccionarUsuario("usu1"); - int antes = instance.listarVideosDeUsuario().size(); - instance.altaVideo(video); - int despues = instance.listarVideosDeUsuario().size(); - assertNotEquals(antes, despues); - } - - - /** - * Test of existeCategoria method, of class CAdmin. - */ - @Test - public void test_1_ExisteCategoria() { - System.out.println("existeCategoria"); - String cat = "DEPORTES"; - boolean expResult = false; - boolean result = instance.existeCategoria(cat); - assertEquals(expResult, result); - } - @Test - public void test_2_ExisteCategoria() { - System.out.println("existeCategoria"); - String cat = "UNDEFINED"; - boolean expResult = true; - boolean result = instance.existeCategoria(cat); - assertEquals(expResult, result); - } - - - /** - * Test of existeEmail method, of class CAdmin. - */ - @Test - public void test_1_ExisteEmail() { - System.out.println("existeEmail"); - String email = "correo1111"; - boolean expResult = false; - boolean result = instance.existeEmail(email); - assertEquals(expResult, result); - } - @Test - public void test_2_ExisteEmail() { - System.out.println("existeEmail"); - String email = "correo2"; - boolean expResult = true; - boolean result = instance.existeEmail(email); - assertEquals(expResult, result); - } - - /** - * Test of existeNickname method, of class CAdmin. - */ - @Test - public void test_1_ExisteNickname() { - System.out.println("existeNickname"); - String nickname = "usu0"; - boolean expResult = false; - boolean result = instance.existeNickname(nickname); - assertEquals(expResult, result); - } - @Test - public void test_2_ExisteNickname() { - System.out.println("existeNickname"); - String nickname = "usu3"; - boolean expResult = true; - boolean result = instance.existeNickname(nickname); - assertEquals(expResult, result); - } - - /** - * Test of iniciarSesionAdministrador method, of class CAdmin. - */ - @Test - public void test_1_IniciarSesionAdministrador() { - System.out.println("iniciarSesionAdministrador"); - int id = 5; - String pass = "passwd"; - boolean expResult = false; - boolean result = instance.iniciarSesionAdministrador(id, pass); - assertEquals(expResult, result); - } - @Test - public void test_2_IniciarSesionAdministrador() { - System.out.println("iniciarSesionAdministrador"); - int id = 0; - String pass = "passwd"; - boolean expResult = false; - boolean result = instance.iniciarSesionAdministrador(id, pass); - assertEquals(expResult, result); - } - @Test - public void test_3_IniciarSesionAdministrador() { - System.out.println("iniciarSesionAdministrador"); - int id = 0; - String pass = "admin"; - boolean expResult = true; - boolean result = instance.iniciarSesionAdministrador(id, pass); - assertEquals(expResult, result); - } - - /** - * Test of iniciarSesionUsuario method, of class CAdmin. - */ - @Test - public void test_1_IniciarSesionUsuario() { - System.out.println("iniciarSesionUsuario"); - String nickname = "usu777"; - String pass = "usu777"; - CAdmin ins = CAdmin.getInstancia(); - boolean expResult = false; - boolean result = ins.iniciarSesionUsuario(nickname, pass); - assertEquals(expResult, result); - } - @Test - public void test_2_IniciarSesionUsuario() { - System.out.println("iniciarSesionUsuario"); - String nickname = "usu3"; - String pass = "usu777"; - CAdmin ins = CAdmin.getInstancia(); - boolean expResult = false; - boolean result = ins.iniciarSesionUsuario(nickname, pass); - assertEquals(expResult, result); - } - @Test - public void test_3_IniciarSesionUsuario() { - System.out.println("iniciarSesionUsuario"); - String nickname = "usu3"; - String pass = "contrasenia3"; - CAdmin ins = CAdmin.getInstancia(); - boolean expResult = true; - boolean result = ins.iniciarSesionUsuario(nickname, pass); - assertEquals(expResult, result); - } - - /** - * Test of liberarMemoriaListaDeReproduccion method, of class CAdmin. - */ - @Test - public void testThrow_1_LiberarMemoriaListaDeReproduccion() { - System.out.println("liberarMemoriaListaDeReproduccion"); - instance.liberarMemoriaListaDeReproduccion(); - } - - /** - * Test of liberarMemoriaUsuario method, of class CAdmin. - */ - @Test - public void testThrow_1_LiberarMemoriaUsuario() { - System.out.println("liberarMemoriaUsuario"); - instance.liberarMemoriaUsuario(); - } - - /** - * Test of liberarMemoriaUsuarioActual method, of class CAdmin. - */ - @Test - public void testThrow_1_LiberarMemoriaUsuarioActual() { - System.out.println("liberarMemoriaUsuarioActual"); - instance.liberarMemoriaUsuarioActual(); - } - - /** - * Test of liberarMemoriaVideo method, of class CAdmin. - */ - @Test - public void testThrow_1_LiberarMemoriaVideo() { - System.out.println("liberarMemoriaVideo"); - instance.liberarMemoriaVideo(); - } - - /** - * Test of listarCategorias method, of class CAdmin. - */ - @Test - public void testThrow_1_ListarCategorias() { - System.out.println("listarCategorias"); - ArrayList<String> result = instance.listarCategorias(); - assertTrue(result.size() > 0 && result.contains("UNDEFINED")); - } - - /** - * Test of listarComentariosDeVideo method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarComentariosDeVideo() { - System.out.println("listarComentariosDeVideo"); - ArrayList<DtComentario> expResult = null; - ArrayList<DtComentario> result = instance.listarComentariosDeVideo(); - } - @Test(expected = RuntimeException.class) - public void testThrow__ListarComentariosDeVideo() { - System.out.println("listarComentariosDeVideo"); - ArrayList<DtComentario> expResult = null; - instance.seleccionarUsuario("usu1"); - ArrayList<DtComentario> result = instance.listarComentariosDeVideo(); - } - @Test - public void test_ListarComentariosDeVideo() { - System.out.println("listarComentariosDeVideo"); - - DtComentario dtCom = new DtComentario(0, "esto no deberia aparecer", new Date(119, 8, 24), "test_ListarComentariosDeVideo", 0); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarVideo(1); - instance.altaComentario(dtCom); - - ArrayList<DtComentario> result = instance.listarComentariosDeVideo(); - for (int i = 0; i < result.size(); i++){ - if (result.get(i).getTexto().equals(dtCom.getTexto())){ - assertTrue(true); - return; - } - } - assertTrue(false); - } - - /** - * Test of listarListasDeReproduccionEnCategoria method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarListasDeReproduccionEnCategoria() { - System.out.println("listarListasDeReproduccionEnCategoria"); - String cat = ""; - ArrayList<DtListaDeReproduccion> expResult = null; - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionEnCategoria(cat); - assertEquals(expResult, result); - } - @Test - public void test_1_ListarListasDeReproduccionEnCategoria() { - System.out.println("listarListasDeReproduccionEnCategoria"); - String cat = "UNDEFINED"; - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionEnCategoria(cat); - - for (int i = 0; i < result.size(); i++) { - if ("UNDEFINED" != result.get(i).getCategoria()) { - assertTrue(true); - assertTrue(false); - return; - } - } - assertTrue(true); - } - @Test - public void test_2_ListarListasDeReproduccionEnCategoria() { - System.out.println("listarListasDeReproduccionEnCategoria"); - String cat = "ASTRONOMIA"; - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionEnCategoria(cat); - assertEquals(0, result.size()); - } - - - /** - * Test of listarListasDeReproduccionDeUsuario method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarListasDeReproduccionDeUsuario() { - System.out.println("listarListasDeReproduccionDeUsuario"); - String nickname = ""; - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionDeUsuario(nickname); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_ListarListasDeReproduccionDeUsuario() { - System.out.println("listarListasDeReproduccionDeUsuario"); - String nickname = "nickname"; - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionDeUsuario(nickname); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_ListarListasDeReproduccionDeUsuario() { - System.out.println("listarListasDeReproduccionDeUsuario"); - String nickname = "nickname"; - instance.seleccionarUsuario("usu1"); - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionDeUsuario(nickname); - } - @Test(expected = RuntimeException.class) - public void testThrow_4_ListarListasDeReproduccionDeUsuario() { - System.out.println("listarListasDeReproduccionDeUsuario"); - String nickname = "nickname"; - instance.seleccionarUsuarioActual("usu2"); - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionDeUsuario(nickname); - } - @Test(expected = RuntimeException.class) - public void testThrow_5_ListarListasDeReproduccionDeUsuario() { - System.out.println("listarListasDeReproduccionDeUsuario"); - String nickname = "nickname"; - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu2"); - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionDeUsuario(nickname); - } - @Test - public void testThrow_7_ListarListasDeReproduccionDeUsuario() { - System.out.println("listarListasDeReproduccionDeUsuario"); - String nickname = "usu2"; - instance.seleccionarUsuario("usu2"); - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionDeUsuario(nickname); - assertTrue(result.get(0).getId() == 2); - } - @Test - public void testThrow_9_ListarListasDeReproduccionDeUsuario() { - System.out.println("listarListasDeReproduccionDeUsuario"); - String nickname = "usu2"; - instance.seleccionarUsuarioActual("usu2"); - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionDeUsuario(nickname); - assertTrue(result.size() == 3); - } - - - /** - * Test of listarListasDeReproduccionParticularesDeUsuario method, of class - * CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarListasDeReproduccionParticularesDeUsuario() { - System.out.println("listarListasDeReproduccionParticularesDeUsuario"); - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionParticularesDeUsuario(); - } - @Test - public void test_ListarListasDeReproduccionParticularesDeUsuario() { - System.out.println("listarListasDeReproduccionParticularesDeUsuario"); - instance.seleccionarUsuario("usu3"); - ArrayList<DtListaDeReproduccion> result = instance.listarListasDeReproduccionParticularesDeUsuario(); - for (int i = 0; i < result.size(); i++) { - if (result.get(i).getTipo() != TipoListaDeReproduccion.PARTICULAR) { - assertTrue(false); - return; - } - } - assertTrue(true); - } - - /** - * Test of listarUsuarioSeguidores method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarUsuarioSeguidores() { - System.out.println("listarUsuarioSeguidores"); - ArrayList<DtUsuario> result = instance.listarUsuarioSeguidores(); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_ListarUsuarioSeguidores() { - System.out.println("listarUsuarioSeguidores"); - instance.seleccionarUsuarioActual("usu1"); - ArrayList<DtUsuario> result = instance.listarUsuarioSeguidores(); - } - @Test - public void test_ListarUsuarioSeguidores() { - System.out.println("listarUsuarioSeguidores"); - // usuarios 1 y 2 siguen al 3 - instance.seleccionarUsuario("usu3"); - instance.seleccionarUsuarioActual("usu1"); - instance.seguirUsuario(); - instance.seleccionarUsuarioActual("usu2"); - instance.seguirUsuario(); - - instance.seleccionarUsuario("usu3"); - ArrayList<DtUsuario> result = instance.listarUsuarioSeguidores(); - - // deshago que usuarios 1 y 2 siguen al 3 - instance.seleccionarUsuario("usu3"); - instance.seleccionarUsuarioActual("usu1"); - instance.seguirUsuario(); - instance.seleccionarUsuarioActual("usu2"); - instance.seguirUsuario(); - - for (int i = 0; i < result.size(); i++){ - if (result.get(i).getNickname() != "usu1" && result.get(i).getNickname() != "usu2") { - assertTrue(false); - return; - } - } - assertTrue(true); - } - - - - /** - * Test of listarUsuarioNoSeguidos method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarUsuarioNoSeguidos() { - System.out.println("listarUsuarioSeguidos"); - ArrayList<DtUsuario> result = instance.listarUsuarioNoSeguidos(); - } - @Test - public void test_ListarUsuarioNoSeguidos() { - System.out.println("listarUsuarioSeguidos"); - - instance.seleccionarUsuario("usu3"); - ArrayList<DtUsuario> seguidos = instance.listarUsuarioSeguidos(); - instance.seleccionarUsuarioActual("usu3"); - for (DtUsuario u : seguidos){ - instance.seleccionarUsuario(u.getNickname()); - instance.seguirUsuario(); - } - - // usuarios 3 sige a 1 - instance.seleccionarUsuarioActual("usu3"); - instance.seleccionarUsuario("usu1"); - instance.seguirUsuario(); - - instance.seleccionarUsuario("usu3"); - ArrayList<DtUsuario> result = instance.listarUsuarioNoSeguidos(); - - for (DtUsuario u : result){ - if (u.getNickname().equals("usu1") || u.getNickname().equals("usu3")){ - assertTrue(false); - } - } - assertTrue(true); - } - - - - - - - - - - - - /** - * Test of listarUsuarioSeguidos method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarUsuarioSeguidos() { - System.out.println("listarUsuarioSeguidos"); - ArrayList<DtUsuario> result = instance.listarUsuarioSeguidos(); - } - @Test - public void test_ListarUsuarioSeguidos() { - System.out.println("listarUsuarioSeguidos"); - - // usuarios 3 sige a 1 y 2 - instance.seleccionarUsuarioActual("usu3"); - instance.seleccionarUsuario("usu1"); - instance.seguirUsuario(); - instance.seleccionarUsuario("usu2"); - instance.seguirUsuario(); - - ArrayList<DtUsuario> result = instance.listarUsuarioSeguidos(); - - // deshago que usuarios 3 sige a 1 y 2 - instance.seleccionarUsuario("usu1"); - instance.seguirUsuario(); - instance.seleccionarUsuario("usu2"); - instance.seguirUsuario(); - - for (int i = 0; i < result.size(); i++){ - if (result.get(i).getNickname() != "usu1" || result.get(i).getNickname() != "usu2") { - assertTrue(false); - return; - } - } - assertTrue(true); - - } - - - /** - * Test of listarUsuarios method, of class CAdmin. - */ - @Test - public void testThrow_1_ListarUsuarios() { - System.out.println("listarUsuarios"); - ArrayList<DtUsuario> result = instance.listarUsuarios(); - assertTrue(result.size() == 3); - } - - - /** - * Test of listarVideosEnCategoria method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarVideosEnCategoria() { - System.out.println("listarVideosEnCategoria"); - String cat = ""; - ArrayList<DtVideo> result = instance.listarVideosEnCategoria(cat); - } - @Test - public void testThrow_2_ListarVideosEnCategoria() { - System.out.println("listarVideosEnCategoria"); - String cat = "DEPORTE"; - ArrayList<DtVideo> result = instance.listarVideosEnCategoria(cat); - assertTrue(result.size() == 0); - } - @Test - public void test_ListarVideosEnCategoria() { - System.out.println("listarVideosEnCategoria"); - String cat = "ARTE"; - ArrayList<DtVideo> result = instance.listarVideosEnCategoria(cat); - - for (int i = 0; i < result.size(); i++){ - if (result.get(i).getCategoria() != "ARTE") { - assertTrue(false); - return; - } - } - assertTrue(true); - } - - - /** - * Test of listarVideosDeUsuario method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarVideosDeUsuario() { - System.out.println("listarVideosDeUsuario"); - ArrayList<DtVideo> result = instance.listarVideosDeUsuario(); - } - @Test - public void test_ListarVideosDeUsuario() { - System.out.println("listarVideosDeUsuario"); - instance.seleccionarUsuario("usu1"); - ArrayList<DtVideo> result = instance.listarVideosDeUsuario(); - assertTrue(result.size() == 3); - } - - - /** - * Test of listarVideosDeListaDeReproduccion method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ListarVideosDeListaDeReproduccion() { - System.out.println("listarVideosDeListaDeReproduccion"); - ArrayList<DtVideo> result = instance.listarVideosDeListaDeReproduccion(); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_ListarVideosDeListaDeReproduccion() { - System.out.println("listarVideosDeListaDeReproduccion"); - instance.seleccionarUsuario("usu3"); - ArrayList<DtVideo> result = instance.listarVideosDeListaDeReproduccion(); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_ListarVideosDeListaDeReproduccion() { - System.out.println("listarVideosDeListaDeReproduccion"); - instance.seleccionarUsuario("usu3"); - instance.seleccionarVideo(555); - ArrayList<DtVideo> result = instance.listarVideosDeListaDeReproduccion(); - } - @Test - public void test_ListarVideosDeListaDeReproduccion() { - System.out.println("listarVideosDeListaDeReproduccion"); - instance.seleccionarUsuario("usu3"); - instance.seleccionarListaDeReproduccion(9); - ArrayList<DtVideo> result = instance.listarVideosDeListaDeReproduccion(); - assertTrue(result.size() == 0); - } - - /** - * Test of modificarListaDeReproduccion method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ModificarListaDeReproduccion() { - System.out.println("modificarListaDeReproduccion"); - instance.modificarListaDeReproduccion(null); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_ModificarListaDeReproduccion() { - System.out.println("modificarListaDeReproduccion"); - instance.seleccionarUsuario("usu1"); - instance.modificarListaDeReproduccion(null); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_ModificarListaDeReproduccion() { - System.out.println("modificarListaDeReproduccion"); - instance.seleccionarUsuario("usu1"); - instance.seleccionarListaDeReproduccion(7); - instance.modificarListaDeReproduccion(null); - } - @Test(expected = RuntimeException.class) - public void testThrow_4_ModificarListaDeReproduccion() { - System.out.println("modificarListaDeReproduccion"); - DtListaDeReproduccion dt = new DtListaDeReproduccion(0, "Favoritos", Privacidad.PUBLICO, TipoListaDeReproduccion.POR_DEFECTO, "DEPORTE"); - instance.seleccionarUsuario("usu1"); - instance.seleccionarListaDeReproduccion(7); - instance.modificarListaDeReproduccion(dt); - } - @Test(expected = RuntimeException.class) - public void testThrow_5_ModificarListaDeReproduccion() { - System.out.println("modificarListaDeReproduccion"); - DtListaDeReproduccion dt = new DtListaDeReproduccion(0, "Favoritos", Privacidad.PUBLICO, TipoListaDeReproduccion.POR_DEFECTO, "UNDEFINED"); - instance.seleccionarUsuario("usu1"); - instance.seleccionarListaDeReproduccion(7); - instance.modificarListaDeReproduccion(dt); - } - @Test - public void test_ModificarListaDeReproduccion() { - System.out.println("modificarListaDeReproduccion"); - DtListaDeReproduccion dt = new DtListaDeReproduccion(0, "Alfa-jores", Privacidad.PUBLICO, TipoListaDeReproduccion.POR_DEFECTO, "ARTE"); - instance.seleccionarUsuario("usu1"); - instance.seleccionarListaDeReproduccion(7); - instance.modificarListaDeReproduccion(dt); - assertTrue(instance.seleccionarListaDeReproduccion(7).getNombre() == "Alfa-jores"); - - } - - /** - * Test of modificarUsuarioYCanal method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ModificarUsuarioYCanal() { - System.out.println("modificarUsuarioYCanal"); - DtUsuario usr = null; - DtCanal canal = null; - instance.modificarUsuarioYCanal(usr, canal); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_ModificarUsuarioYCanal() { - System.out.println("modificarUsuarioYCanal"); - instance.seleccionarUsuario("usu1"); - DtUsuario usr = null; - DtCanal canal = null; - instance.modificarUsuarioYCanal(usr, canal); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_ModificarUsuarioYCanal() { - System.out.println("modificarUsuarioYCanal"); - instance.seleccionarUsuario("usu1"); - DtUsuario usr = new DtUsuario("usuario1", "pass1", "nombre mod", "apellido mod", "correo mod", new Date(55, 11, 21), "imagen mod", 123456); - DtCanal canal = null; - instance.modificarUsuarioYCanal(usr, canal); - } - @Test(expected = RuntimeException.class) - public void testThrow_4_ModificarUsuarioYCanal() { - System.out.println("modificarUsuarioYCanal"); - instance.seleccionarUsuario("usu1"); - DtUsuario usr = new DtUsuario("usuario1", "pass1", "nombre mod", "apellido mod", "correo mod", new Date(55, 11, 21), "imagen mod", 123456); - DtCanal canal = new DtCanal(0, "canal mod", "descripcion3 mod", Privacidad.PRIVADO); - instance.modificarUsuarioYCanal(usr, canal); - } - @Test(expected = RuntimeException.class) - public void testThrow_5_ModificarUsuarioYCanal() { - System.out.println("modificarUsuarioYCanal"); - instance.seleccionarUsuario("usu1"); - DtUsuario usr = new DtUsuario("usu1", "pass1", "nombre mod", "apellido mod", "correo mod", new Date(55, 11, 21), "imagen mod", 123456); - DtCanal canal = new DtCanal(0, "canal mod", "descripcion3 mod", Privacidad.PRIVADO); - instance.modificarUsuarioYCanal(usr, canal); - } - @Test - public void test_ModificarUsuarioYCanal() { - System.out.println("modificarUsuarioYCanal"); - DtUsuario usuRef = instance.seleccionarUsuario("usu1"); - DtCanal canRef = instance.obtenerCanalDeUsuario(); - DtUsuario usr = new DtUsuario("usu1", "pass1", "nombre mod", "apellido mod", "correo1", new Date(55, 11, 21), "imagen mod", 123456); - DtCanal canal = new DtCanal(0, "canal mod", "descripcion3 mod", Privacidad.PRIVADO); - instance.modificarUsuarioYCanal(usr, canal); - DtUsuario usuPost = instance.seleccionarUsuario("usu1"); - DtCanal canPost = instance.obtenerCanalDeUsuario(); - - assertTrue( - usuRef.toString() != usuPost.toString() && - canRef.toString() != canPost.toString() - ); - } - - - /** - * Test of modificarVideo method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ModificarVideo() { - System.out.println("modificarVideo"); - DtVideo video = null; - instance.modificarVideo(video); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_ModificarVideo() { - System.out.println("modificarVideo"); - DtVideo video = null; - instance.seleccionarUsuario("usu1"); - instance.modificarVideo(video); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_ModificarVideo() { - System.out.println("modificarVideo"); - DtVideo video = null; - instance.seleccionarUsuario("usu1"); - instance.seleccionarVideo(1); - instance.modificarVideo(video); - } - @Test(expected = RuntimeException.class) - public void testThrow_4_ModificarVideo() { - System.out.println("modificarVideo"); - DtVideo video = new DtVideo(0, "video2", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "DEPORTE", 0, 0); - instance.seleccionarUsuario("usu1"); - instance.seleccionarVideo(1); - instance.modificarVideo(video); - } - @Test(expected = RuntimeException.class) - public void testThrow_5_ModificarVideo() { - System.out.println("modificarVideo"); - DtVideo video = new DtVideo(0, "video2", "descripcion", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "ARTE", 1000, 5); - instance.seleccionarUsuario("usu1"); - instance.seleccionarVideo(1); - instance.modificarVideo(video); - } - @Test - public void test_ModificarVideo() { - System.out.println("modificarVideo"); - DtVideo video = new DtVideo(0, "video2", "descripcion modificada", new Time(1, 2, 3), new Date(11, 1, 1), "url", Privacidad.PRIVADO, "ARTE", 1000, 5); - instance.seleccionarUsuario("usu1"); - DtVideo antes = instance.seleccionarVideo(2); - instance.modificarVideo(video); - DtVideo despues = instance.seleccionarVideo(2); - assertNotEquals(antes.toString(), despues.toString()); - } - - - - /** - * Test of obtenerPropietarioDeVideo method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ObtenerPropietarioDeVideo() { - System.out.println("obtenerCanalDeUsuario"); - DtUsuario dtu = instance.obtenerPropietarioDeVideo(500); - } - @Test - public void test_ObtenerPropietarioDeVideo() { - System.out.println("obtenerCanalDeUsuario"); - DtUsuario dtu = instance.obtenerPropietarioDeVideo(8); - assertTrue(dtu.getNickname().equals("usu3")); - } - - - - /** - * Test of obtenerCanalDeUsuario method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ObtenerCanalDeUsuario() { - System.out.println("obtenerCanalDeUsuario"); - DtCanal expResult = null; - DtCanal result = instance.obtenerCanalDeUsuario(); - } - - - /** - * Test of obtenerValoracionesDeVideo method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ObtenerValoracionesDeVideo() { - System.out.println("obtenerValoracionesDeVideo"); - ArrayList<DtValoracion> expResult = null; - ArrayList<DtValoracion> result = instance.obtenerValoracionesDeVideo(); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_ObtenerValoracionesDeVideo() { - System.out.println("obtenerValoracionesDeVideo"); - ArrayList<DtValoracion> expResult = null; - instance.seleccionarUsuario("usu1"); - ArrayList<DtValoracion> result = instance.obtenerValoracionesDeVideo(); - } - @Test - public void test_ObtenerValoracionesDeVideo() { - System.out.println("obtenerValoracionesDeVideo"); - - instance.seleccionarUsuario("usu3"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarVideo(8); - instance.altaValoracion(new DtValoracion(TipoValoracion.LIKE, "nickname")); - - instance.seleccionarUsuario("usu3"); - instance.seleccionarVideo(8); - ArrayList<DtValoracion> result = instance.obtenerValoracionesDeVideo(); - - for (int i = 0; i < result.size(); i++){ - if (result.get(i).getNickname().equals("usu2")){ - assertTrue(true); - return; - } - } - assertTrue(false); - } - - /** - * Test of obtenerValoracionDada method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ObtenerValoracionDada() { - System.out.println("obtenerValoracionDada"); - DtValoracion expResult = null; - DtValoracion result = instance.obtenerValoracionDada(); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_ObtenerValoracionDada() { - System.out.println("obtenerValoracionDada"); - instance.seleccionarUsuarioActual("usu2"); - DtValoracion expResult = null; - DtValoracion result = instance.obtenerValoracionDada(); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_ObtenerValoracionDada() { - System.out.println("obtenerValoracionDada"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarUsuario("usu2"); - DtValoracion expResult = null; - DtValoracion result = instance.obtenerValoracionDada(); - } - @Test - public void test_1_ObtenerValoracionDada() { - System.out.println("obtenerValoracionDada"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarUsuario("usu2"); - instance.seleccionarVideo(5); - - DtValoracion expResult = null; - DtValoracion result = instance.obtenerValoracionDada(); - assertEquals(expResult, result); - } - @Test - public void test_2_ObtenerValoracionDada() { - System.out.println("obtenerValoracionDada"); - - instance.seleccionarUsuario("usu2"); - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarVideo(5); - instance.altaValoracion(new DtValoracion(TipoValoracion.DISLIKE, "nickname")); - - instance.seleccionarUsuarioActual("usu2"); - instance.seleccionarUsuario("usu2"); - instance.seleccionarVideo(5); - - DtValoracion expResult = new DtValoracion(TipoValoracion.DISLIKE, "usu2"); - DtValoracion result = instance.obtenerValoracionDada(); - assertEquals(expResult.toString(), result.toString()); - } - - /** - * Test of quitarVideoDeListaDeReproduccion method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_QuitarVideoDeListaDeReproduccion() { - System.out.println("quitarVideoDeListaDeReproduccion"); - instance.quitarVideoDeListaDeReproduccion(5); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_QuitarVideoDeListaDeReproduccion() { - System.out.println("quitarVideoDeListaDeReproduccion"); - instance.seleccionarUsuario("usu1"); - instance.quitarVideoDeListaDeReproduccion(5); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_QuitarVideoDeListaDeReproduccion() { - System.out.println("quitarVideoDeListaDeReproduccion"); - instance.seleccionarUsuario("usu1"); - instance.seleccionarListaDeReproduccion(1); - instance.quitarVideoDeListaDeReproduccion(0); - } - @Test - public void test_1_QuitarVideoDeListaDeReproduccion() { - System.out.println("quitarVideoDeListaDeReproduccion"); - instance.seleccionarUsuario("usu1"); - instance.seleccionarListaDeReproduccion(1); - instance.quitarVideoDeListaDeReproduccion(5); - assertEquals(0, instance.listarVideosDeListaDeReproduccion().size()); - } - @Test - public void test_2_QuitarVideoDeListaDeReproduccion() { - System.out.println("quitarVideoDeListaDeReproduccion"); - - instance.seleccionarUsuario("usu2"); - instance.seleccionarUsuarioActual("usu1"); - instance.seleccionarVideo(5); - instance.agregarVideoAListaDeReproduccion(1); - - instance.seleccionarUsuario("usu1"); - instance.seleccionarListaDeReproduccion(1); - int antes = instance.listarVideosDeListaDeReproduccion().size(); - - instance.seleccionarUsuario("usu1"); - instance.seleccionarListaDeReproduccion(1); - instance.quitarVideoDeListaDeReproduccion(5); - int despues = instance.listarVideosDeListaDeReproduccion().size(); - - assertEquals(antes-1, despues); - } - - - /** - * Test of seleccionarUsuario method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_SeleccionarUsuario() { - System.out.println("seleccionarUsuario"); - String nickname = ""; - DtUsuario result = instance.seleccionarUsuario(nickname); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_SeleccionarUsuario() { - System.out.println("seleccionarUsuario"); - String nickname = "nickname inexistente"; - DtUsuario result = instance.seleccionarUsuario(nickname); - } - @Test - public void test_SeleccionarUsuario() { - System.out.println("seleccionarUsuario"); - String nickname = "usu3"; - DtUsuario result = instance.seleccionarUsuario(nickname); - assertNotNull(result); - } - - /** - * Test of seleccionarUsuarioActual method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_SeleccionarUsuarioActual() { - System.out.println("seleccionarUsuario"); - String nickname = ""; - DtUsuario result = instance.seleccionarUsuarioActual(nickname); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_SeleccionarUsuarioActual() { - System.out.println("seleccionarUsuario"); - String nickname = "nickname inexistente"; - DtUsuario result = instance.seleccionarUsuarioActual(nickname); - } - @Test - public void test_SeleccionarUsuarioActual() { - System.out.println("seleccionarUsuario"); - String nickname = "usu3"; - DtUsuario result = instance.seleccionarUsuarioActual(nickname); - assertNotNull(result); - } - - - /** - * Test of seleccionarVideo method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_SeleccionarVideo() { - System.out.println("seleccionarVideo"); - int idVideo = 0; - DtVideo expResult = null; - DtVideo result = instance.seleccionarVideo(idVideo); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_SeleccionarVideo() { - System.out.println("seleccionarVideo"); - int idVideo = 9; - instance.seleccionarUsuario("usu1"); - DtVideo expResult = null; - DtVideo result = instance.seleccionarVideo(idVideo); - } - @Test - public void test_SeleccionarVideo() { - System.out.println("seleccionarVideo"); - int idVideo = 9; - instance.seleccionarUsuario("usu3"); - DtVideo expResult = null; - DtVideo result = instance.seleccionarVideo(idVideo); - assertTrue(result.getId() == 9); - } - - - /** - * Test of seleccionarListaDeReproduccion method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_SeleccionarListaDeReproduccion() { - System.out.println("seleccionarListaDeReproduccion"); - int idLista = 0; - DtListaDeReproduccion result = instance.seleccionarListaDeReproduccion(idLista); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_SeleccionarListaDeReproduccion() { - System.out.println("seleccionarListaDeReproduccion"); - int idLista = 3; - instance.seleccionarUsuario("usu1"); - DtListaDeReproduccion result = instance.seleccionarListaDeReproduccion(idLista); - } - @Test - public void test_SeleccionarListaDeReproduccion() { - System.out.println("seleccionarListaDeReproduccion"); - int idLista = 4; - instance.seleccionarUsuario("usu1"); - DtListaDeReproduccion result = instance.seleccionarListaDeReproduccion(idLista); - assertTrue(result.getId() == 4); - } - - - /** - * Test of seguirUsuario method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_SeguirUsuario() { - System.out.println("seguirUsuario"); - instance.seguirUsuario(); - } - @Test(expected = RuntimeException.class) - public void testThrow_2_SeguirUsuario() { - System.out.println("seguirUsuario"); - instance.seleccionarUsuarioActual("usu1"); - instance.seguirUsuario(); - } - @Test(expected = RuntimeException.class) - public void testThrow_3_SeguirUsuario() { - System.out.println("seguirUsuario"); - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu1"); - instance.seguirUsuario(); - } - @Test - public void test_SeguirUsuario() { - System.out.println("seguirUsuario"); - instance.seleccionarUsuario("usu1"); - ArrayList<DtUsuario> seguidos = instance.listarUsuarioSeguidores(); - for (DtUsuario u : seguidos){ - instance.seleccionarUsuarioActual(u.getNickname()); - instance.seguirUsuario(); - } - instance.seleccionarUsuario("usu1"); - instance.seleccionarUsuarioActual("usu3"); - - int antes = instance.listarUsuarioSeguidores().size(); - instance.seguirUsuario(); - int despues = instance.listarUsuarioSeguidores().size(); - - assertEquals(antes+1, despues); - } - - - - /** - * Test of validarNuevaListaParticular method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void testThrow_1_ValidarNuevaListaParticular() { - System.out.println("validarNuevaListaParticular"); - String nombre = ""; - boolean expResult = false; - boolean result = instance.validarNuevaListaParticular(nombre); - } - @Test - public void test_1_ValidarNuevaListaParticular() { - System.out.println("validarNuevaListaParticular"); - String nombre = "Favoritos"; - instance.seleccionarUsuario("usu1"); - boolean expResult = false; - boolean result = instance.validarNuevaListaParticular(nombre); - assertEquals(expResult, result); - } - @Test - public void test_2_ValidarNuevaListaParticular() { - System.out.println("validarNuevaListaParticular"); - String nombre = "terraplanismo"; - instance.seleccionarUsuario("usu1"); - boolean expResult = true; - boolean result = instance.validarNuevaListaParticular(nombre); - assertEquals(expResult, result); - } - - /** - * Test of validarNuevaListaPorDefecto method, of class CAdmin. - */ - @Test(expected = RuntimeException.class) - public void test_1_ValidarNuevaListaPorDefecto() { - System.out.println("validarNuevaListaPorDefecto"); - String nombre = ""; - boolean expResult = false; - boolean result = instance.validarNuevaListaPorDefecto(nombre); - assertEquals(expResult, result); - } - @Test - public void test_2_ValidarNuevaListaPorDefecto() { - System.out.println("validarNuevaListaPorDefecto"); - String nombre = "Ver mas tarde"; - boolean expResult = false; - boolean result = instance.validarNuevaListaPorDefecto(nombre); - assertEquals(expResult, result); - } - @Test - public void test_3_ValidarNuevaListaPorDefecto() { - System.out.println("validarNuevaListaPorDefecto"); - String nombre = "mi lista"; - boolean expResult = false; - boolean result = instance.validarNuevaListaPorDefecto(nombre); - assertEquals(expResult, result); - } - @Test - public void test_4_ValidarNuevaListaPorDefecto() { - System.out.println("validarNuevaListaPorDefecto"); - String nombre = "Reviews de Yerba"; - boolean expResult = true; - boolean result = instance.validarNuevaListaPorDefecto(nombre); - assertEquals(expResult, result); - } - - - - - - -} diff --git a/UyTube_aplicacion/test/Logica/DataType/DtCanalTest.java b/UyTube_aplicacion/test/Logica/DataType/DtCanalTest.java deleted file mode 100644 index 411298da5a55e4f74235d62dcc545719640bf65a..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/DataType/DtCanalTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.DataType; - -import Logica.Enumerados.Privacidad; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class DtCanalTest { - - DtCanal instance = null; - - public DtCanalTest() { - instance = new DtCanal(0, "nombre", "descripcion", Privacidad.PRIVADO); - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getId method, of class DtCanal. - */ - @Test - public void testGetId() { - System.out.println("getId"); - int expResult = 0; - int result = instance.getId(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getNombre method, of class DtCanal. - */ - @Test - public void testGetNombre() { - System.out.println("getNombre"); - String expResult = "nombre"; - String result = instance.getNombre(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getDescripcion method, of class DtCanal. - */ - @Test - public void testGetDescripcion() { - System.out.println("getDescripcion"); - String expResult = "descripcion"; - String result = instance.getDescripcion(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getPrivacidad method, of class DtCanal. - */ - @Test - public void testGetPrivacidad() { - System.out.println("getPrivacidad"); - Privacidad expResult = Privacidad.PRIVADO; - Privacidad result = instance.getPrivacidad(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of toString method, of class DtCanal. - */ - @Test - public void testToString() { - System.out.println("toString"); - String expResult = "DtCanal{id=0, nombre=nombre, descripcion=descripcion, privacidad=PRIVADO}"; - String result = instance.toString(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/DataType/DtCategoriaTest.java b/UyTube_aplicacion/test/Logica/DataType/DtCategoriaTest.java deleted file mode 100644 index 5205137fcbfa11175118de827764a75a271086b9..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/DataType/DtCategoriaTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.DataType; - -import Logica.Clases.Categoria; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class DtCategoriaTest { - - public DtCategoriaTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getNombre method, of class DtCategoria. - */ - @Test - public void testGetNombre() { - System.out.println("getNombre"); - DtCategoria instance = new DtCategoria("MUSICA"); - String expResult = "MUSICA"; - String result = instance.getNombre(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of toString method, of class DtCategoria. - */ - @Test - public void testToString() { - System.out.println("toString"); - DtCategoria instance = new DtCategoria("MUSICA"); - String expResult = "DtCategoria{nombre=MUSICA}"; - String result = instance.toString(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/DataType/DtComentarioTest.java b/UyTube_aplicacion/test/Logica/DataType/DtComentarioTest.java deleted file mode 100644 index fb798fefdfdab63cb4f5293b8d72e7603e14e9f5..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/DataType/DtComentarioTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.DataType; - -import java.sql.Date; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class DtComentarioTest { - - public DtComentarioTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getId method, of class DtComentario. - */ - @Test - public void testGetId() { - System.out.println("getId"); - DtComentario instance = new DtComentario(0, "nickname", new Date(2019-1900, 1, 1), "texto", 1); - int expResult = 0; - int result = instance.getId(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getNickname method, of class DtComentario. - */ - @Test - public void testGetNickname() { - System.out.println("getNickname"); - DtComentario instance = new DtComentario(0, "nickname", new Date(2019-1900, 1, 1), "texto", 1); - String expResult = "nickname"; - String result = instance.getNickname(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getFecha method, of class DtComentario. - */ - @Test - public void testGetFecha() { - System.out.println("getFecha"); - DtComentario instance = new DtComentario(0, "nickname", new Date(2019-1900, 1, 1), "texto", 1); - Date expResult = new Date(2019-1900, 1, 1); - Date result = instance.getFecha(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getTexto method, of class DtComentario. - */ - @Test - public void testGetTexto() { - System.out.println("getTexto"); - DtComentario instance = new DtComentario(0, "nickname", new Date(2019-1900, 1, 1), "texto", 1); - String expResult = "texto"; - String result = instance.getTexto(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getNivelSubComentario method, of class DtComentario. - */ - @Test - public void testGetNivelSubComentario() { - System.out.println("getNivelSubComentario"); - DtComentario instance = new DtComentario(0, "nickname", new Date(2019-1900, 1, 1), "texto", 1); - int expResult = 1; - int result = instance.getNivelSubComentario(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of toString method, of class DtComentario. - */ - @Test - public void testToString() { - System.out.println("toString"); - DtComentario instance = new DtComentario(0, "nickname", new Date(2019-1900, 1, 1), "texto", 1); - String expResult = "DtComentario{id=0, nickname=nickname, fecha=2019-02-01, texto=texto, nivelSubComentario=1}"; - String result = instance.toString(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/DataType/DtListaDeReproduccionTest.java b/UyTube_aplicacion/test/Logica/DataType/DtListaDeReproduccionTest.java deleted file mode 100644 index bae99bca9dbe3384d746cd0da16a0590fcf19485..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/DataType/DtListaDeReproduccionTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.DataType; - -import Logica.Clases.ListaDeReproduccion; -import Logica.Enumerados.Privacidad; -import Logica.Enumerados.TipoListaDeReproduccion; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class DtListaDeReproduccionTest { - - public DtListaDeReproduccionTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getId method, of class DtListaDeReproduccion. - */ - @Test - public void testGetId() { - System.out.println("getId"); - DtListaDeReproduccion instance = new DtListaDeReproduccion(0, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - int expResult = 0; - int result = instance.getId(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getNombre method, of class DtListaDeReproduccion. - */ - @Test - public void testGetNombre() { - System.out.println("getNombre"); - DtListaDeReproduccion instance = new DtListaDeReproduccion(0, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - String expResult = "nombre"; - String result = instance.getNombre(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getPrivacidad method, of class DtListaDeReproduccion. - */ - @Test - public void testGetPrivacidad() { - System.out.println("getPrivacidad"); - DtListaDeReproduccion instance = new DtListaDeReproduccion(0, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - Privacidad expResult = Privacidad.PRIVADO; - Privacidad result = instance.getPrivacidad(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getTipo method, of class DtListaDeReproduccion. - */ - @Test - public void testGetTipo() { - System.out.println("getTipo"); - DtListaDeReproduccion instance = new DtListaDeReproduccion(0, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - TipoListaDeReproduccion expResult = TipoListaDeReproduccion.PARTICULAR; - TipoListaDeReproduccion result = instance.getTipo(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getCategoria method, of class DtListaDeReproduccion. - */ - @Test - public void testGetCategoria() { - System.out.println("getCategoria"); - DtListaDeReproduccion instance = new DtListaDeReproduccion(0, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - String expResult = "UNDEFINED"; - String result = instance.getCategoria(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of toString method, of class DtListaDeReproduccion. - */ - @Test - public void testToString() { - System.out.println("toString"); - DtListaDeReproduccion instance = new DtListaDeReproduccion(0, "nombre", Privacidad.PRIVADO, TipoListaDeReproduccion.PARTICULAR, "UNDEFINED"); - String expResult = "DtListaDeReproduccion{id=0, nombre=nombre, privacidad=PRIVADO, tipo=PARTICULAR, categoria=UNDEFINED}"; - String result = instance.toString(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/DataType/DtPersonaTest.java b/UyTube_aplicacion/test/Logica/DataType/DtPersonaTest.java deleted file mode 100644 index 47ce2e83d9eb05323f5c5f1c65fd131e89864d3d..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/DataType/DtPersonaTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.DataType; - -import java.sql.Date; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class DtPersonaTest { - - public DtPersonaTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getNombre method, of class DtPersona. - */ - @Test - public void testGetNombre() { - System.out.println("getNickname"); - DtUsuario instance = new DtUsuario( - "nickname", - "contrasenia", - "nombre", - "apellido", - "correo", - new Date(2019-1900, 1, 1), - "imagen", - 0); - String expResult = "nombre"; - String result = instance.getNombre(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getApellido method, of class DtPersona. - */ - @Test - public void testGetApellido() { - System.out.println("getNickname"); - DtUsuario instance = new DtUsuario( - "nickname", - "contrasenia", - "nombre", - "apellido", - "correo", - new Date(2019-1900, 1, 1), - "imagen", - 0); - String expResult = "apellido"; - String result = instance.getApellido(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getContrasenia method, of class DtPersona. - */ - @Test - public void testGetContrasenia() { - System.out.println("getNickname"); - DtUsuario instance = new DtUsuario( - "nickname", - "contrasenia", - "nombre", - "apellido", - "correo", - new Date(2019-1900, 1, 1), - "imagen", - 0); - String expResult = "contrasenia"; - String result = instance.getContrasenia(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/DataType/DtUsuarioTest.java b/UyTube_aplicacion/test/Logica/DataType/DtUsuarioTest.java deleted file mode 100644 index e98ca2a2302e5698a5926e6f4e1d19852a427abc..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/DataType/DtUsuarioTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.DataType; - -import java.sql.Date; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class DtUsuarioTest { - - public DtUsuarioTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getNickname method, of class DtUsuario. - */ - @Test - public void testGetNickname() { - System.out.println("getNickname"); - DtUsuario instance = new DtUsuario( - "nickname", - "contrasenia", - "nombre", - "apellido", - "correo", - new Date(2019-1900, 1, 1), - "imagen", - 0); - String expResult = "nickname"; - String result = instance.getNickname(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - - /** - * Test of getCorreo method, of class DtUsuario. - */ - @Test - public void testGetCorreo() { - System.out.println("getCorreo"); - DtUsuario instance = new DtUsuario( - "nickname", - "contrasenia", - "nombre", - "apellido", - "correo", - new Date(2019-1900, 1, 1), - "imagen", - 0); - String expResult = "correo"; - String result = instance.getCorreo(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getFechaNacimiento method, of class DtUsuario. - */ - @Test - public void testGetFechaNacimiento() { - System.out.println("getFechaNacimiento"); - DtUsuario instance = new DtUsuario( - "nickname", - "contrasenia", - "nombre", - "apellido", - "correo", - new Date(2019-1900, 1, 1), - "imagen", - 0); - Date expResult = new Date(2019-1900, 1, 1); - Date result = instance.getFechaNacimiento(); - assertEquals(expResult.toString(), result.toString()); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getImagen method, of class DtUsuario. - */ - @Test - public void testGetImagen() { - System.out.println("getImagen"); - DtUsuario instance = new DtUsuario( - "nickname", - "contrasenia", - "nombre", - "apellido", - "correo", - new Date(2019-1900, 1, 1), - "imagen", - 0); - String expResult = "imagen"; - String result = instance.getImagen(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getCantSeguidores method, of class DtUsuario. - */ - @Test - public void testGetCantSeguidores() { - System.out.println("getCantSeguidores"); - DtUsuario instance = new DtUsuario( - "nickname", - "contrasenia", - "nombre", - "apellido", - "correo", - new Date(2019-1900, 1, 1), - "imagen", - 0); - int expResult = 0; - int result = instance.getCantSeguidores(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of toString method, of class DtUsuario. - */ - @Test - public void testToString() { - System.out.println("toString"); - DtUsuario instance = new DtUsuario( - "nickname", - "contrasenia", - "nombre", - "apellido", - "correo", - new Date(2019-1900, 1, 1), - "imagen", - 0); - String expResult = "DtUsuario{DtPersona{nombre=nombre, apellido=apellido, contrasenia=contrasenia}, nickname=nickname, correo=correo, fechaNacimiento=2019-02-01, imagen=imagen, cantSeguidores=0}"; - String result = instance.toString(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/DataType/DtValoracionTest.java b/UyTube_aplicacion/test/Logica/DataType/DtValoracionTest.java deleted file mode 100644 index 3372fce2457d73d67e7e6b8dbec3c4de9ed1172d..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/DataType/DtValoracionTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.DataType; - -import Logica.Enumerados.TipoValoracion; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class DtValoracionTest { - - public DtValoracionTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getNickname method, of class DtValoracion. - */ - @Test - public void testGetNickname() { - System.out.println("getNickname"); - DtValoracion instance = new DtValoracion(TipoValoracion.LIKE, "nickname"); - String expResult = "nickname"; - String result = instance.getNickname(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of getVal method, of class DtValoracion. - */ - @Test - public void testGetVal() { - System.out.println("getVal"); - DtValoracion instance = new DtValoracion(TipoValoracion.LIKE, "nickname"); - TipoValoracion expResult = TipoValoracion.LIKE; - TipoValoracion result = instance.getVal(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of toString method, of class DtValoracion. - */ - @Test - public void testToString() { - System.out.println("toString"); - DtValoracion instance = new DtValoracion(TipoValoracion.LIKE, "nickname"); - String expResult = "DtValoracion{val=LIKE, nickname=nickname}"; - String result = instance.toString(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/DataType/DtVideoTest.java b/UyTube_aplicacion/test/Logica/DataType/DtVideoTest.java deleted file mode 100644 index 6b6c855899b23b866bccd2795c7d184716dfe53a..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/DataType/DtVideoTest.java +++ /dev/null @@ -1,139 +0,0 @@ -package Logica.DataType; - -import Logica.Enumerados.Privacidad; -import java.sql.Date; -import java.sql.Time; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Carlos BM - */ -public class DtVideoTest { - - DtVideo dtv; - public DtVideoTest() { - dtv = new DtVideo(2, "video1", "un_video", new Time(1,1,1), new Date(190,1,2), "https://sdsd.com", Privacidad.PRIVADO, "futbol", 0, 0); - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - @Test - public void testGetId() { - System.out.println("getId"); - DtVideo instance = dtv; - int expResult = 2; - int result = instance.getId(); - assertEquals(expResult, result); - } - - @Test - public void testGetNombre() { - System.out.println("getNombre"); - DtVideo instance = dtv; - String expResult = "video1"; - String result = instance.getNombre(); - assertEquals(expResult, result); - } - - @Test - public void testGetDescripcion() { - System.out.println("getDescripcion"); - DtVideo instance = dtv; - String expResult = "un_video"; - String result = instance.getDescripcion(); - assertEquals(expResult, result); - } - - @Test - public void testGetDuracion() { - System.out.println("getDuracion"); - DtVideo instance = dtv; - Time expResult = new Time(1,1,1); - Time result = instance.getDuracion(); - assertEquals(expResult, result); - } - - @Test - public void testGetFechaPublicacion() { - System.out.println("getFechaPublicacion"); - DtVideo instance = dtv; - Date expResult = new Date(190,1,2); - Date result = instance.getFechaPublicacion(); - assertEquals(expResult, result); - } - - @Test - public void testGetUrlVideoOriginal() { - System.out.println("getUrlVideoOriginal"); - DtVideo instance = dtv; - String expResult = "https://sdsd.com"; - String result = instance.getUrlVideoOriginal(); - assertEquals(expResult, result); - } - - @Test - public void testGetPrivacidad() { - System.out.println("getPrivacidad"); - DtVideo instance = dtv; - Privacidad expResult = Privacidad.PRIVADO; - Privacidad result = instance.getPrivacidad(); - assertEquals(expResult, result); - } - - @Test - public void testGetCategoria() { - System.out.println("getCategoria"); - DtVideo instance = dtv; - String expResult = "futbol"; - String result = instance.getCategoria(); - assertEquals(expResult, result); - } - - @Test - public void testGetCantLikes() { - System.out.println("getCantLikes"); - DtVideo instance = dtv; - int expResult = 0; - int result = instance.getCantLikes(); - assertEquals(expResult, result); - } - - @Test - public void testGetCantDisLikes() { - System.out.println("getCantDisLikes"); - DtVideo instance = dtv; - int expResult = 0; - int result = instance.getCantDisLikes(); - assertEquals(expResult, result); - } - - @Test - public void testToString() { - System.out.println("toString"); - DtVideo instance = dtv; - String expResult = "DtVideo{id=2, nombre=video1, descripcion=un_video, duracion=01:01:01, fechaPublicacion=2090-02-02, urlVideoOriginal=https://sdsd.com, privacidad=PRIVADO, categoria=futbol, cantLikes=0, cantDisLikes=0}"; - String result = instance.toString(); - assertEquals(expResult, result); - } - -} diff --git a/UyTube_aplicacion/test/Logica/Enumerados/PrivacidadTest.java b/UyTube_aplicacion/test/Logica/Enumerados/PrivacidadTest.java deleted file mode 100644 index 4fe10a6ddb83ae647354d36683368c9b84a9034b..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Enumerados/PrivacidadTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Enumerados; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class PrivacidadTest { - - public PrivacidadTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of values method, of class Privacidad. - */ - @Test - public void testValues() { - System.out.println("values"); - Privacidad[] expResult = {Privacidad.PUBLICO, Privacidad.PRIVADO}; - Privacidad[] result = Privacidad.values(); - assertArrayEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of valueOf method, of class Privacidad. - */ - @Test - public void testValueOf() { - System.out.println("valueOf"); - String name = "PRIVADO"; - Privacidad expResult = Privacidad.PRIVADO; - Privacidad result = Privacidad.valueOf(name); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/Enumerados/TipoListaDeReproduccionTest.java b/UyTube_aplicacion/test/Logica/Enumerados/TipoListaDeReproduccionTest.java deleted file mode 100644 index dfa276361a3fe0b7a117c17abbf250b510fab29e..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Enumerados/TipoListaDeReproduccionTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Enumerados; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class TipoListaDeReproduccionTest { - - public TipoListaDeReproduccionTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of values method, of class TipoListaDeReproduccion. - */ - @Test - public void testValues() { - System.out.println("values"); - TipoListaDeReproduccion[] expResult = {TipoListaDeReproduccion.POR_DEFECTO, TipoListaDeReproduccion.PARTICULAR}; - TipoListaDeReproduccion[] result = TipoListaDeReproduccion.values(); - assertArrayEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of valueOf method, of class TipoListaDeReproduccion. - */ - @Test - public void testValueOf() { - System.out.println("valueOf"); - String name = "POR_DEFECTO"; - TipoListaDeReproduccion expResult = TipoListaDeReproduccion.POR_DEFECTO; - TipoListaDeReproduccion result = TipoListaDeReproduccion.valueOf(name); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/Enumerados/TipoValoracionTest.java b/UyTube_aplicacion/test/Logica/Enumerados/TipoValoracionTest.java deleted file mode 100644 index ca066e9d180ce8268881a3ac9ec7111791cf0f9d..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/Enumerados/TipoValoracionTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica.Enumerados; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class TipoValoracionTest { - - public TipoValoracionTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of values method, of class TipoValoracion. - */ - @Test - public void testValues() { - System.out.println("values"); - TipoValoracion[] expResult = {TipoValoracion.LIKE, TipoValoracion.DISLIKE}; - TipoValoracion[] result = TipoValoracion.values(); - assertArrayEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - - /** - * Test of valueOf method, of class TipoValoracion. - */ - @Test - public void testValueOf() { - System.out.println("valueOf"); - String name = "LIKE"; - TipoValoracion expResult = TipoValoracion.LIKE; - TipoValoracion result = TipoValoracion.valueOf(name); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - //fail("The test case is a prototype."); - } - -} diff --git a/UyTube_aplicacion/test/Logica/FabricaTest.java b/UyTube_aplicacion/test/Logica/FabricaTest.java deleted file mode 100644 index 827d48e84db46e298af229f9def8963b0c8ab4fb..0000000000000000000000000000000000000000 --- a/UyTube_aplicacion/test/Logica/FabricaTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package Logica; - -import Logica.Interfaces.IAdmin; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Juan - */ -public class FabricaTest { - - public FabricaTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getInstancia method, of class Fabrica. - */ - @Test - public void testGetInstancia_1() { - System.out.println("testGetInstancia_1"); - Fabrica result = Fabrica.getInstancia(); - assertNotNull(result); - } - @Test - public void testGetInstancia_2() { - System.out.println("testGetInstancia_1"); - Fabrica expResult = Fabrica.getInstancia(); - Fabrica result = Fabrica.getInstancia(); - assertSame(expResult, result); - } - - /** - * Test of getIAdmin method, of class Fabrica. - */ - @Test - public void testGetIAdmin_1() { - System.out.println("testGetIAdmin_1"); - Fabrica instance = Fabrica.getInstancia(); - IAdmin result = instance.getIAdmin(); - assertNotNull(result); - } - @Test - public void testGetIAdmin_2() { - System.out.println("testGetIAdmin_2"); - Fabrica instance = Fabrica.getInstancia(); - IAdmin expResult = instance.getIAdmin(); - IAdmin result = instance.getIAdmin(); - assertSame(expResult, result); - } - -}