<commit_before>package com.iappsam.managers.sessions;

import static org.junit.Assert.*;

import org.junit.Test;

import com.iappsam.entities.DivisionOffice;
import com.iappsam.entities.Employee;
import com.iappsam.entities.Person;
import com.iappsam.managers.DivisionOfficeManager;
import com.iappsam.managers.PersonManager;
import com.iappsam.managers.exceptions.DuplicateEntryException;
import com.iappsam.managers.exceptions.TransactionException;

public class PersonManagerSessionTest {

	@Test
	public void addThenRemovePerson() throws TransactionException, DuplicateEntryException {
		PersonManager pm = new PersonManagerSession();

		Person p = new Person("John");

		pm.addPerson(p);
		assertTrue(pm.containsPerson(p));

		pm.removePerson(p);
		assertFalse(pm.containsPerson(p));
	}

	@Test
	public void addThenRemoveEmployee() throws TransactionException, DuplicateEntryException {
		PersonManager pm = new PersonManagerSession();

		Person p = new Person("John");

		pm.addPerson(p);
		assertTrue(pm.containsPerson(p));

		Employee e = new Employee("Designation", p);

		pm.addEmployee(e);
		assertTrue(pm.containsEmployee(e));
		assertEquals(p, e.getPerson());

		pm.removeEmployee(e);
		assertFalse(pm.containsEmployee(e));

		pm.removePerson(p);
		assertFalse(pm.containsPerson(p));
	}

	@Test
	public void addThenRemoveEmployeeWithDivision() throws TransactionException, DuplicateEntryException {

		PersonManager pm = new PersonManagerSession();

		Person p = new Person("John");

		pm.addPerson(p);
		assertTrue(pm.containsPerson(p));

		DivisionOffice office = new DivisionOffice("Division", "Office");
		DivisionOfficeManager dom = new DivisionOfficeManagerSession();

		dom.addDivisionOffice(office);
		assertTrue(dom.containsDivisionOffice(office));

		Employee e = new Employee("Designation", p);
		e.setDivisionOffice(office);

		pm.addEmployee(e);

		assertTrue(pm.containsEmployee(e));
		assertEquals(p, e.getPerson());
		assertEquals(office, e.getDivisionOffice());

		pm.removeEmployee(e);
		assertFalse(pm.containsEmployee(e));

		dom.removeDivisionOffice(office);
		assertFalse(dom.containsDivisionOffice(office));

		pm.removePerson(p);
		assertFalse(pm.containsPerson(p));

	}<commit_msg>Updated tests for PersonManagerSession.<commit_after>package com.iappsam.managers.sessions;

import static org.junit.Assert.*;

import org.junit.Test;

import com.iappsam.entities.DivisionOffice;
import com.iappsam.entities.Employee;
import com.iappsam.entities.Person;
import com.iappsam.managers.DivisionOfficeManager;
import com.iappsam.managers.PersonManager;
import com.iappsam.managers.exceptions.DuplicateEntryException;
import com.iappsam.managers.exceptions.TransactionException;

public class PersonManagerSessionTest {

	@Test
	public void addThenRemovePerson() throws TransactionException, DuplicateEntryException {
		PersonManager pm = new PersonManagerSession();

		Person p = new Person("John");

		pm.addPerson(p);
		assertTrue(pm.containsPerson(p));

		pm.removePerson(p);
		assertFalse(pm.containsPerson(p));
	}

	@Test
	public void addThenRemoveEmployee() throws TransactionException, DuplicateEntryException {
		PersonManager pm = new PersonManagerSession();

		Person p = new Person("John");

		pm.addPerson(p);
		assertTrue(pm.containsPerson(p));

		Employee e = new Employee("Designation", p);

		pm.addEmployee(e);

		Employee employeeFromDb = pm.getEmployee(e.getId());

		assertEquals(e, employeeFromDb);
		assertEquals(p, employeeFromDb.getPerson());

		pm.removeEmployee(e);
		assertFalse(pm.containsEmployee(e));

		pm.removePerson(p);
		assertFalse(pm.containsPerson(p));
	}

	@Test
	public void addThenRemoveEmployeeWithDivision() throws TransactionException, DuplicateEntryException {

		PersonManager pm = new PersonManagerSession();

		Person p = new Person("John");

		pm.addPerson(p);
		assertTrue(pm.containsPerson(p));

		DivisionOffice office = new DivisionOffice("Division", "Office");
		DivisionOfficeManager dom = new DivisionOfficeManagerSession();

		dom.addDivisionOffice(office);
		assertTrue(dom.containsDivisionOffice(office));

		Employee e = new Employee("Designation", p);
		e.setDivisionOffice(office);

		pm.addEmployee(e);

		Employee employeeFromDb = pm.getEmployee(e.getId());

		assertEquals(e, employeeFromDb);
		assertEquals(p, employeeFromDb.getPerson());
		assertEquals(office, employeeFromDb.getDivisionOffice());

		pm.removeEmployee(e);
		assertFalse(pm.containsEmployee(e));

		dom.removeDivisionOffice(office);
		assertFalse(dom.containsDivisionOffice(office));

		pm.removePerson(p);
		assertFalse(pm.containsPerson(p));

	}
{'fraction_non_alphanumeric': 0.11822125813449023, 'fraction_numerical': 0.0, 'mean_word_length': 6.2272727272727275, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1919191', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1362, 'n_words': 249}