Search in sources :

Example 16 with Tag

use of org.mamute.model.Tag in project mamute by caelum.

the class ListController method withTag.

@Get
public void withTag(String tagName, Integer p, boolean semRespostas) {
    Integer page = getPage(p);
    Tag tag = tags.findByName(tagName);
    if (tag == null) {
        result.notFound();
        return;
    }
    List<Question> questionsWithTag = questions.withTagVisible(tag, page, semRespostas);
    result.include("totalPages", questions.numberOfPages(tag));
    result.include("tag", tag);
    result.include("recentTags", recentTagsContainer.getRecentTagsUsage());
    result.include("questions", questionsWithTag);
    result.include("currentPage", page);
    result.include("hasAbout", tags.hasAbout(tag));
    if (semRespostas) {
        result.include("unansweredActive", true);
        result.include("noDefaultActive", true);
        result.include("unansweredTagLinks", true);
    }
}
Also used : Question(org.mamute.model.Question) Tag(org.mamute.model.Tag) Get(br.com.caelum.vraptor.Get)

Example 17 with Tag

use of org.mamute.model.Tag in project mamute by caelum.

the class TagPageDAOTest method should_get_tag_page_by_tag.

@Test
public void should_get_tag_page_by_tag() {
    TagPageDAO tagPages = new TagPageDAO(session);
    Tag java = tag("java");
    session.save(java);
    tagPages.save(new TagPage(java, notMarked("aboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutabout")));
    TagPage javaPage = tagPages.findByTag(java.getName());
    assertEquals(java.getName(), javaPage.getTagName());
}
Also used : TagPageDAO(org.mamute.dao.TagPageDAO) Tag(org.mamute.model.Tag) TagPage(org.mamute.model.TagPage) Test(org.junit.Test)

Example 18 with Tag

use of org.mamute.model.Tag in project mamute by caelum.

the class AttachmentRepositoryTest method should_detach_from_answer.

@Test
public void should_detach_from_answer() {
    final User author = user("question owner", "question@owner.local");
    session.save(author);
    final Attachment attachment = createAttachment("test");
    attachmentRepository.save(attachment);
    final Tag tag = tag("testtag");
    session.save(tag);
    final Question question = question(author, tag);
    session.save(question);
    final Answer answer = answer("answer answer answer answer answer", question, author);
    answer.getAttachments().add(attachment);
    session.save(answer);
    attachmentRepository.delete(answer.getAttachments());
    assertEquals(0, answer.getAttachments().size());
}
Also used : Answer(org.mamute.model.Answer) User(org.mamute.model.User) Attachment(org.mamute.model.Attachment) Question(org.mamute.model.Question) Tag(org.mamute.model.Tag) Test(org.junit.Test)

Example 19 with Tag

use of org.mamute.model.Tag in project mamute by caelum.

the class AttachmentRepositoryTest method should_detach_from_question.

@Test
public void should_detach_from_question() {
    final User author = user("question owner", "question@owner.local");
    session.save(author);
    final Attachment attachment = createAttachment("test");
    attachmentRepository.save(attachment);
    final Tag tag = tag("testtag");
    session.save(tag);
    final Question question = question(author, tag);
    question.getAttachments().add(attachment);
    session.save(question);
    attachmentRepository.delete(question.getAttachments());
    assertEquals(0, question.getAttachments().size());
}
Also used : User(org.mamute.model.User) Attachment(org.mamute.model.Attachment) Question(org.mamute.model.Question) Tag(org.mamute.model.Tag) Test(org.junit.Test)

Example 20 with Tag

use of org.mamute.model.Tag in project mamute by caelum.

the class QuestionTest method should_update_information_and_tag_usage_count.

@Test
public void should_update_information_and_tag_usage_count() throws Exception {
    Tag ruby = tag("ruby");
    Tag java = tag("java");
    Question q = question.withTag(ruby).build();
    QuestionInformation approved = new QuestionInformationBuilder().withTag(java).build();
    q.updateApproved(approved);
    assertEquals(0l, ruby.getUsageCount().longValue());
    assertEquals(1l, java.getUsageCount().longValue());
}
Also used : QuestionInformationBuilder(org.mamute.model.QuestionInformationBuilder) Question(org.mamute.model.Question) Tag(org.mamute.model.Tag) QuestionInformation(org.mamute.model.QuestionInformation) Test(org.junit.Test)

Aggregations

Tag (org.mamute.model.Tag)21 Question (org.mamute.model.Question)9 Test (org.junit.Test)8 User (org.mamute.model.User)7 Before (org.junit.Before)5 LoggedUser (org.mamute.model.LoggedUser)5 Get (br.com.caelum.vraptor.Get)3 ArrayList (java.util.ArrayList)3 Answer (org.mamute.model.Answer)3 CustomBrutauthRules (br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules)2 Post (br.com.caelum.vraptor.Post)2 InvisibleForUsersRule (org.mamute.dao.InvisibleForUsersRule)2 UserSummaryForTag (org.mamute.dto.UserSummaryForTag)2 Attachment (org.mamute.model.Attachment)2 QuestionInformation (org.mamute.model.QuestionInformation)2 QuestionInformationBuilder (org.mamute.model.QuestionInformationBuilder)2 ReputationEvent (org.mamute.model.ReputationEvent)2 TagPage (org.mamute.model.TagPage)2 Environment (br.com.caelum.vraptor.environment.Environment)1 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)1