use of org.mamute.model.Tag in project mamute by caelum.
the class QuestionTest method should_return_true_if_question_has_pending_edits.
@Test
public void should_return_true_if_question_has_pending_edits() throws Exception {
Tag ruby = tag("ruby");
Tag java = tag("java");
Question q = question.withTag(ruby).build();
assertFalse(q.hasPendingEdits());
QuestionInformation approved = new QuestionInformationBuilder().withTag(java).build();
q.enqueueChange(approved, PENDING);
assertTrue(q.hasPendingEdits());
}
use of org.mamute.model.Tag in project mamute by caelum.
the class InformationDAOTest method setup.
@Before
public void setup() {
author = user("namename", "email@gmail.com");
currentAuthor = new LoggedUser(author, null);
java = new Tag("java", "", null);
session.save(author);
session.save(java);
informations = new InformationDAO(session);
question = newQuestion(author);
}
use of org.mamute.model.Tag in project mamute by caelum.
the class TagsValidatorTest method setup.
@Before
public void setup() {
environment = mock(Environment.class);
when(environment.get("tags.sanitizer.regex")).thenReturn("[a-zA-Z0-9-]");
messageFactory = new MessageFactory(bundle);
validator = new MockValidator();
tagsValidator = new TagsValidator(environment, validator, messageFactory);
User user = user("any", "any@brutal.com");
java = new Tag("java", "", user);
ruby = new Tag("ruby", "", user);
rails = new Tag("rails", "", user);
nonalpha = new Tag("java,mysql", "", user);
}
use of org.mamute.model.Tag in project mamute by caelum.
the class SolrQuestionIndex method toDoc.
private SolrInputDocument toDoc(Question q) {
List<String> tagNames = Lists.transform(q.getTags(), new Function<Tag, String>() {
@Nullable
@Override
public String apply(@Nullable Tag tag) {
return tag.getName();
}
});
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", q.getId());
doc.addField("title", q.getTitle());
doc.addField("description", q.getMarkedDescription());
doc.addField("tags", join(tagNames));
String solution = null;
List<String> answers = new ArrayList<>();
for (Answer a : q.getAnswers()) {
if (a.isSolution()) {
solution = a.getDescription();
} else {
answers.add(a.getDescription());
}
}
if (solution != null) {
doc.addField("solution", solution);
}
if (answers.size() > 0) {
doc.addField("answers", join(answers));
}
return doc;
}
use of org.mamute.model.Tag in project mamute by caelum.
the class RssController method rssByTag.
@Get
public void rssByTag(String tagName) throws IOException {
Tag tag = tags.findByName(tagName);
if (tag == null) {
result.notFound();
return;
}
List<RssContent> orderedByDate = questions.orderedByCreationDate(MAX_RESULTS, tag);
String title = bundle.getMessage("questions.rss.title", bundle.getMessage("site.name"));
String description = bundle.getMessage("questions.rss.description", bundle.getMessage("site.name"));
buildRss(orderedByDate, title, description);
}
Aggregations