Search in sources :

Example 11 with Attachment

use of org.summerb.microservices.articles.api.dto.Attachment in project summerb by skarpushin.

the class AttachmentServiceImplTest method testAttachment_expectCreatedAndRetrieved.

@Test
public void testAttachment_expectCreatedAndRetrieved() throws Exception {
    Attachment a = new Attachment();
    a.setArticleId(createTestArticle());
    a.setName("test attachment");
    a.setSize(123);
    a.setContents(createValidContentsReader());
    Attachment result = attachmentService.create(a);
    assertNotNull(result);
    assertNotNull(result.getId());
    assertTrue(result.getId() > 0);
    Attachment b = attachmentService.findById(result.getId());
    assertNotNull(b);
    // NOTE: By default we don't want to open stream
    assertNull(b.getContents());
}
Also used : Attachment(org.summerb.microservices.articles.api.dto.Attachment) Test(org.junit.Test)

Aggregations

Attachment (org.summerb.microservices.articles.api.dto.Attachment)11 Test (org.junit.Test)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 Locale (java.util.Locale)3 Article (org.summerb.microservices.articles.api.dto.Article)3 RenderedArticle (org.summerb.microservices.articles.api.dto.consuming.RenderedArticle)2 EventBus (com.google.common.eventbus.EventBus)1 UrlBuilderTestImpl (integr.ru.skarpushin.services.articles.impl.UrlBuilderTestImpl)1 InputStream (java.io.InputStream)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 FileItem (org.apache.commons.fileupload.FileItem)1 InputStreamResource (org.springframework.core.io.InputStreamResource)1 HttpHeaders (org.springframework.http.HttpHeaders)1 ResponseEntity (org.springframework.http.ResponseEntity)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 PagerParams (org.summerb.approaches.jdbccrud.api.dto.PagerParams)1 Query (org.summerb.approaches.jdbccrud.api.query.Query)1 PageMessage (org.summerb.approaches.springmvc.model.PageMessage)1 ArticleAbsoluteUrlBuilder (org.summerb.microservices.articles.api.ArticleAbsoluteUrlBuilder)1