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

import static org.junit.Assert.assertTrue;

import java.text.ParseException;
import java.util.ArrayList;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
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.model.Solicitantes;
import com.ejie.ad74a.service.SolicitantesService;
import com.ejie.ad74a.util.comun.UtilidadesMail;

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

	@Autowired
	private SolicitantesService solicitantesService;

	@Test
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	@Rollback(false)
	public void testEnviarMailAvisoSSB() throws ParseException {

		Solicitantes solicitante = new Solicitantes();
		solicitante.setIdSolicitante01(321204L);
		solicitante = this.solicitantesService.find(solicitante);

		ArrayList<String> ssbTo = new ArrayList<String>();
		ssbTo.add("AD74AU02");
		try {
			UtilidadesMail.getInstance().enviarMailAviso(null, solicitante,
					com.ejie.ad74a.util.constantes.Constantes.TiposCorreo.AVISO_SSB_INF_INTERVENCION, ssbTo);
			assertTrue("Fin petición envío mail", 1 == 1);
		} catch (Exception e) {
			assertTrue("Fin petición envio mail", 1 != 1);
		}

	}

}
