Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.umutayb</groupId>
<artifactId>Utilities</artifactId>
<version>1.6.8</version>
<version>1.6.8-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Java-Utilities</name>
Expand Down Expand Up @@ -58,7 +58,6 @@
<maven.compiler.target>1.8</maven.compiler.target>
<cucumber.version>4.8.0</cucumber.version>
<retrofit.version>2.9.0</retrofit.version>
<lombok.version>1.18.26</lombok.version>
<okhttp.version>4.9.3</okhttp.version>
<java.version>17</java.version>
</properties>
Expand Down Expand Up @@ -140,14 +139,6 @@
<version>${retrofit.version}</version>
</dependency>

<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>

<!-- Apache -->
<dependency>
<groupId>org.apache.poi</groupId>
Expand Down
69 changes: 55 additions & 14 deletions src/main/java/utils/email/EmailUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMessage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import utils.DateUtilities;
import utils.Printer;
import utils.reflection.ReflectionUtilities;
Expand All @@ -19,7 +15,7 @@

import static utils.arrays.lambda.Collectors.toSingleton;

@SuppressWarnings("unused")
@SuppressWarnings({"unused", "UnusedReturnValue"})
public class EmailUtilities {

/**
Expand Down Expand Up @@ -115,8 +111,11 @@ public static class Inbox {
* List of email messages represented as a list of maps where each map contains email fields as keys
* and their corresponding values as values.
*/
@Getter
public List<EmailMessage> messages = new ArrayList<>();
public static List<EmailMessage> messages = new ArrayList<>();

public List<EmailMessage> getMessages() {
return messages;
}

/**
* Enumeration of email fields used as keys in the map representation of email messages.
Expand All @@ -126,11 +125,53 @@ public enum EmailField {SUBJECT, SENDER, CONTENT, @Deprecated(since = "1.6.2", f
/**
* This class represents an email message.
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class EmailMessage {
String from;

public String getSentDate() {
return sentDate;
}

public void setSentDate(String sentDate) {
this.sentDate = sentDate;
}

public String getSubject() {
return subject;
}

public void setSubject(String subject) {
this.subject = subject;
}

public String getMessageContent() {
return messageContent;
}

public void setMessageContent(String messageContent) {
this.messageContent = messageContent;
}

public String getAttachments() {
return attachments;
}

public void setAttachments(String attachments) {
this.attachments = attachments;
}

public String getFileName() {
return fileName;
}

public String getFrom() {
return from;
}

public void setFrom(String from) {
this.from = from;
}

String sentDate;
String subject;
String messageContent;
Expand Down Expand Up @@ -175,7 +216,7 @@ public void setFileName(String fileName){
* @return the email message matching the filter criteria
*/
public EmailMessage getMessageBy(List<Pair<EmailField, String>> filterPairs) {
return this.messages.stream()
return messages.stream()
.filter(message -> emailMatch(message, filterPairs))
.collect(toSingleton());
}
Expand Down Expand Up @@ -281,7 +322,7 @@ public static void load(Inbox inbox, int timeout, int expectedMessageCount, bool
timeout,
() -> {
inbox.load(print, save, saveAttachments, filterPairs);
return inbox.messages.size() >= expectedMessageCount;
return messages.size() >= expectedMessageCount;
}
);
}
Expand Down Expand Up @@ -342,7 +383,7 @@ public void load(boolean print, boolean save, boolean saveAttachments, List<Pair
if (emailMatch(EmailMessage.from(message), filterPairs))
resolveMessage(message, messages.indexOf(message), print, save, saveAttachments);
}
log.info("You have " + this.messages.size() + " new mails in your inbox");
log.info("You have " + Inbox.messages.size() + " new mails in your inbox");
// disconnect
folderInbox.close(false);
store.close();
Expand Down Expand Up @@ -402,7 +443,7 @@ private void resolveMessage(Message message, Integer index, Boolean print, Boole
emailMessage = EmailMessage.from(message);
emailMessage.setFileName(String.format("message#%s", DateUtilities.getDate().getTimeInMillis()));

this.messages.add(emailMessage);
messages.add(emailMessage);

if (print) {
log.info("Message #" + index);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ public void getSimpleDateStringFromTest() {
String simpleDateFormatString = DateUtilities.getSimpleDateStringFrom(offsetDateTimeString, dateFormat);
Assert.assertEquals(
"Date string does not match the expected value!",
simpleDateFormatString,
"2024-01-25"
"2024-01-25",
simpleDateFormatString
);
printer.success("The getSimpleDateFormatStringFromTest() test passed!");
}
Expand Down
78 changes: 68 additions & 10 deletions src/test/java/petstore/models/Pet.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
package petstore.models;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class Pet {
Long id;
DataModel category;
Expand All @@ -25,12 +18,77 @@ public Pet(DataModel category, String name, List<String> photoUrls, List<DataMod
this.status = status;
}

@Data
@AllArgsConstructor
@NoArgsConstructor
public Pet() {
}

public Pet(Long id, DataModel category, String name, List<String> photoUrls, List<DataModel> tags, String status) {
this.id = id;
this.category = category;
this.name = name;
this.photoUrls = photoUrls;
this.tags = tags;
this.status = status;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public DataModel getCategory() {
return category;
}

public void setCategory(DataModel category) {
this.category = category;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public List<String> getPhotoUrls() {
return photoUrls;
}

public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}

public List<DataModel> getTags() {
return tags;
}

public void setTags(List<DataModel> tags) {
this.tags = tags;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public static class DataModel {
Long id;
String name;

public DataModel(Long id, String name) {
this.id = id;
this.name = name;
}

public DataModel() {
}
}
}