<commit_before>package org.openmrs.reference;

import org.dbunit.dataset.DataSetException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openmrs.reference.helper.PatientGenerator;
import org.openmrs.reference.helper.TestPatient;
import org.openmrs.reference.page.HeaderPage;
import org.openmrs.reference.page.HomePage;
import org.openmrs.reference.page.PatientDashboardPage;
import org.openmrs.reference.page.RegistrationPage;
import org.openmrs.uitestframework.test.TestBase;

import java.sql.SQLException;

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

public class RegistrationAppTest extends TestBase {
    private HeaderPage headerPage;
    private RegistrationPage registrationPage;
    private HomePage homePage;
	private PatientDashboardPage patientDashboardPage;
	private String registeredPatientId;

    @Before
    public void setUp() throws DataSetException, SQLException, Exception {
        headerPage = new HeaderPage(driver);
        homePage = new HomePage(driver);
        registrationPage = new RegistrationPage(driver);
        patientDashboardPage = new PatientDashboardPage(driver);
        headerPage.clickOnHomeIcon();
    	assertPage(loginPage);
        loginPage.loginAsClerk();
        assertPage(homePage);
    }

    // Test for Story RA-71
    @Test
    public void registerAPatient() {
        homePage.openRegisterAPatientApp();
        TestPatient patient = PatientGenerator.generateTestPatient();
        registrationPage.enterPatient(patient);

        String address = patient.address1 + " " + 
        		patient.address2 + " " + 
        		patient.city + " " + 
        		patient.state + " " + 
        		patient.country + " " + 
        		patient.postalCode;

        assertEquals(patient.givenName + " " + patient.familyName, registrationPage.getNameInConfirmationPage());
        assertEquals(patient.gender, registrationPage.getGenderInConfirmationPage());
        assertEquals(patient.birthDay + " " + patient.birthMonth + " " + patient.birthYear, registrationPage.getBirthdateInConfirmationPage());
        assertEquals(address, registrationPage.getAddressInConfirmationPage());
        assertEquals(patient.phone, registrationPage.getPhoneInConfirmationPage());
        
        registrationPage.confirmPatient();
        assertPage(patientDashboardPage);
		registeredPatientId = patientIdFromUrl();	// remember just-registered patient id, so it can be removed.
		assertTrue(driver.getPageSource().contains(patient.givenName + " " + patient.familyName));
    }
    
	@After
    public void tearDown() throws Exception {
		deletePatient(registeredPatientId);
		Thread.sleep(5000);	// a bit of a hack, wait for "created patient" popup to disappear 
        headerPage.logOut();
    }

    // Test for RA-472
    @Test
    public void registerUnidentifiedPatient() {
        homePage.openRegisterAPatientApp();
        TestPatient patient = PatientGenerator.generateTestPatient();
        registrationPage.enterUnidentifiedPatient(patient);

        assertEquals("--", registrationPage.getNameInConfirmationPage());
        assertEquals(patient.gender, registrationPage.getGenderInConfirmationPage());

        registrationPage.confirmPatient();
        assertPage(patientDashboardPage);
        registeredPatientId = patientIdFromUrl();	// remember just-registered patient id, so it can be removed.
        assertTrue(driver.getPageSource().contains("UNKNOWN UNKNOWN"));
    }
}
<commit_msg>revert: updated after change to name layout in patient header<commit_after>package org.openmrs.reference;

import org.dbunit.dataset.DataSetException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openmrs.reference.helper.PatientGenerator;
import org.openmrs.reference.helper.TestPatient;
import org.openmrs.reference.page.HeaderPage;
import org.openmrs.reference.page.HomePage;
import org.openmrs.reference.page.PatientDashboardPage;
import org.openmrs.reference.page.RegistrationPage;
import org.openmrs.uitestframework.test.TestBase;

import java.sql.SQLException;

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

public class RegistrationAppTest extends TestBase {
    private HeaderPage headerPage;
    private RegistrationPage registrationPage;
    private HomePage homePage;
	private PatientDashboardPage patientDashboardPage;
	private String registeredPatientId;

    @Before
    public void setUp() throws DataSetException, SQLException, Exception {
        headerPage = new HeaderPage(driver);
        homePage = new HomePage(driver);
        registrationPage = new RegistrationPage(driver);
        patientDashboardPage = new PatientDashboardPage(driver);
        headerPage.clickOnHomeIcon();
    	assertPage(loginPage);
        loginPage.loginAsClerk();
        assertPage(homePage);
    }

    // Test for Story RA-71
    @Test
    public void registerAPatient() {
        homePage.openRegisterAPatientApp();
        TestPatient patient = PatientGenerator.generateTestPatient();
        registrationPage.enterPatient(patient);

        String address = patient.address1 + " " + 
        		patient.address2 + " " + 
        		patient.city + " " + 
        		patient.state + " " + 
        		patient.country + " " + 
        		patient.postalCode;

        assertEquals(patient.givenName + " " + patient.familyName, registrationPage.getNameInConfirmationPage());
        assertEquals(patient.gender, registrationPage.getGenderInConfirmationPage());
        assertEquals(patient.birthDay + " " + patient.birthMonth + " " + patient.birthYear, registrationPage.getBirthdateInConfirmationPage());
        assertEquals(address, registrationPage.getAddressInConfirmationPage());
        assertEquals(patient.phone, registrationPage.getPhoneInConfirmationPage());
        
        registrationPage.confirmPatient();
        assertPage(patientDashboardPage);
		registeredPatientId = patientIdFromUrl();	// remember just-registered patient id, so it can be removed.
		assertTrue(driver.getPageSource().contains(patient.familyName + ", " + patient.givenName));
    }
    
	@After
    public void tearDown() throws Exception {
		deletePatient(registeredPatientId);
		Thread.sleep(5000);	// a bit of a hack, wait for "created patient" popup to disappear 
        headerPage.logOut();
    }

    // Test for RA-472
    @Test
    public void registerUnidentifiedPatient() {
        homePage.openRegisterAPatientApp();
        TestPatient patient = PatientGenerator.generateTestPatient();
        registrationPage.enterUnidentifiedPatient(patient);

        assertEquals("--", registrationPage.getNameInConfirmationPage());
        assertEquals(patient.gender, registrationPage.getGenderInConfirmationPage());

        registrationPage.confirmPatient();
        assertPage(patientDashboardPage);
        registeredPatientId = patientIdFromUrl();	// remember just-registered patient id, so it can be removed.
        assertTrue(driver.getPageSource().contains("UNKNOWN, UNKNOWN"));
    }
}

{'fraction_non_alphanumeric': 0.09397964951950255, 'fraction_numerical': 0.0031091011871113624, 'mean_word_length': 3.8406292749658, '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': '1464618', 'n_tokens_mistral': 1929, 'n_tokens_neox': 1824, 'n_words': 363}