Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AddressPartTest.java #793

Merged
merged 8 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
35 changes: 35 additions & 0 deletions src/test/java/org/openelisglobal/address/AddressPartTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.openelisglobal.address;

import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.openelisglobal.address.valueholder.AddressPart;

public class AddressPartTest {

private AddressPart addressPart;

@Before
public void setUp() {
addressPart = new AddressPart();
}

@Test
public void testSetAndGetId() {
sayed4900 marked this conversation as resolved.
Show resolved Hide resolved
addressPart.setId("123");
assertEquals("123", addressPart.getId());
}

@Test
public void testSetAndGetPartName() {
addressPart.setPartName("Street");
assertEquals("Street", addressPart.getPartName());
}

@Test
public void testSetAndGetDisplayOrder() {
addressPart.setDisplayOrder("1");
assertEquals("1", addressPart.getDisplayOrder());
}
}

49 changes: 49 additions & 0 deletions src/test/java/org/openelisglobal/address/AdressPKTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.openelisglobal.address;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openelisglobal.address.valueholder.AddressPK;

public class AdressPKTest {

private AddressPK addressPK;

@Before
public void setUp() {
addressPK = new AddressPK();
}

@Test
public void testSetAndGetTargetId() {
addressPK.setTargetId("123");
Assert.assertEquals("123", addressPK.getTargetId());
}

@Test
public void testSetAndGetAddressPartId() {
addressPK.setAddressPartId("456");
Assert.assertEquals("456", addressPK.getAddressPartId());
}

@Test
public void testEqualsAndHashCode() {
AddressPK addressPK1 = new AddressPK();
addressPK1.setTargetId("123");
addressPK1.setAddressPartId("456");

AddressPK addressPK2 = new AddressPK();
addressPK2.setTargetId("123");
addressPK2.setAddressPartId("456");

AddressPK addressPK3 = new AddressPK();
addressPK3.setTargetId("789");
addressPK3.setAddressPartId("101");

Assert.assertEquals(addressPK1, addressPK2);
Assert.assertNotEquals(addressPK1, addressPK3);
Assert.assertEquals(addressPK1.hashCode(), addressPK2.hashCode());
Assert.assertNotEquals(addressPK1.hashCode(), addressPK3.hashCode());
}

}
109 changes: 109 additions & 0 deletions src/test/java/org/openelisglobal/address/IntegrationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package org.openelisglobal.address;

import org.junit.Before;
import org.junit.Test;
import org.openelisglobal.address.valueholder.AddressPK;
import org.openelisglobal.address.valueholder.AddressPart;
import org.openelisglobal.address.valueholder.OrganizationAddress;
import org.openelisglobal.address.valueholder.PersonAddress;
import org.openelisglobal.organization.valueholder.Organization;
import org.openelisglobal.person.valueholder.Person;



