Skip to content

Commit

Permalink
Tests unitarios para utils y eliminación de los test del ejb
Browse files Browse the repository at this point in the history
  • Loading branch information
yazmin48 committed Jan 7, 2025
1 parent d390239 commit 6bf8bd4
Show file tree
Hide file tree
Showing 15 changed files with 874 additions and 1,128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ public ElectionsManagerEJBBean() {
// Default initialization
}

public void setEm(EntityManager em) {
this.em = em;
}

/**
* Logs an user to the application and persists audit information in the activity table
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static List<UserVoter> processCensusExcel(String contentType, byte[] cens
}
}

private static Workbook getWorkbook(String contentType, FileInputStream fis) throws IOException, CensusValidationException {
public static Workbook getWorkbook(String contentType, FileInputStream fis) throws IOException, CensusValidationException {
switch (contentType) {
case CONTENT_TYPE_XLS:
return new HSSFWorkbook(fis);
Expand Down Expand Up @@ -161,21 +161,21 @@ private static String getOptionalCellValue(Row row, int columnIndex) {
return (cell != null) ? cell.getStringCellValue() : null;
}

private static String validateLanguage(String language, int rowIndex) throws CensusValidationException {
public static String validateLanguage(String language, int rowIndex) throws CensusValidationException {
if (!language.matches("SP|EN|PT")) {
throw new CensusValidationException("censusManagementUploadWrongLanguage", rowIndex, language);
}
return language;
}

private static String validateEmail(String email, int rowIndex) throws CensusValidationException {
public static String validateEmail(String email, int rowIndex) throws CensusValidationException {
if (!email.contains("@") || !email.contains(".")) {
throw new CensusValidationException("censusManagementUploadWrongEmail", rowIndex, email);
}
return email;
}

private static int validateVoteAmount(Cell cell, int rowIndex) throws CensusValidationException {
public static int validateVoteAmount(Cell cell, int rowIndex) throws CensusValidationException {
try {
int votes = (int) cell.getNumericCellValue();
if (votes <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ public static boolean sendMail(Session session, String fromString, String to, St
}
}

private static String getHeaderMailer(String subject) {
public static String getHeaderMailer(String subject) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
return StringUtils.md5(subject.concat(sdf.format(new Date())));
}

private static Address getEmailAddress(String fromString) throws MessagingException, UnsupportedEncodingException {
public static Address getEmailAddress(String fromString) throws MessagingException, UnsupportedEncodingException {
String[] from = fromString.split(",");
if (from.length == 2)
return new InternetAddress(from[0], from[1]);
Expand Down
Loading

0 comments on commit 6bf8bd4

Please sign in to comment.