<commit_before>package br.com.caelum.brutal.infra.rss;

import static org.junit.Assert.assertTrue;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;

import org.joda.time.DateTimeUtils;
import org.junit.Test;

import br.com.caelum.brutal.builder.QuestionBuilder;
import br.com.caelum.brutal.dao.TestCase;
import br.com.caelum.brutal.model.Question;
import br.com.caelum.brutal.model.User;
import br.com.caelum.brutal.model.interfaces.RssContent;
import br.com.caelum.vraptor.environment.DefaultEnvironment;

public class RssFeedFactoryTest extends TestCase {
	
	@Test
	public void should_generate_feed() throws IOException {
		DefaultEnvironment env = new DefaultEnvironment("development");
		QuestionRssEntryFactory factory = new QuestionRssEntryFactory(env);
		RssFeedFactory rssFeedFactory = new RssFeedFactory(env, factory);
		
		QuestionBuilder builder = new QuestionBuilder();
		
		DateTimeUtils.setCurrentMillisFixed(100);
		User user1 = user("author1", "author@email");
		user1.setPhotoUri(new URL("http://imagemsuser1.com"));
		Question question1 = builder.withAuthor(user1)
			.withTitle("first question")
			.withDescription("question")
			.withId(1l)
			.build();
		
		User user2 = user("author2", "author@email");
		user2.setPhotoUri(new URL("http://imagemsuser2.com"));
		Question question2 = builder.withId(2l)
			.withTitle("second question")
			.withAuthor(user2)
			.build();
		
		ByteArrayOutputStream output = new ByteArrayOutputStream();
		rssFeedFactory.build(Arrays.<RssContent>asList(question1, question2), output);
		output.close();
		String xml = new String(output.toByteArray());
		assertTrue(xml.contains("first question"));
		assertTrue(xml.contains("second question"));
		assertTrue(xml.contains("http://imagemsuser1.com"));
		assertTrue(xml.contains("http://imagemsuser2.com"));
		DateTimeUtils.setCurrentMillisSystem();
	}
}<commit_msg>corrigindo teste de unidade<commit_after>package br.com.caelum.brutal.infra.rss;

import static org.junit.Assert.assertTrue;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;

import org.joda.time.DateTimeUtils;
import org.junit.Test;

import br.com.caelum.brutal.builder.QuestionBuilder;
import br.com.caelum.brutal.dao.TestCase;
import br.com.caelum.brutal.model.Question;
import br.com.caelum.brutal.model.User;
import br.com.caelum.brutal.model.interfaces.RssContent;
import br.com.caelum.vraptor.environment.DefaultEnvironment;

public class RssFeedFactoryTest extends TestCase {
	
	@Test
	public void should_generate_feed() throws IOException {
		DefaultEnvironment env = new DefaultEnvironment("development");
		QuestionRssEntryFactory factory = new QuestionRssEntryFactory(env);
		RssFeedFactory rssFeedFactory = new RssFeedFactory(env, factory);
		
		QuestionBuilder builder = new QuestionBuilder();
		
		DateTimeUtils.setCurrentMillisFixed(100);
		User user1 = user("author1", "author<EMAIL>");
		user1.setPhotoUri(new URL("http://imagemsuser1.com"));
		Question question1 = builder.withAuthor(user1)
			.withTitle("first question")
			.withDescription("question")
			.withId(1l)
			.build();
		
		User user2 = user("author2", "author@email");
		user2.setPhotoUri(new URL("http://imagemsuser2.com"));
		Question question2 = builder.withId(2l)
			.withTitle("second question")
			.withAuthor(user2)
			.build();
		
		ByteArrayOutputStream output = new ByteArrayOutputStream();
		rssFeedFactory.build(Arrays.<RssContent>asList(question1, question2), output, "title", "description");
		output.close();
		String xml = new String(output.toByteArray());
		assertTrue(xml.contains("first question"));
		assertTrue(xml.contains("second question"));
		assertTrue(xml.contains("http://imagemsuser1.com"));
		assertTrue(xml.contains("http://imagemsuser2.com"));
		DateTimeUtils.setCurrentMillisSystem();
	}
}
{'fraction_non_alphanumeric': 0.12996667521148422, 'fraction_numerical': 0.0107664701358626, 'mean_word_length': 5.774305555555555, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1373765', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1228, 'n_words': 213}