Search in sources :

Example 6 with Attachment

use of com.icthh.xm.ms.entity.domain.Attachment in project xm-ms-entity by xm-online.

the class AttachmentResourceExtendedIntTest method checkStartDateIsNotRequired.

@Test
@Transactional
public void checkStartDateIsNotRequired() throws Exception {
    int databaseSizeBeforeTest = attachmentRepository.findAll().size();
    // set the field null
    attachment.setStartDate(null);
    // Create the Attachment.
    restAttachmentMockMvc.perform(post("/api/attachments").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(attachment))).andExpect(status().isCreated()).andExpect(jsonPath("$.startDate").value(MOCKED_START_DATE.toString()));
    List<Attachment> attachmentList = attachmentRepository.findAll();
    assertThat(attachmentList).hasSize(databaseSizeBeforeTest + 1);
    Attachment testAttachment = attachmentList.get(attachmentList.size() - 1);
    assertThat(testAttachment.getStartDate()).isEqualTo(MOCKED_START_DATE);
    // Validate the Attachment in Elasticsearch
    Attachment attachmentEs = attachmentSearchRepository.findOne(testAttachment.getId());
    assertThat(attachmentEs).isEqualToComparingFieldByField(testAttachment);
}
Also used : Attachment(com.icthh.xm.ms.entity.domain.Attachment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Attachment

use of com.icthh.xm.ms.entity.domain.Attachment in project xm-ms-entity by xm-online.

the class AttachmentResourceIntTest method updateAttachment.

@Test
@Transactional
public void updateAttachment() throws Exception {
    // Initialize the database
    attachmentService.save(attachment);
    int databaseSizeBeforeUpdate = attachmentRepository.findAll().size();
    // Update the attachment
    Attachment updatedAttachment = attachmentRepository.findOne(attachment.getId());
    updatedAttachment.typeKey(UPDATED_TYPE_KEY).name(UPDATED_NAME).contentUrl(UPDATED_CONTENT_URL).description(UPDATED_DESCRIPTION).startDate(UPDATED_START_DATE).endDate(UPDATED_END_DATE).valueContentType(UPDATED_VALUE_CONTENT_TYPE).valueContentSize(UPDATED_VALUE_CONTENT_SIZE);
    restAttachmentMockMvc.perform(put("/api/attachments").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedAttachment))).andExpect(status().isOk());
    // Validate the Attachment in the database
    List<Attachment> attachmentList = attachmentRepository.findAll();
    assertThat(attachmentList).hasSize(databaseSizeBeforeUpdate);
    Attachment testAttachment = attachmentList.get(attachmentList.size() - 1);
    assertThat(testAttachment.getTypeKey()).isEqualTo(UPDATED_TYPE_KEY);
    assertThat(testAttachment.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testAttachment.getContentUrl()).isEqualTo(UPDATED_CONTENT_URL);
    assertThat(testAttachment.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
    assertThat(testAttachment.getStartDate()).isEqualTo(UPDATED_START_DATE);
    assertThat(testAttachment.getEndDate()).isEqualTo(UPDATED_END_DATE);
    assertThat(testAttachment.getValueContentType()).isEqualTo(UPDATED_VALUE_CONTENT_TYPE);
    assertThat(testAttachment.getValueContentSize()).isEqualTo(UPDATED_VALUE_CONTENT_SIZE);
    // Validate the Attachment in Elasticsearch
    Attachment attachmentEs = attachmentSearchRepository.findOne(testAttachment.getId());
    assertThat(attachmentEs).isEqualToComparingFieldByField(testAttachment);
}
Also used : Attachment(com.icthh.xm.ms.entity.domain.Attachment) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Attachment

use of com.icthh.xm.ms.entity.domain.Attachment in project xm-ms-entity by xm-online.

the class AttachmentResourceIntTest method createAttachment.

