package com.agilex.healthcare.schedulingmanager.datalayer;

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

import javax.annotation.Resource;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.agilex.healthcare.schedulingmanager.datalayer.vista.util.AuthenticationUtil;
import com.agilex.healthcare.schedulingmanager.domain.CancelReasons;
import com.agilex.healthcare.schedulingmanager.mdws.connection.MdwsConfiguration;

@ContextConfiguration(locations = {"classpath:integrationApplicationContext.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public class SchedulingDataLayerMdwsCancelVistaTest {
	
	@Resource
	MdwsConfiguration mdwsSchedulingConfiguration;

	@BeforeClass
	public static void login() {
		AuthenticationUtil.loginUser("777", "clerk3434", "clerk4343$", "1");
	}
	@AfterClass
	public static void logoff() {
		AuthenticationUtil.logoffUser();
	}

	@Test
	public void getCancelReasonList() {
		SchedulingDataLayerMdws dl = new SchedulingDataLayerMdws(mdwsSchedulingConfiguration);
		CancelReasons reasons = dl.getCancelReasonList("777");
		assertNotNull(reasons);
		assertEquals(13, reasons.getSize());
		assertNotNull(reasons.get(0));
		assertEquals("10", reasons.get(0).getNumber());
		assertEquals("APPOINTMENT NO LONGER REQUIRED", reasons.get(0).getText());
	}
}