Skip to content

Commit

Permalink
test: added positive test for the constructor in OrganizationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil-F committed Mar 1, 2026
1 parent 77afc5c commit 0523bce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,82 +5,90 @@
import static org.junit.jupiter.api.Assertions.*;

class OrganizationTest {


@Test
void constructor_CreatesAnOrganizationWhenInputIsValid() {
Organization org = new Organization(
1,
"Org",
true,
"org.com",
true,
"Org description"
);

assertEquals(1, org.orgNumber());
}

@Test
void constructor_ThrowsWhenOrgNumberIsNegative() {
assertThrows(IllegalArgumentException.class, () -> {new Organization(
assertThrows(IllegalArgumentException.class, () -> new Organization(
-1,
"Org",
true,
null,
true,
"Org description"
);
});
));
}

@Test
void constructor_ThrowsWhenNameIsNull() {
assertThrows(NullPointerException.class, () -> {new Organization(
assertThrows(NullPointerException.class, () -> new Organization(
1,
null,
true,
"org.com",
true,
"Org description"
);
});
));
}

@Test
void constructor_ThrowsWhenNameIsBlank() {
assertThrows(IllegalArgumentException.class, () -> {new Organization(
assertThrows(IllegalArgumentException.class, () -> new Organization(
1,
"",
true,
"org.com",
true,
"Org description"
);
});
));
}

@Test
void constructor_ThrowsWhenWebsiteURLIsNull() {
assertThrows(NullPointerException.class, () -> {new Organization(
assertThrows(NullPointerException.class, () -> new Organization(
1,
"Org",
true,
null,
true,
"Org description"
);
});
));
}

@Test
void constructor_ThrowsWhenWebsiteURLIsBlank() {
assertThrows(IllegalArgumentException.class, () -> {new Organization(
assertThrows(IllegalArgumentException.class, () -> new Organization(
1,
"Org",
true,
"",
true,
"Org description"
);
});
));
}

@Test
void constructor_ThrowsWhenDescriptionIsNull() {
assertThrows(NullPointerException.class, () -> {new Organization(
assertThrows(NullPointerException.class, () -> new Organization(
1,
"Org",
true,
"org.com",
true,
null
);
});
));
}
}

0 comments on commit 0523bce

Please sign in to comment.