Skip to content

Commit

Permalink
feat: Issuer Tests
Browse files Browse the repository at this point in the history
* Written tests to test functionality of Issuer implementations

Refs: #3
  • Loading branch information
Muratcan Şentürk committed Mar 21, 2023
1 parent b213b0f commit 81feb97
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/test/java/org/snturk/petition/IssuerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.snturk.petition;


import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.snturk.petition.exceptions.InvalidIssuerException;
import org.snturk.petition.model.Issuer;
import org.snturk.petition.model.Organization;
import org.snturk.petition.model.Person;

import static org.junit.jupiter.api.Assertions.*;

public class IssuerTest {


@Test @DisplayName("Should create person") void shouldCreatePerson() {
Issuer issuerPerson = new Person("Muratcan", "Şentürk");
assertEquals("Muratcan Şentürk", issuerPerson.getCompleteName());

Issuer issuerPerson2 = new Person("Muratcan", "Example", "Şentürk");
assertEquals("Muratcan Example Şentürk", issuerPerson2.getCompleteName());

assertThrows(InvalidIssuerException.class, () -> new Person(null, "Şentürk"));
assertThrows(InvalidIssuerException.class, () -> new Person("Muratcan", null));
assertThrows(InvalidIssuerException.class, () -> new Person("Muratcan", "Example", null));
assertThrows(InvalidIssuerException.class, () -> new Person("Muratcan", null, "Şentürk"));
assertThrows(InvalidIssuerException.class, () -> new Person(null, "Example", "Şentürk"));
assertThrows(InvalidIssuerException.class, () -> new Person("", "Şentürk"));
assertThrows(InvalidIssuerException.class, () -> new Person("Muratcan", ""));
assertThrows(InvalidIssuerException.class, () -> new Person("Muratcan", "Example", ""));
assertThrows(InvalidIssuerException.class, () -> new Person("Muratcan", "", "Şentürk"));
assertThrows(InvalidIssuerException.class, () -> new Person("", "Example", "Şentürk"));
}


@Test @DisplayName("Should create organization") void shouldCreateOrganization() {
Issuer issuerOrganization = new Organization("Example");
assertEquals("Example", issuerOrganization.getCompleteName());

Issuer issuerOrganization2 = new Organization("Example", "Ltd.");
assertEquals("Example (Ltd.)", issuerOrganization2.getCompleteName());

assertThrows(InvalidIssuerException.class, () -> new Organization(null));
assertThrows(InvalidIssuerException.class, () -> new Organization(""));
assertThrows(InvalidIssuerException.class, () -> new Organization("Example", null));
assertThrows(InvalidIssuerException.class, () -> new Organization("Example", ""));
}


@Test @DisplayName("Should create issuer") void shouldCreateIssuer() {
Issuer issuerPerson = new Person("Muratcan", "Şentürk");
assertEquals("Muratcan Şentürk", issuerPerson.getCompleteName());

Issuer issuerOrganization = new Organization("Example");
assertEquals("Example", issuerOrganization.getCompleteName());
}
}

0 comments on commit 81feb97

Please sign in to comment.