package com.agilex.healthcare.schedulingmanager.datalayer.vista.util;

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

import com.agilex.healthcare.mobilehealthplatform.domain.DataIdentifier;
import com.agilex.healthcare.mobilehealthplatform.domain.PatientIdentifier;

public class TestUtil {
	/**
	 * A patient identifier comes back as an object when it's null with all of the fields set to null.
	 */
	public static void assertPatientIdentifier(PatientIdentifier patientIdentifier, String assigningAuthority, String uniqueId) {
		assertNotNull(patientIdentifier);
		assertEquals(assigningAuthority, patientIdentifier.getAssigningAuthority());
		assertNull(patientIdentifier.getFirstName());
		assertNull(patientIdentifier.getLastName());
		assertNull(patientIdentifier.getSsn());
		assertEquals(uniqueId, patientIdentifier.getUniqueId());
	}
	
	/**
	 * A patient identifier comes back as an object when it's null with all of the fields set to null.
	 */
	public static void assertNullPatientIdentifier(PatientIdentifier patientIdentifier) {
		assertNotNull(patientIdentifier);
		assertNull(patientIdentifier.getAssigningAuthority());
		assertNull(patientIdentifier.getFirstName());
		assertNull(patientIdentifier.getLastName());
		assertNull(patientIdentifier.getSsn());
		assertNull(patientIdentifier.getUniqueId());
	}
	
	/**
	 * A data identifier comes back as an object when it's null with all of the fields set to null.
	 */
	public static void assertNullDataIdentifier(DataIdentifier dataIdentifier) {
		assertNotNull(dataIdentifier);
		assertNull(dataIdentifier.getSystemId());
		assertNull(dataIdentifier.getUniqueId());
	}
	
	/**
	 * A data identifier comes back as an object when it's null with all of the fields set to null.
	 * Because we found that the uniqueId returned from mdws could be different for every single time
	 * you called it, we added in ability to just check if uniqueId is not null by passing in an empty string
	 * rather than null.
	 */
	public static void assertDataIdentifier(DataIdentifier dataIdentifier, String systemId, String uniqueId) {
		assertNotNull(dataIdentifier);
		if (systemId == null)
			assertNull(dataIdentifier.getSystemId());
		else
			assertEquals(systemId, dataIdentifier.getSystemId());
		
		if (uniqueId == null)
			assertNull(dataIdentifier.getUniqueId());
		else if (uniqueId.isEmpty())
			assertNotNull(dataIdentifier.getUniqueId());
		else
			assertEquals(uniqueId, dataIdentifier.getUniqueId());
	}
}
