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);
}
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);
}
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);
}
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\"");
}
}
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;
}
Aggregations