package com.ejie.ad74a.service.test.basic;

import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ejie.ad74a.dao.ExpedientesDao;
import com.ejie.ad74a.dao.PisosTuteladosDao;
import com.ejie.ad74a.model.Direcciones;
import com.ejie.ad74a.model.Expedientes;
import com.ejie.ad74a.model.PisosTutelados;
import com.ejie.ad74a.service.ExpedientesService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:test/application-context.xml")
public class TestExpedienteService {

	@Autowired
	private ExpedientesDao expedientesDao;

	@Autowired
	private PisosTuteladosDao pisosTuteladosDao;

	@Test
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	// @Rollback(true)
	public void testHistorico() {
		String total = this.expedientesDao.pasarHistorico("aa");
		System.out.println("Total: " + total);
		assertTrue("No se ha recuperado el solicitante", total != null);
	}

	@Test
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public void testIsPisoTutelado() {

		Direcciones direccion = new Direcciones();
		direccion.setIdProvincia06("01");
		direccion.setIdMunicipio06("059");
		direccion.setIdLocalidad06(10105900000734L);
		direccion.setIdCalle06(130105900005600L);
		direccion.setIdPortal06(80105900001243L);
		direccion.setPiso06("1");
		List<PisosTutelados> listPisos = this.pisosTuteladosDao.isPisoTutelado(direccion);
		System.out.println("Total: " + listPisos.size());
		assertTrue("No se ha recuperado el solicitante", listPisos.size() > 0);
	}

}