@Test
@Transactional
public void createAttachment() throws Exception {
    int databaseSizeBeforeCreate = attachmentRepository.findAll().size();
    // Create the Attachment
    restAttachmentMockMvc.perform(post("/api/attachments").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(attachment))).andExpect(status().isCreated());
    // Validate the Attachment in the database
    List<Attachment> attachmentList = attachmentRepository.findAll();
    assertThat(attachmentList).hasSize(databaseSizeBeforeCreate + 1);
    Attachment testAttachment = attachmentList.get(attachmentList.size() - 1);
    assertThat(testAttachment.getTypeKey()).isEqualTo(DEFAULT_TYPE_KEY);
    assertThat(testAttachment.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testAttachment.getContentUrl()).isEqualTo(DEFAULT_CONTENT_URL);
    assertThat(testAttachment.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
    assertThat(testAttachment.getStartDate()).isEqualTo(DEFAULT_START_DATE);
    assertThat(testAttachment.getEndDate()).isEqualTo(DEFAULT_END_DATE);
    assertThat(testAttachment.getValueContentType()).isEqualTo(DEFAULT_VALUE_CONTENT_TYPE);
    assertThat(testAttachment.getValueContentSize()).isEqualTo(DEFAULT_VALUE_CONTENT_SIZE);
    // Validate the Attachment in Elasticsearch
    Attachment attachmentEs = attachmentSearchRepository.findOne(testAttachment.getId());
    assertThat(attachmentEs).isEqualToComparingFieldByField(testAttachment);
}
Also used : Attachment(com.icthh.xm.ms.entity.domain.Attachment) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with Attachment

use of com.icthh.xm.ms.entity.domain.Attachment in project xm-ms-entity by xm-online.

the class AttachmentResourceExtendedIntTest method checkStartDateIsRequiredInDb.

@Test
@Transactional
public void checkStartDateIsRequiredInDb() throws Exception {
    Attachment att = attachmentService.save(attachment);
    // set the field null
    when(startUpdateDateGenerationStrategy.generateStartDate()).thenReturn(null);
    att.setStartDate(null);
    attachmentService.save(att);
    try {
        attachmentRepository.flush();
        fail("DataIntegrityViolationException exception was expected!");
    } catch (DataIntegrityViolationException e) {
        assertThat(e.getMostSpecificCause().getMessage()).containsIgnoringCase("NULL not allowed for column \"START_DATE\"");
    }
}
Also used : Attachment(com.icthh.xm.ms.entity.domain.Attachment) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with Attachment

use of com.icthh.xm.ms.entity.domain.Attachment in project xm-ms-entity by xm-online.

the class AttachmentResourceIntTest method createEntity.

/**
 * Create an entity for this test.
 * <p>
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static Attachment createEntity(EntityManager em) {
    Attachment attachment = new Attachment().typeKey(DEFAULT_TYPE_KEY).name(DEFAULT_NAME).contentUrl(DEFAULT_CONTENT_URL).description(DEFAULT_DESCRIPTION).startDate(DEFAULT_START_DATE).endDate(DEFAULT_END_DATE).valueContentType(DEFAULT_VALUE_CONTENT_TYPE).valueContentSize(DEFAULT_VALUE_CONTENT_SIZE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    attachment.setXmEntity(xmEntity);
    return attachment;
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Attachment(com.icthh.xm.ms.entity.domain.Attachment)

Aggregations

Attachment (com.icthh.xm.ms.entity.domain.Attachment)14 Test (org.junit.Test)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 Transactional (org.springframework.transaction.annotation.Transactional)8 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)6 Location (com.icthh.xm.ms.entity.domain.Location)4 Tag (com.icthh.xm.ms.entity.domain.Tag)4 Calendar (com.icthh.xm.ms.entity.domain.Calendar)3 Link (com.icthh.xm.ms.entity.domain.Link)3 LogicExtensionPoint (com.icthh.xm.commons.lep.LogicExtensionPoint)2 Comment (com.icthh.xm.ms.entity.domain.Comment)2 Content (com.icthh.xm.ms.entity.domain.Content)2 Event (com.icthh.xm.ms.entity.domain.Event)2 Rating (com.icthh.xm.ms.entity.domain.Rating)2 Vote (com.icthh.xm.ms.entity.domain.Vote)2 JsonAutoDetect (com.fasterxml.jackson.annotation.JsonAutoDetect)1 JsonInclude (com.fasterxml.jackson.annotation.JsonInclude)1 PropertyAccessor (com.fasterxml.jackson.annotation.PropertyAccessor)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1