Se comenzaron a realizar unit tests
Junto con ello se modificaron las clases para poder hacer la conexion a una uri diferente para sqlite.
This commit is contained in:
BIN
dist/Programa Caja.jar
vendored
BIN
dist/Programa Caja.jar
vendored
Binary file not shown.
@@ -40,6 +40,7 @@ public class Main {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
setUpSystemProperties();
|
setUpSystemProperties();
|
||||||
|
DAOManager.setup();
|
||||||
updateDatabase();
|
updateDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,8 +113,12 @@ public class CajasController {
|
|||||||
DAOManager.getEfectivoDAO().insertDefault(efectivo);
|
DAOManager.getEfectivoDAO().insertDefault(efectivo);
|
||||||
|
|
||||||
Documentos documentos = new Documentos();
|
Documentos documentos = new Documentos();
|
||||||
|
documentos.setTarjetas(0);
|
||||||
|
documentos.setCheques(0);
|
||||||
|
documentos.setRetiros(0);
|
||||||
documentos.setCaja(c);
|
documentos.setCaja(c);
|
||||||
DAOManager.getDocumentosDAO().insertDefault(documentos);
|
DAOManager.getDocumentosDAO().insert(documentos);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -47,18 +47,18 @@ import danielcortes.xyz.models.version.VersionDAO;
|
|||||||
|
|
||||||
public class DAOManager {
|
public class DAOManager {
|
||||||
|
|
||||||
private static final CajaDAO cajaDAO;
|
private static CajaDAO cajaDAO;
|
||||||
private static final CalculoFondoDAO calculoFondoDAO;
|
private static CalculoFondoDAO calculoFondoDAO;
|
||||||
private static final DocumentosDAO documentosDAO;
|
private static DocumentosDAO documentosDAO;
|
||||||
private static final EfectivoDAO efectivoDAO;
|
private static EfectivoDAO efectivoDAO;
|
||||||
private static final EgresoDAO egresoDAO;
|
private static EgresoDAO egresoDAO;
|
||||||
private static final IngresoDAO ingresoDAO;
|
private static IngresoDAO ingresoDAO;
|
||||||
private static final TipoEgresoDAO tipoEgresoDAO;
|
private static TipoEgresoDAO tipoEgresoDAO;
|
||||||
private static final TipoIngresoDAO tipoIngresoDAO;
|
private static TipoIngresoDAO tipoIngresoDAO;
|
||||||
private static final EstadoResultadoDAO estadoResultadoDAO;
|
private static EstadoResultadoDAO estadoResultadoDAO;
|
||||||
private static final VersionDAO versionDAO;
|
private static VersionDAO versionDAO;
|
||||||
|
|
||||||
static {
|
public static void setup() {
|
||||||
cajaDAO = new SQLiteCajaDAO();
|
cajaDAO = new SQLiteCajaDAO();
|
||||||
calculoFondoDAO = new SQLiteCalculoFondoDAO();
|
calculoFondoDAO = new SQLiteCalculoFondoDAO();
|
||||||
documentosDAO = new SQLiteDocumentosDAO();
|
documentosDAO = new SQLiteDocumentosDAO();
|
||||||
@@ -71,6 +71,19 @@ public class DAOManager {
|
|||||||
versionDAO = new SQLiteVersionDAO();
|
versionDAO = new SQLiteVersionDAO();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setup(ConnectionHolder connectionHolder){
|
||||||
|
cajaDAO = new SQLiteCajaDAO(connectionHolder);
|
||||||
|
calculoFondoDAO = new SQLiteCalculoFondoDAO(connectionHolder);
|
||||||
|
documentosDAO = new SQLiteDocumentosDAO(connectionHolder);
|
||||||
|
efectivoDAO = new SQLiteEfectivoDAO(connectionHolder);
|
||||||
|
egresoDAO = new SQLiteEgresoDAO(connectionHolder);
|
||||||
|
ingresoDAO = new SQLiteIngresoDAO(connectionHolder);
|
||||||
|
tipoEgresoDAO = new SQLiteTipoEgresoDAO(connectionHolder);
|
||||||
|
tipoIngresoDAO = new SQLiteTipoIngresoDAO(connectionHolder);
|
||||||
|
estadoResultadoDAO = new SQLiteEstadoResultadoDAO(connectionHolder);
|
||||||
|
versionDAO = new SQLiteVersionDAO(connectionHolder);
|
||||||
|
}
|
||||||
|
|
||||||
public static CajaDAO getCajaDAO() {
|
public static CajaDAO getCajaDAO() {
|
||||||
return cajaDAO;
|
return cajaDAO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ public class SQLiteConnectionHolder implements ConnectionHolder {
|
|||||||
this.databaseURI = Configuration.get("sqlite_database_uri");
|
this.databaseURI = Configuration.get("sqlite_database_uri");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteConnectionHolder(String databaseURI){
|
||||||
|
this.databaseURI = databaseURI;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
Connection con = null;
|
Connection con = null;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
package danielcortes.xyz.models.caja;
|
package danielcortes.xyz.models.caja;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Caja {
|
public class Caja {
|
||||||
public final static Caja EMPTY = new Caja();
|
public final static Caja EMPTY = new Caja();
|
||||||
@@ -66,6 +67,26 @@ public class Caja {
|
|||||||
return "Caja{" +
|
return "Caja{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", fecha=" + fecha +
|
", fecha=" + fecha +
|
||||||
|
", fondo=" + fondo +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof Caja)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Caja caja = (Caja) o;
|
||||||
|
return id == caja.id &&
|
||||||
|
fondo == caja.fondo &&
|
||||||
|
Objects.equals(fecha, caja.fecha);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, fecha, fondo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.caja;
|
package danielcortes.xyz.models.caja;
|
||||||
|
|
||||||
|
import danielcortes.xyz.data.ConnectionHolder;
|
||||||
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -38,12 +39,16 @@ import org.apache.logging.log4j.Logger;
|
|||||||
|
|
||||||
public class SQLiteCajaDAO implements CajaDAO {
|
public class SQLiteCajaDAO implements CajaDAO {
|
||||||
private static final Logger log = LogManager.getLogger(SQLiteCajaDAO.class);
|
private static final Logger log = LogManager.getLogger(SQLiteCajaDAO.class);
|
||||||
private SQLiteConnectionHolder connectionHolder;
|
private ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
public SQLiteCajaDAO() {
|
public SQLiteCajaDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteCajaDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Caja> getAll() {
|
public List<Caja> getAll() {
|
||||||
log.debug("Se intentara conseguir todas las Cajas");
|
log.debug("Se intentara conseguir todas las Cajas");
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
package danielcortes.xyz.models.calculo_fondo;
|
package danielcortes.xyz.models.calculo_fondo;
|
||||||
|
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class CalculoFondo {
|
public class CalculoFondo {
|
||||||
|
|
||||||
@@ -74,4 +75,24 @@ public class CalculoFondo {
|
|||||||
", caja=" + caja +
|
", caja=" + caja +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof CalculoFondo)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CalculoFondo that = (CalculoFondo) o;
|
||||||
|
return id == that.id &&
|
||||||
|
valor == that.valor &&
|
||||||
|
Objects.equals(descripcion, that.descripcion) &&
|
||||||
|
Objects.equals(caja, that.caja);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, valor, descripcion, caja);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ public class SQLiteCalculoFondoDAO implements CalculoFondoDAO {
|
|||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteCalculoFondoDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CalculoFondo> getAll() {
|
public List<CalculoFondo> getAll() {
|
||||||
log.debug("Se intentara conseguir todos los CalculosFondo");
|
log.debug("Se intentara conseguir todos los CalculosFondo");
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
package danielcortes.xyz.models.documentos;
|
package danielcortes.xyz.models.documentos;
|
||||||
|
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Documentos {
|
public class Documentos {
|
||||||
public final static Documentos EMPTY;
|
public final static Documentos EMPTY;
|
||||||
@@ -90,4 +91,25 @@ public class Documentos {
|
|||||||
", caja=" + caja +
|
", caja=" + caja +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof Documentos)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Documentos that = (Documentos) o;
|
||||||
|
return id == that.id &&
|
||||||
|
cheques == that.cheques &&
|
||||||
|
tarjetas == that.tarjetas &&
|
||||||
|
retiros == that.retiros &&
|
||||||
|
Objects.equals(caja, that.caja);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, cheques, tarjetas, retiros, caja);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,12 +67,6 @@ public interface DocumentosDAO {
|
|||||||
*/
|
*/
|
||||||
void insert(Documentos documentos);
|
void insert(Documentos documentos);
|
||||||
|
|
||||||
/**
|
|
||||||
* Inserta un documentos con valores por default.
|
|
||||||
* @param documentos Instancia del documento a guardar
|
|
||||||
*/
|
|
||||||
void insertDefault(Documentos documentos);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actualiza un documentos
|
* Actualiza un documentos
|
||||||
* @param documentos Documento a actualizar
|
* @param documentos Documento a actualizar
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
|||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteDocumentosDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Documentos> getAll() {
|
public List<Documentos> getAll() {
|
||||||
log.debug("Se intentaran conseguir todos los Documentos");
|
log.debug("Se intentaran conseguir todos los Documentos");
|
||||||
@@ -193,27 +197,6 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
|||||||
log.debug("Se inserto el documentos " + documentos);
|
log.debug("Se inserto el documentos " + documentos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void insertDefault(Documentos documentos) {
|
|
||||||
log.debug("Se intentara insertar el documento default " + documentos);
|
|
||||||
String query = "insert into documentos (cheques, tarjetas, retiros, caja_id) values (0,0,0,?)";
|
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
|
||||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
|
||||||
ps.setInt(1, documentos.getCaja().getId());
|
|
||||||
ps.executeUpdate();
|
|
||||||
}
|
|
||||||
try (PreparedStatement ps = conn.prepareStatement("select last_insert_rowid()")) {
|
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
|
||||||
rs.next();
|
|
||||||
documentos.setId(rs.getInt(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Error al intentar insertar el documento por default " + documentos, e);
|
|
||||||
}
|
|
||||||
log.debug("Se inserto el documento por default " + documentos);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Documentos documentos) {
|
public void update(Documentos documentos) {
|
||||||
log.debug("Se intentara actualizar el documentos " + documentos);
|
log.debug("Se intentara actualizar el documentos " + documentos);
|
||||||
@@ -240,6 +223,7 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
|
|||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||||
ps.setInt(1, documentos.getId());
|
ps.setInt(1, documentos.getId());
|
||||||
|
ps.execute();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Error al eliminar el documentos " + documentos, e);
|
log.error("Error al eliminar el documentos " + documentos, e);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
package danielcortes.xyz.models.efectivo;
|
package danielcortes.xyz.models.efectivo;
|
||||||
|
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Efectivo {
|
public class Efectivo {
|
||||||
public final static Efectivo EMPTY;
|
public final static Efectivo EMPTY;
|
||||||
@@ -150,4 +151,33 @@ public class Efectivo {
|
|||||||
", caja=" + caja +
|
", caja=" + caja +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof Efectivo)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Efectivo efectivo = (Efectivo) o;
|
||||||
|
return id == efectivo.id &&
|
||||||
|
veinteMil == efectivo.veinteMil &&
|
||||||
|
diezMil == efectivo.diezMil &&
|
||||||
|
cincoMil == efectivo.cincoMil &&
|
||||||
|
dosMil == efectivo.dosMil &&
|
||||||
|
mil == efectivo.mil &&
|
||||||
|
quinientos == efectivo.quinientos &&
|
||||||
|
cien == efectivo.cien &&
|
||||||
|
cincuenta == efectivo.cincuenta &&
|
||||||
|
diez == efectivo.diez &&
|
||||||
|
Objects.equals(caja, efectivo.caja);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects
|
||||||
|
.hash(id, veinteMil, diezMil, cincoMil, dosMil, mil, quinientos, cien, cincuenta, diez,
|
||||||
|
caja);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ public class SQLiteEfectivoDAO implements EfectivoDAO {
|
|||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteEfectivoDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Efectivo> getAll() {
|
public List<Efectivo> getAll() {
|
||||||
log.debug("Se intentara conseguir todas los Efectivo");
|
log.debug("Se intentara conseguir todas los Efectivo");
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ package danielcortes.xyz.models.egreso;
|
|||||||
|
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Egreso {
|
public class Egreso {
|
||||||
|
|
||||||
@@ -85,7 +86,8 @@ public class Egreso {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String
|
||||||
|
toString() {
|
||||||
return "Egreso{" +
|
return "Egreso{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", nro='" + nro + '\'' +
|
", nro='" + nro + '\'' +
|
||||||
@@ -95,4 +97,26 @@ public class Egreso {
|
|||||||
", caja=" + caja +
|
", caja=" + caja +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof Egreso)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Egreso egreso = (Egreso) o;
|
||||||
|
return id == egreso.id &&
|
||||||
|
valor == egreso.valor &&
|
||||||
|
Objects.equals(nro, egreso.nro) &&
|
||||||
|
Objects.equals(descripcion, egreso.descripcion) &&
|
||||||
|
Objects.equals(tipoEgreso, egreso.tipoEgreso) &&
|
||||||
|
Objects.equals(caja, egreso.caja);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, nro, descripcion, valor, tipoEgreso, caja);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ public class SQLiteEgresoDAO implements EgresoDAO {
|
|||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteEgresoDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Egreso> getAll() {
|
public List<Egreso> getAll() {
|
||||||
log.debug("Se intentara conseguir todos los Egreso");
|
log.debug("Se intentara conseguir todos los Egreso");
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package danielcortes.xyz.models.estado_resultado;
|
package danielcortes.xyz.models.estado_resultado;
|
||||||
|
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class EstadoResultado {
|
public class EstadoResultado {
|
||||||
|
|
||||||
@@ -182,5 +183,67 @@ public class EstadoResultado {
|
|||||||
public void setIvaFavor(int ivaFavor) {
|
public void setIvaFavor(int ivaFavor) {
|
||||||
this.ivaFavor = ivaFavor;
|
this.ivaFavor = ivaFavor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "EstadoResultado{" +
|
||||||
|
"id=" + id +
|
||||||
|
", mes=" + mes +
|
||||||
|
", costoVenta=" + costoVenta +
|
||||||
|
", cuentaCorrienteFactura=" + cuentaCorrienteFactura +
|
||||||
|
", cuentaCorrienteBoleta=" + cuentaCorrienteBoleta +
|
||||||
|
", cuentaCorrienteSinRespaldo=" + cuentaCorrienteSinRespaldo +
|
||||||
|
", remuneraciones=" + remuneraciones +
|
||||||
|
", finiquitos=" + finiquitos +
|
||||||
|
", aguinaldo=" + aguinaldo +
|
||||||
|
", bonosPersonal=" + bonosPersonal +
|
||||||
|
", honorariosContador=" + honorariosContador +
|
||||||
|
", arriendo=" + arriendo +
|
||||||
|
", agua=" + agua +
|
||||||
|
", luz=" + luz +
|
||||||
|
", gas=" + gas +
|
||||||
|
", telefono=" + telefono +
|
||||||
|
", otroServicio=" + otroServicio +
|
||||||
|
", ppm=" + ppm +
|
||||||
|
", ivaFavor=" + ivaFavor +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof EstadoResultado)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
EstadoResultado that = (EstadoResultado) o;
|
||||||
|
return id == that.id &&
|
||||||
|
costoVenta == that.costoVenta &&
|
||||||
|
cuentaCorrienteFactura == that.cuentaCorrienteFactura &&
|
||||||
|
cuentaCorrienteBoleta == that.cuentaCorrienteBoleta &&
|
||||||
|
cuentaCorrienteSinRespaldo == that.cuentaCorrienteSinRespaldo &&
|
||||||
|
remuneraciones == that.remuneraciones &&
|
||||||
|
finiquitos == that.finiquitos &&
|
||||||
|
aguinaldo == that.aguinaldo &&
|
||||||
|
bonosPersonal == that.bonosPersonal &&
|
||||||
|
honorariosContador == that.honorariosContador &&
|
||||||
|
arriendo == that.arriendo &&
|
||||||
|
agua == that.agua &&
|
||||||
|
luz == that.luz &&
|
||||||
|
gas == that.gas &&
|
||||||
|
telefono == that.telefono &&
|
||||||
|
otroServicio == that.otroServicio &&
|
||||||
|
Double.compare(that.ppm, ppm) == 0 &&
|
||||||
|
ivaFavor == that.ivaFavor &&
|
||||||
|
Objects.equals(mes, that.mes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, mes, costoVenta, cuentaCorrienteFactura, cuentaCorrienteBoleta,
|
||||||
|
cuentaCorrienteSinRespaldo, remuneraciones, finiquitos, aguinaldo, bonosPersonal,
|
||||||
|
honorariosContador, arriendo, agua, luz, gas, telefono, otroServicio, ppm, ivaFavor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package danielcortes.xyz.models.estado_resultado;
|
package danielcortes.xyz.models.estado_resultado;
|
||||||
|
|
||||||
|
import danielcortes.xyz.data.ConnectionHolder;
|
||||||
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -16,12 +17,16 @@ import org.apache.logging.log4j.Logger;
|
|||||||
public class SQLiteEstadoResultadoDAO implements EstadoResultadoDAO {
|
public class SQLiteEstadoResultadoDAO implements EstadoResultadoDAO {
|
||||||
|
|
||||||
private static final Logger log = LogManager.getLogger(SQLiteEstadoResultadoDAO.class);
|
private static final Logger log = LogManager.getLogger(SQLiteEstadoResultadoDAO.class);
|
||||||
private SQLiteConnectionHolder connectionHolder;
|
private ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
public SQLiteEstadoResultadoDAO() {
|
public SQLiteEstadoResultadoDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteEstadoResultadoDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<EstadoResultado> getAll() {
|
public List<EstadoResultado> getAll() {
|
||||||
log.debug("Se intentara conseguir todos los EstadoResultado");
|
log.debug("Se intentara conseguir todos los EstadoResultado");
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ package danielcortes.xyz.models.ingreso;
|
|||||||
|
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.tipo_ingreso.TipoIngreso;
|
import danielcortes.xyz.models.tipo_ingreso.TipoIngreso;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Ingreso {
|
public class Ingreso {
|
||||||
|
|
||||||
@@ -115,4 +116,28 @@ public class Ingreso {
|
|||||||
", caja=" + caja +
|
", caja=" + caja +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof Ingreso)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Ingreso ingreso = (Ingreso) o;
|
||||||
|
return id == ingreso.id &&
|
||||||
|
valor == ingreso.valor &&
|
||||||
|
Objects.equals(nroZInicial, ingreso.nroZInicial) &&
|
||||||
|
Objects.equals(nroZFinal, ingreso.nroZFinal) &&
|
||||||
|
Objects.equals(nroInicial, ingreso.nroInicial) &&
|
||||||
|
Objects.equals(nroFinal, ingreso.nroFinal) &&
|
||||||
|
Objects.equals(tipoIngreso, ingreso.tipoIngreso) &&
|
||||||
|
Objects.equals(caja, ingreso.caja);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, valor, nroZInicial, nroZFinal, nroInicial, nroFinal, tipoIngreso, caja);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ public class SQLiteIngresoDAO implements IngresoDAO {
|
|||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteIngresoDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Ingreso> getAll() {
|
public List<Ingreso> getAll() {
|
||||||
log.debug("Se intententaran conseguir todos los Ingreso");
|
log.debug("Se intententaran conseguir todos los Ingreso");
|
||||||
|
|||||||
@@ -36,10 +36,6 @@ import java.util.Optional;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
|
||||||
* Objeto DAO que realiza las querys y mapeos necesarios del objeto TipoEgreso. En especifico esta
|
|
||||||
* implementacion se comunica con la base de datos SQLite
|
|
||||||
*/
|
|
||||||
public class SQLiteTipoEgresoDAO implements TipoEgresoDAO {
|
public class SQLiteTipoEgresoDAO implements TipoEgresoDAO {
|
||||||
|
|
||||||
private static final Logger log = LogManager.getLogger(SQLiteTipoEgresoDAO.class);
|
private static final Logger log = LogManager.getLogger(SQLiteTipoEgresoDAO.class);
|
||||||
@@ -49,6 +45,10 @@ public class SQLiteTipoEgresoDAO implements TipoEgresoDAO {
|
|||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteTipoEgresoDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TipoEgreso> getAll() {
|
public List<TipoEgreso> getAll() {
|
||||||
log.debug("Se intentara conseguir todos los tipoEgreso");
|
log.debug("Se intentara conseguir todos los tipoEgreso");
|
||||||
|
|||||||
@@ -48,6 +48,8 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.tipo_egreso;
|
package danielcortes.xyz.models.tipo_egreso;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class TipoEgreso {
|
public class TipoEgreso {
|
||||||
public final static TipoEgreso EMPTY;
|
public final static TipoEgreso EMPTY;
|
||||||
|
|
||||||
@@ -94,4 +96,22 @@ public class TipoEgreso {
|
|||||||
", nombre='" + nombre + '\'' +
|
", nombre='" + nombre + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof TipoEgreso)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TipoEgreso that = (TipoEgreso) o;
|
||||||
|
return id == that.id &&
|
||||||
|
Objects.equals(nombre, that.nombre);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, nombre);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ public class SQLiteTipoIngresoDAO implements TipoIngresoDAO {
|
|||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteTipoIngresoDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TipoIngreso> getAll() {
|
public List<TipoIngreso> getAll() {
|
||||||
log.debug("Se intentara conseguir todos los TipoIngreso");
|
log.debug("Se intentara conseguir todos los TipoIngreso");
|
||||||
|
|||||||
@@ -48,6 +48,8 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.tipo_ingreso;
|
package danielcortes.xyz.models.tipo_ingreso;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class TipoIngreso {
|
public class TipoIngreso {
|
||||||
public final static TipoIngreso EMPTY;
|
public final static TipoIngreso EMPTY;
|
||||||
|
|
||||||
@@ -94,4 +96,22 @@ public class TipoIngreso {
|
|||||||
", nombre='" + nombre + '\'' +
|
", nombre='" + nombre + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof TipoIngreso)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TipoIngreso that = (TipoIngreso) o;
|
||||||
|
return id == that.id &&
|
||||||
|
Objects.equals(nombre, that.nombre);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, nombre);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ public class SQLiteVersionDAO implements VersionDAO {
|
|||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQLiteVersionDAO(ConnectionHolder connectionHolder) {
|
||||||
|
this.connectionHolder = connectionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean tableVersionsExists() {
|
private boolean tableVersionsExists() {
|
||||||
try {
|
try {
|
||||||
DatabaseMetaData md = this.connectionHolder.getConnection().getMetaData();
|
DatabaseMetaData md = this.connectionHolder.getConnection().getMetaData();
|
||||||
|
|||||||
21
src/danielcortes/xyz/utils/RandomLocalDate.java
Normal file
21
src/danielcortes/xyz/utils/RandomLocalDate.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package danielcortes.xyz.utils;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
public class RandomLocalDate {
|
||||||
|
private static final LocalDate DEFAULT_FROM = LocalDate.of(1970,1,1);
|
||||||
|
private static final LocalDate DEFAULT_TO = LocalDate.of(2038,1,19);
|
||||||
|
|
||||||
|
public static LocalDate random(){
|
||||||
|
return randomBetween(DEFAULT_FROM, DEFAULT_TO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LocalDate randomBetween(LocalDate from, LocalDate to){
|
||||||
|
long min = from.toEpochDay();
|
||||||
|
long max = to.toEpochDay();
|
||||||
|
long random = ThreadLocalRandom.current().nextLong(min, max);
|
||||||
|
return LocalDate.ofEpochDay(random);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
159
test/danielcortes/xyz/models/caja/SQLiteCajaDAOTest.java
Normal file
159
test/danielcortes/xyz/models/caja/SQLiteCajaDAOTest.java
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
package danielcortes.xyz.models.caja;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import com.github.javafaker.Faker;
|
||||||
|
import danielcortes.xyz.data.ConnectionHolder;
|
||||||
|
import danielcortes.xyz.data.DAOManager;
|
||||||
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
|
import danielcortes.xyz.models.version.SQLiteVersionDAO;
|
||||||
|
import danielcortes.xyz.utils.RandomLocalDate;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class SQLiteCajaDAOTest {
|
||||||
|
|
||||||
|
static private int databaseVersion = 2;
|
||||||
|
static private SQLiteVersionDAO versionDAO;
|
||||||
|
static private ConnectionHolder connectionHolder;
|
||||||
|
static private Faker faker;
|
||||||
|
private SQLiteCajaDAO cajaDAO;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void setAll() {
|
||||||
|
connectionHolder = new SQLiteConnectionHolder("jdbc:sqlite:/tmp/tmp.sqlite");
|
||||||
|
DAOManager.setup(connectionHolder);
|
||||||
|
versionDAO = new SQLiteVersionDAO(connectionHolder);
|
||||||
|
faker = new Faker();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
versionDAO.updateTo(databaseVersion);
|
||||||
|
this.cajaDAO = new SQLiteCajaDAO(connectionHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void tearDown() {
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
new File("/tmp/tmp.sqlite").delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getAll() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
List<Caja> list = this.cajaDAO.getAll();
|
||||||
|
|
||||||
|
assertThat(list)
|
||||||
|
.hasSize(2)
|
||||||
|
.containsExactlyInAnyOrder(c1, c2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getById() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
Optional<Caja> o1 = this.cajaDAO.getById(c1.getId());
|
||||||
|
Optional<Caja> o2 = this.cajaDAO.getById(c2.getId());
|
||||||
|
|
||||||
|
assertThat(o1)
|
||||||
|
.isPresent()
|
||||||
|
.contains(c1);
|
||||||
|
|
||||||
|
assertThat(o2)
|
||||||
|
.isPresent()
|
||||||
|
.contains(c2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getByFecha() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
Optional<Caja> o1 = this.cajaDAO.getByFecha(c1.getFecha());
|
||||||
|
Optional<Caja> o2 = this.cajaDAO.getByFecha(c2.getFecha());
|
||||||
|
|
||||||
|
assertThat(o1)
|
||||||
|
.isPresent()
|
||||||
|
.contains(c1);
|
||||||
|
|
||||||
|
assertThat(o2)
|
||||||
|
.isPresent()
|
||||||
|
.contains(c2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void insert() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
assertThat(0)
|
||||||
|
.isEqualTo(c1.getId())
|
||||||
|
.isEqualTo(c2.getId());
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
assertThat(0)
|
||||||
|
.isNotEqualTo(c1.getId())
|
||||||
|
.isNotEqualTo(c2.getId());
|
||||||
|
|
||||||
|
List<Caja> l = this.cajaDAO.getAll();
|
||||||
|
assertThat(l)
|
||||||
|
.hasSize(2)
|
||||||
|
.containsExactlyInAnyOrder(c1, c2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void update() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
Caja u1 = giveRandomCaja(c1.getId());
|
||||||
|
Caja u2 = giveRandomCaja(c2.getId());
|
||||||
|
|
||||||
|
this.cajaDAO.update(c1);
|
||||||
|
this.cajaDAO.update(c2);
|
||||||
|
|
||||||
|
List<Caja> l = this.cajaDAO.getAll();
|
||||||
|
|
||||||
|
assertThat(l)
|
||||||
|
.hasSize(2)
|
||||||
|
.containsExactlyInAnyOrder(c1, c2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Caja giveRandomCaja() {
|
||||||
|
Caja caja = new Caja();
|
||||||
|
caja.setFondo(faker.number().numberBetween(0, 10000000));
|
||||||
|
caja.setFecha(RandomLocalDate.random());
|
||||||
|
return caja;
|
||||||
|
}
|
||||||
|
|
||||||
|
Caja giveRandomCaja(int id) {
|
||||||
|
Caja caja = new Caja();
|
||||||
|
caja.setId(id);
|
||||||
|
caja.setFondo(faker.number().numberBetween(0, 10000000));
|
||||||
|
caja.setFecha(RandomLocalDate.random());
|
||||||
|
return caja;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,258 @@
|
|||||||
|
package danielcortes.xyz.models.calculo_fondo;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import com.github.javafaker.Faker;
|
||||||
|
import danielcortes.xyz.data.ConnectionHolder;
|
||||||
|
import danielcortes.xyz.data.DAOManager;
|
||||||
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
import danielcortes.xyz.models.caja.CajaDAO;
|
||||||
|
import danielcortes.xyz.models.version.SQLiteVersionDAO;
|
||||||
|
import danielcortes.xyz.models.version.VersionDAO;
|
||||||
|
import danielcortes.xyz.utils.RandomLocalDate;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class SQLiteCalculoFondoDAOTest {
|
||||||
|
private static Faker faker;
|
||||||
|
private static final int databaseVersion = 2;
|
||||||
|
private static VersionDAO versionDAO;
|
||||||
|
private CalculoFondoDAO calculoFondoDAO;
|
||||||
|
private CajaDAO cajaDAO;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void setAll() {
|
||||||
|
ConnectionHolder connectionHolder = new SQLiteConnectionHolder("jdbc:sqlite:/tmp/tmp.sqlite");
|
||||||
|
DAOManager.setup(connectionHolder);
|
||||||
|
versionDAO = new SQLiteVersionDAO(connectionHolder);
|
||||||
|
faker = new Faker();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
versionDAO.updateTo(databaseVersion);
|
||||||
|
this.calculoFondoDAO = DAOManager.getCalculoFondoDAO();
|
||||||
|
this.cajaDAO = DAOManager.getCajaDAO();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void tearDown() {
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
new File("/tmp/tmp.sqlite").delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getAll() {
|
||||||
|
Caja c = giveRandomCaja();
|
||||||
|
this.cajaDAO.insert(c);
|
||||||
|
|
||||||
|
CalculoFondo f1 = giveRandomCalculoFondo(c);
|
||||||
|
CalculoFondo f2 = giveRandomCalculoFondo(c);
|
||||||
|
|
||||||
|
this.calculoFondoDAO.insert(f1);
|
||||||
|
this.calculoFondoDAO.insert(f2);
|
||||||
|
|
||||||
|
List<CalculoFondo> list = this.calculoFondoDAO.getAll();
|
||||||
|
|
||||||
|
assertThat(list)
|
||||||
|
.hasSize(2)
|
||||||
|
.contains(f1)
|
||||||
|
.contains(f2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getByCaja() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
CalculoFondo f1 = giveRandomCalculoFondo(c1);
|
||||||
|
CalculoFondo f2 = giveRandomCalculoFondo(c1);
|
||||||
|
|
||||||
|
CalculoFondo f3 = giveRandomCalculoFondo(c2);
|
||||||
|
CalculoFondo f4 = giveRandomCalculoFondo(c2);
|
||||||
|
CalculoFondo f5 = giveRandomCalculoFondo(c2);
|
||||||
|
|
||||||
|
this.calculoFondoDAO.insert(f1);
|
||||||
|
this.calculoFondoDAO.insert(f2);
|
||||||
|
this.calculoFondoDAO.insert(f3);
|
||||||
|
this.calculoFondoDAO.insert(f4);
|
||||||
|
this.calculoFondoDAO.insert(f5);
|
||||||
|
|
||||||
|
List<CalculoFondo> l1 = this.calculoFondoDAO.getByCaja(c1);
|
||||||
|
List<CalculoFondo> l2 = this.calculoFondoDAO.getByCaja(c2);
|
||||||
|
List<CalculoFondo> l3 = this.calculoFondoDAO.getByCaja(Caja.EMPTY);
|
||||||
|
|
||||||
|
assertThat(l1)
|
||||||
|
.hasSize(2)
|
||||||
|
.containsExactlyInAnyOrder(f1, f2)
|
||||||
|
.doesNotContain(f3, f4, f5);
|
||||||
|
|
||||||
|
assertThat(l2)
|
||||||
|
.hasSize(3)
|
||||||
|
.containsExactlyInAnyOrder(f3, f4, f5)
|
||||||
|
.doesNotContain(f1, f2);
|
||||||
|
|
||||||
|
assertThat(l3)
|
||||||
|
.hasSize(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getById() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
|
||||||
|
CalculoFondo f1 = giveRandomCalculoFondo(c1);
|
||||||
|
CalculoFondo f2 = giveRandomCalculoFondo(c1);
|
||||||
|
|
||||||
|
this.calculoFondoDAO.insert(f1);
|
||||||
|
this.calculoFondoDAO.insert(f2);
|
||||||
|
|
||||||
|
Optional<CalculoFondo> o1 = this.calculoFondoDAO.getById(f1.getId());
|
||||||
|
Optional<CalculoFondo> o2 = this.calculoFondoDAO.getById(f2.getId());
|
||||||
|
Optional<CalculoFondo> o3 = this.calculoFondoDAO.getById(-1);
|
||||||
|
|
||||||
|
assertThat(o1)
|
||||||
|
.isPresent()
|
||||||
|
.contains(f1);
|
||||||
|
assertThat(o2)
|
||||||
|
.isPresent()
|
||||||
|
.contains(f2);
|
||||||
|
assertThat(o3)
|
||||||
|
.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getTotalCalculoFondo() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
CalculoFondo f1 = giveRandomCalculoFondo(c1);
|
||||||
|
CalculoFondo f2 = giveRandomCalculoFondo(c1);
|
||||||
|
CalculoFondo f3 = giveRandomCalculoFondo(c2);
|
||||||
|
CalculoFondo f4 = giveRandomCalculoFondo(c2);
|
||||||
|
CalculoFondo f5 = giveRandomCalculoFondo(c2);
|
||||||
|
|
||||||
|
this.calculoFondoDAO.insert(f1);
|
||||||
|
this.calculoFondoDAO.insert(f2);
|
||||||
|
this.calculoFondoDAO.insert(f3);
|
||||||
|
this.calculoFondoDAO.insert(f4);
|
||||||
|
this.calculoFondoDAO.insert(f5);
|
||||||
|
|
||||||
|
int t1 = this.calculoFondoDAO.getTotalCalculoFondo(c1);
|
||||||
|
int t2 = this.calculoFondoDAO.getTotalCalculoFondo(c2);
|
||||||
|
|
||||||
|
assertThat(t1)
|
||||||
|
.isEqualTo(f1.getValor() + f2.getValor());
|
||||||
|
assertThat(t2)
|
||||||
|
.isEqualTo(f3.getValor() + f4.getValor() + f5.getValor());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void insert() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
|
||||||
|
CalculoFondo f1 = giveRandomCalculoFondo(c1);
|
||||||
|
CalculoFondo f2 = giveRandomCalculoFondo(c1);
|
||||||
|
|
||||||
|
assertThat(0)
|
||||||
|
.isEqualTo(f1.getId())
|
||||||
|
.isEqualTo(f2.getId());
|
||||||
|
|
||||||
|
this.calculoFondoDAO.insert(f1);
|
||||||
|
this.calculoFondoDAO.insert(f2);
|
||||||
|
|
||||||
|
assertThat(0)
|
||||||
|
.isNotEqualTo(f1.getId())
|
||||||
|
.isNotEqualTo(f2.getId());
|
||||||
|
|
||||||
|
List<CalculoFondo> l = this.calculoFondoDAO.getAll();
|
||||||
|
|
||||||
|
assertThat(l)
|
||||||
|
.hasSize(2)
|
||||||
|
.containsExactlyInAnyOrder(f1, f2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void update() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
CalculoFondo f1 = giveRandomCalculoFondo(c1);
|
||||||
|
CalculoFondo f2 = giveRandomCalculoFondo(c1);
|
||||||
|
|
||||||
|
this.calculoFondoDAO.insert(f1);
|
||||||
|
this.calculoFondoDAO.insert(f2);
|
||||||
|
|
||||||
|
f1 = giveRandomCalculoFondo(c2, f1.getId());
|
||||||
|
f2 = giveRandomCalculoFondo(c2, f2.getId());
|
||||||
|
|
||||||
|
this.calculoFondoDAO.update(f1);
|
||||||
|
this.calculoFondoDAO.update(f2);
|
||||||
|
|
||||||
|
List<CalculoFondo> l = this.calculoFondoDAO.getAll();
|
||||||
|
|
||||||
|
assertThat(l)
|
||||||
|
.hasSize(2)
|
||||||
|
.containsExactlyInAnyOrder(f1, f2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void delete() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
|
||||||
|
CalculoFondo f1 = giveRandomCalculoFondo(c1);
|
||||||
|
CalculoFondo f2 = giveRandomCalculoFondo(c1);
|
||||||
|
this.calculoFondoDAO.insert(f1);
|
||||||
|
this.calculoFondoDAO.insert(f2);
|
||||||
|
|
||||||
|
List<CalculoFondo> l1 = this.calculoFondoDAO.getAll();
|
||||||
|
|
||||||
|
assertThat(l1)
|
||||||
|
.hasSize(2);
|
||||||
|
|
||||||
|
this.calculoFondoDAO.delete(f1);
|
||||||
|
this.calculoFondoDAO.delete(f2);
|
||||||
|
|
||||||
|
List<CalculoFondo> l2 = this.calculoFondoDAO.getAll();
|
||||||
|
|
||||||
|
assertThat(l2)
|
||||||
|
.hasSize(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Caja giveRandomCaja() {
|
||||||
|
Caja caja = new Caja();
|
||||||
|
caja.setFondo(faker.number().numberBetween(0, 10000000));
|
||||||
|
caja.setFecha(RandomLocalDate.random());
|
||||||
|
return caja;
|
||||||
|
}
|
||||||
|
|
||||||
|
CalculoFondo giveRandomCalculoFondo(Caja caja) {
|
||||||
|
CalculoFondo calculoFondo = new CalculoFondo();
|
||||||
|
calculoFondo.setCaja(caja);
|
||||||
|
calculoFondo.setDescripcion(faker.lorem().characters());
|
||||||
|
calculoFondo.setValor(faker.number().numberBetween(0, 10000000));
|
||||||
|
return calculoFondo;
|
||||||
|
}
|
||||||
|
|
||||||
|
CalculoFondo giveRandomCalculoFondo(Caja caja, int id) {
|
||||||
|
CalculoFondo calculoFondo = giveRandomCalculoFondo(caja);
|
||||||
|
calculoFondo.setId(id);
|
||||||
|
return calculoFondo;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,243 @@
|
|||||||
|
package danielcortes.xyz.models.documentos;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import com.github.javafaker.Faker;
|
||||||
|
import danielcortes.xyz.data.ConnectionHolder;
|
||||||
|
import danielcortes.xyz.data.DAOManager;
|
||||||
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
import danielcortes.xyz.models.caja.CajaDAO;
|
||||||
|
import danielcortes.xyz.models.version.SQLiteVersionDAO;
|
||||||
|
import danielcortes.xyz.models.version.VersionDAO;
|
||||||
|
import danielcortes.xyz.utils.RandomLocalDate;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class SQLiteDocumentosDAOTest {
|
||||||
|
|
||||||
|
private static final int databaseVersion = 2;
|
||||||
|
private static Faker faker;
|
||||||
|
private static VersionDAO versionDAO;
|
||||||
|
private DocumentosDAO documentosDAO;
|
||||||
|
private CajaDAO cajaDAO;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void setAll() {
|
||||||
|
ConnectionHolder connectionHolder = new SQLiteConnectionHolder("jdbc:sqlite:/tmp/tmp.sqlite");
|
||||||
|
DAOManager.setup(connectionHolder);
|
||||||
|
versionDAO = new SQLiteVersionDAO(connectionHolder);
|
||||||
|
faker = new Faker();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
versionDAO.updateTo(databaseVersion);
|
||||||
|
this.documentosDAO = DAOManager.getDocumentosDAO();
|
||||||
|
this.cajaDAO = DAOManager.getCajaDAO();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void tearDown() {
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
new File("/tmp/tmp.sqlite").delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getAll() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
|
||||||
|
Documentos d1 = giveRandomDocumentos(c1);
|
||||||
|
Documentos d2 = giveRandomDocumentos(c1);
|
||||||
|
|
||||||
|
this.documentosDAO.insert(d1);
|
||||||
|
this.documentosDAO.insert(d2);
|
||||||
|
|
||||||
|
List<Documentos> l = this.documentosDAO.getAll();
|
||||||
|
|
||||||
|
assertThat(l)
|
||||||
|
.hasSize(2)
|
||||||
|
.containsExactlyInAnyOrder(d1, d2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getById() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
|
||||||
|
Documentos d1 = giveRandomDocumentos(c1);
|
||||||
|
Documentos d2 = giveRandomDocumentos(c1);
|
||||||
|
|
||||||
|
this.documentosDAO.insert(d1);
|
||||||
|
this.documentosDAO.insert(d2);
|
||||||
|
|
||||||
|
Optional<Documentos> o1 = this.documentosDAO.getById(d1.getId());
|
||||||
|
Optional<Documentos> o2 = this.documentosDAO.getById(d2.getId());
|
||||||
|
Optional<Documentos> o3 = this.documentosDAO.getById(-1);
|
||||||
|
|
||||||
|
assertThat(o1)
|
||||||
|
.isPresent()
|
||||||
|
.contains(d1);
|
||||||
|
|
||||||
|
assertThat(o2)
|
||||||
|
.isPresent()
|
||||||
|
.contains(d2);
|
||||||
|
|
||||||
|
assertThat(o3)
|
||||||
|
.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getByCaja() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
Documentos d1 = giveRandomDocumentos(c1);
|
||||||
|
Documentos d2 = giveRandomDocumentos(c2);
|
||||||
|
|
||||||
|
this.documentosDAO.insert(d1);
|
||||||
|
this.documentosDAO.insert(d2);
|
||||||
|
|
||||||
|
Optional<Documentos> o1 = this.documentosDAO.getByCaja(c1);
|
||||||
|
Optional<Documentos> o2 = this.documentosDAO.getByCaja(c2);
|
||||||
|
Optional<Documentos> o3 = this.documentosDAO.getByCaja(Caja.EMPTY);
|
||||||
|
|
||||||
|
assertThat(o1)
|
||||||
|
.isPresent()
|
||||||
|
.contains(d1);
|
||||||
|
|
||||||
|
assertThat(o2)
|
||||||
|
.isPresent()
|
||||||
|
.contains(d2);
|
||||||
|
|
||||||
|
assertThat(o3)
|
||||||
|
.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getTotalDocumentos() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
Documentos d1 = giveRandomDocumentos(c1);
|
||||||
|
Documentos d2 = giveRandomDocumentos(c2);
|
||||||
|
|
||||||
|
this.documentosDAO.insert(d1);
|
||||||
|
this.documentosDAO.insert(d2);
|
||||||
|
|
||||||
|
int t1 = this.documentosDAO.getTotalDocumentos(c1);
|
||||||
|
int t2 = this.documentosDAO.getTotalDocumentos(c2);
|
||||||
|
|
||||||
|
assertThat(t1)
|
||||||
|
.isEqualTo(d1.getCheques() + d1.getRetiros() + d1.getTarjetas());
|
||||||
|
|
||||||
|
assertThat(t2)
|
||||||
|
.isEqualTo(d2.getCheques() + d2.getRetiros() + d2.getTarjetas());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void insert() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
|
||||||
|
Documentos d1 = giveRandomDocumentos(c1);
|
||||||
|
|
||||||
|
assertThat(d1.getId())
|
||||||
|
.isEqualTo(0);
|
||||||
|
|
||||||
|
this.documentosDAO.insert(d1);
|
||||||
|
|
||||||
|
assertThat(d1.getId())
|
||||||
|
.isNotEqualTo(0);
|
||||||
|
|
||||||
|
List<Documentos> l = this.documentosDAO.getAll();
|
||||||
|
|
||||||
|
assertThat(l)
|
||||||
|
.hasSize(1)
|
||||||
|
.containsExactlyInAnyOrder(d1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void update() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
Caja c2 = giveRandomCaja();
|
||||||
|
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
this.cajaDAO.insert(c2);
|
||||||
|
|
||||||
|
Documentos d1 = giveRandomDocumentos(c1);
|
||||||
|
|
||||||
|
this.documentosDAO.insert(d1);
|
||||||
|
|
||||||
|
Documentos d2 = updateRandomDocumentos(d1);
|
||||||
|
|
||||||
|
this.documentosDAO.update(d2);
|
||||||
|
|
||||||
|
assertThat(d1.getId()).isEqualTo(d2.getId());
|
||||||
|
|
||||||
|
Optional<Documentos> o = this.documentosDAO.getById(d2.getId());
|
||||||
|
|
||||||
|
assertThat(o)
|
||||||
|
.isPresent()
|
||||||
|
.contains(d2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void delete() {
|
||||||
|
Caja c1 = giveRandomCaja();
|
||||||
|
this.cajaDAO.insert(c1);
|
||||||
|
|
||||||
|
Documentos d1 =giveRandomDocumentos(c1);
|
||||||
|
this.documentosDAO.insert(d1);
|
||||||
|
|
||||||
|
assertThat(this.documentosDAO.getById(d1.getId()))
|
||||||
|
.isPresent()
|
||||||
|
.contains(d1);
|
||||||
|
|
||||||
|
this.documentosDAO.delete(d1);
|
||||||
|
assertThat(this.documentosDAO.getById(d1.getId()))
|
||||||
|
.isEmpty();
|
||||||
|
|
||||||
|
assertThat(this.cajaDAO.getById(c1.getId()))
|
||||||
|
.isPresent()
|
||||||
|
.contains(c1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Caja giveRandomCaja() {
|
||||||
|
Caja caja = new Caja();
|
||||||
|
caja.setFondo(faker.number().numberBetween(0, 10000000));
|
||||||
|
caja.setFecha(RandomLocalDate.random());
|
||||||
|
return caja;
|
||||||
|
}
|
||||||
|
|
||||||
|
Documentos giveRandomDocumentos(Caja caja) {
|
||||||
|
Documentos d = new Documentos();
|
||||||
|
d.setCaja(caja);
|
||||||
|
d.setRetiros(faker.number().numberBetween(0, 10000000));
|
||||||
|
d.setCheques(faker.number().numberBetween(0, 10000000));
|
||||||
|
d.setTarjetas(faker.number().numberBetween(0, 10000000));
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
Documentos updateRandomDocumentos(Documentos documentos) {
|
||||||
|
Documentos d = giveRandomDocumentos(documentos.getCaja());
|
||||||
|
d.setId(documentos.getId());
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,15 +24,13 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.utils;
|
package danielcortes.xyz.utils;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestInstance;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
|
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||||
class NaturalOrderComparatorTest {
|
class NaturalOrderComparatorTest {
|
||||||
@@ -77,14 +75,13 @@ class NaturalOrderComparatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testIfArraySortIsCorrect(){
|
void testIfArraySortIsCorrect(){
|
||||||
assertNotEquals(toCompare, original);
|
|
||||||
|
|
||||||
NaturalOrderComparator comparator = new NaturalOrderComparator();
|
NaturalOrderComparator comparator = new NaturalOrderComparator();
|
||||||
toCompare.sort(comparator);
|
toCompare.sort(comparator);
|
||||||
|
|
||||||
assertEquals(toCompare, natural);
|
assertThat(toCompare)
|
||||||
assertNotEquals(toCompare, lexicographic);
|
.containsSequence(natural)
|
||||||
assertNotEquals(toCompare, original);
|
.doesNotContainSequence(lexicographic)
|
||||||
|
.doesNotContainSequence(original);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,17 +24,15 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.utils;
|
package danielcortes.xyz.utils;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
class StringUtilsTest {
|
class StringUtilsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testIfUpercasedCorrectly() {
|
void testIfUpercasedCorrectly() {
|
||||||
assertEquals("Barycentric", StringUtils.capitalize("barycentric"));
|
assertThat("Barycentric").isEqualTo(StringUtils.capitalize("barycentric"));
|
||||||
assertEquals("Showcased", StringUtils.capitalize("showcased"));
|
assertThat("Showcased").isEqualTo(StringUtils.capitalize("showcased"));
|
||||||
assertEquals("Failures", StringUtils.capitalize("failures"));
|
assertThat("Failures").isEqualTo(StringUtils.capitalize("failures"));
|
||||||
assertEquals("Scroogie", StringUtils.capitalize("scroogie"));
|
assertThat("Scroogie").isEqualTo(StringUtils.capitalize("scroogie"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user