import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class IntegrationTest {

private AddressPart addressPart;
private OrganizationAddress organizationAddress;
private AddressPK addressPK;
private PersonAddress personAddress;
private Organization organization;
private Person person; // Add Person object

@Before
public void setUp() {
addressPart = new AddressPart();
organizationAddress = new OrganizationAddress();
addressPK = new AddressPK();
personAddress = new PersonAddress();
organization = new Organization();
person = new Person();
}


@Test
public void testIntegration() {
// Simulate interactions between the classes
addressPart.setPartName("StreetX");
organizationAddress.setType("Office");
addressPK.setTargetId("456");
addressPK.setAddressPartId("Eg");

// Set up person object
person.setId("789");
person.setFirstName("John");
person.setLastName("Doe");

organizationAddress.setCompoundId(addressPK);
personAddress.setCompoundId(addressPK);

// Verify that the integrated behavior meets the expected outcomes
assertEquals("StreetX", addressPart.getPartName());

assertEquals("Office", organizationAddress.getType());
assertEquals("456Eg", organizationAddress.getStringId());
assertEquals(addressPK, organizationAddress.getCompoundId());

assertEquals("456", personAddress.getPersonId());
assertEquals("Eg", personAddress.getAddressPartId());

// Verify person object properties
assertEquals("789", person.getId());
assertEquals("John", person.getFirstName());
assertEquals("Doe", person.getLastName());
}

@Test
public void testOrganizationAddressIntegration() {
// Set up organization and address part
organization.setId("org123");
addressPart.setId("address123");

// Set organization ID and address part ID in organization address
organizationAddress.setOrganizationId(organization.getId());
organizationAddress.setAddressPartId(addressPart.getId());

// Verify that organization address holds correct IDs
assertEquals("org123", organizationAddress.getOrganizationId());
assertEquals("address123", organizationAddress.getAddressPartId());
}

@Test
public void testAddressPartNotNull() {
assertNotNull(addressPart);
}

@Test
public void testOrganizationAddressNotNull() {
assertNotNull(organizationAddress);
}

@Test
public void testAddressPKNotNull() {
assertNotNull(addressPK);
}

@Test
public void testPersonAddressNotNull() {
assertNotNull(personAddress);
}

@Test
public void testPersonNotNull() {
assertNotNull(person);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.openelisglobal.address;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openelisglobal.address.valueholder.OrganizationAddress;

public class OrganizationAddressTest {

private OrganizationAddress organizationAddress;

@Before
public void setUp() {
organizationAddress = new OrganizationAddress();
}

@Test
sayed4900 marked this conversation as resolved.
Show resolved Hide resolved
public void testSetAndGetOrganizationId() {
organizationAddress.setOrganizationId("123");
Assert.assertEquals("123", organizationAddress.getOrganizationId());
}

@Test
sayed4900 marked this conversation as resolved.
Show resolved Hide resolved
public void testSetAndGetAddressPartId() {
organizationAddress.setAddressPartId("456");
Assert.assertEquals("456", organizationAddress.getAddressPartId());
}

@Test
public void testSetAndGetUniqueIdentifier() {
organizationAddress.setUniqueIdentifyer("unique123");
Assert.assertEquals("unique123", organizationAddress.getUniqueIdentifyer());
}

@Test
sayed4900 marked this conversation as resolved.
Show resolved Hide resolved
public void testGetStringId() {
String organizationId = "123";
sayed4900 marked this conversation as resolved.
Show resolved Hide resolved
String addressPartId = "456";
organizationAddress.setOrganizationId("123");
organizationAddress.setAddressPartId("456");
Assert.assertEquals("123456", organizationAddress.getStringId());
}


}
46 changes: 46 additions & 0 deletions src/test/java/org/openelisglobal/address/PersonAddressTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.openelisglobal.address;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openelisglobal.address.valueholder.PersonAddress;

sayed4900 marked this conversation as resolved.
Show resolved Hide resolved
public class PersonAddressTest {

private PersonAddress personAddress;

@Before
public void setUp() {
personAddress = new PersonAddress();
}

@Test
public void testSetAndGetPersonId() {
personAddress.setPersonId("123");
sayed4900 marked this conversation as resolved.
Show resolved Hide resolved
Assert.assertEquals("123", personAddress.getPersonId());
}

@Test
public void testSetAndGetAddressPartId() {
personAddress.setAddressPartId("456");
Assert.assertEquals("456", personAddress.getAddressPartId());
}

@Test
public void testSetAndGetUniqueIdentifier() {
personAddress.setUniqueIdentifyer("unique123");
sayed4900 marked this conversation as resolved.
Show resolved Hide resolved
Assert.assertEquals("unique123", personAddress.getUniqueIdentifyer());
}

@Test
public void testGetStringId() {
personAddress.setPersonId("123");
personAddress.setAddressPartId("456");
Assert.assertEquals("123456", personAddress.getStringId());
}

// Add more test cases for other methods as needed
}
Loading