diff --git a/src/main/java/edu/group5/app/model/organization/Organization.java b/src/main/java/edu/group5/app/model/organization/Organization.java
index abb2f71..885f0ed 100644
--- a/src/main/java/edu/group5/app/model/organization/Organization.java
+++ b/src/main/java/edu/group5/app/model/organization/Organization.java
@@ -2,44 +2,49 @@
import java.util.Objects;
-public class Organization {
- private final int orgNumber;
- private final String name;
- private final boolean trusted;
- private final String websiteURL;
- private final boolean isPreApproved;
- private final String description;
-
+/**
+ * Represents an organization.
+ *
+ *
An organization is identified by an organization number, a name,
+ * trust status, website URL, pre-approval status, and a textual description.
+ *
+ *
Instances are validated on creation:
+ *
+ * - orgNumber must be non-negative
+ * - name and websiteURL must not be null or blank
+ * - description must not be null
+ *
+ */
+public record Organization(int orgNumber, String name, boolean trusted, String websiteURL, boolean isPreApproved,
+ String description) {
+ /**
+ * Creates a new organization.
+ *
+ * @param orgNumber the organization number; must be non-negative
+ * @param name the organization name; must not be null or blank
+ * @param trusted whether the organization is trusted
+ * @param websiteURL the organization's website URL; must not be null or blank
+ * @param isPreApproved whether the organization is pre-approved
+ * @param description a textual description of the organization; must not be null
+ * @throws NullPointerException if name, websiteURL or description is null
+ * @throws IllegalArgumentException if orgNumber is negative, or if name or websiteURL is blank
+ */
public Organization(int orgNumber, String name, boolean trusted, String websiteURL, boolean isPreApproved, String description) {
+ if (orgNumber < 0) {
+ throw new IllegalArgumentException("orgNumber cannot be negative");
+ }
this.orgNumber = orgNumber;
this.name = Objects.requireNonNull(name, "name cannot be null");
this.trusted = trusted;
this.websiteURL = Objects.requireNonNull(websiteURL, "websiteURL cannot be null");
this.isPreApproved = isPreApproved;
this.description = Objects.requireNonNull(description, "description cannot be null");
- }
-
- public int getOrgNumber() {
- return orgNumber;
- }
-
- public String getName() {
- return name;
- }
-
- public boolean isTrusted() {
- return trusted;
- }
-
- public String getWebsiteURL() {
- return websiteURL;
- }
-
- public boolean isPreApproved() {
- return isPreApproved;
- }
- public String getDescription() {
- return description;
+ if (name.isBlank()) {
+ throw new IllegalArgumentException("name cannot be blank");
+ }
+ if (websiteURL.isBlank()) {
+ throw new IllegalArgumentException("websiteURL cannot be blank");
+ }
}
}
diff --git a/src/test/java/edu/group5/app/model/organization/OrganizationTest.java b/src/test/java/edu/group5/app/model/organization/OrganizationTest.java
new file mode 100644
index 0000000..557c0c0
--- /dev/null
+++ b/src/test/java/edu/group5/app/model/organization/OrganizationTest.java
@@ -0,0 +1,4 @@
+import static org.junit.jupiter.api.Assertions.*;
+class OrganizationTest {
+
+}
\ No newline at end of file