package info.bukova.isspst.mail;

import info.bukova.isspst.data.Material;

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 static org.junit.Assert.*;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/test-context.xml"})
public class MessageBuilderTest {
	
	@Autowired
	private MessageBuilder messageBuilder;
	
	@Test
	public void  buildTest() {
		MailMessage template = new MailMessage();
		Material data = new Material();
		data.setCode("pokus");
		data.setDescription("popisek");
		
		template.setSubject("predmet");
		template.setText("pokusnej text [code] s popiskem [description]");
		
		MailMessage replaced = messageBuilder.buildMessage(template, data);
		
		assertEquals("pokusnej text pokus s popiskem popisek", replaced.getText());
	}

}
