use of com.icthh.xm.ms.entity.domain.Content in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method testAttachmentStartDate.
@Test
@Transactional
public void testAttachmentStartDate() throws Exception {
Attachment attachment = new Attachment().typeKey("A").name("1");
XmEntity entity = new XmEntity().name(" ").key(randomUUID()).typeKey("TEST_DELETE").attachments(asSet(attachment));
MutableObject<Instant> startDate = new MutableObject<>();
MutableObject<XmEntity> entityHolder = new MutableObject<>();
byte[] content = TestUtil.convertObjectToJsonBytes(entity);
restXmEntityMockMvc.perform(post("/api/xm-entities").contentType(TestUtil.APPLICATION_JSON_UTF8).content(content)).andDo(r -> entityHolder.setValue(readValue(r))).andDo(r -> log.info(r.getResponse().getContentAsString())).andExpect(status().is2xxSuccessful());
Long id = entityHolder.getValue().getId();
restXmEntityMockMvc.perform(get("/api/xm-entities/" + id)).andDo(r -> startDate.setValue(readValue(r).getAttachments().iterator().next().getStartDate())).andDo(r -> log.info(r.getResponse().getContentAsString())).andExpect(status().is2xxSuccessful());
assertNotNull(startDate.getValue());
content = TestUtil.convertObjectToJsonBytes(entityHolder.getValue());
restXmEntityMockMvc.perform(put("/api/xm-entities").contentType(TestUtil.APPLICATION_JSON_UTF8).content(content)).andDo(r -> log.info(r.getResponse().getContentAsString())).andExpect(status().is2xxSuccessful());
restXmEntityMockMvc.perform(get("/api/xm-entities/" + id)).andDo(r -> log.info(r.getResponse().getContentAsString())).andDo(r -> assertEquals(startDate.getValue(), readValue(r).getAttachments().iterator().next().getStartDate())).andExpect(status().is2xxSuccessful());
}
use of com.icthh.xm.ms.entity.domain.Content in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method createEntityComplexIncoming.
/**
* Creates incoming Entity as from HTTP request.
* Potentially cam be moved to DTO
*
* @param em - Entity manager
* @return XmEntity for incoming request
*/
public static XmEntity createEntityComplexIncoming(EntityManager em) {
XmEntity entity = createEntity(em);
entity.getTags().add(new Tag().typeKey(DEFAULT_TAG_KEY).startDate(DEFAULT_START_DATE).name(DEFAULT_TAG_NAME));
entity.getAttachments().add(new Attachment().typeKey(DEFAULT_ATTACHMENT_KEY).name(DEFAULT_ATTACHMENT_NAME).startDate(DEFAULT_ATTACHMENT_START_DATE).endDate(DEFAULT_ATTACHMENT_END_DATE).valueContentType(DEFAULT_ATTACHMENT_CONTENT_TYPE).content(new Content().value(DEFAULT_ATTACHMENT_CONTENT_VALUE.getBytes())).contentUrl(DEFAULT_ATTACHMENT_URL).description(DEFAULT_ATTACHMENT_DESCRIPTION));
entity.getLocations().add(new Location().typeKey(DEFAULT_LOCATION_KEY).name(DEFAULT_LOCATION_NAME).countryKey(DEFAULT_LOCATION_COUNTRY_KEY));
return entity;
}
use of com.icthh.xm.ms.entity.domain.Content in project xm-ms-entity by xm-online.
the class ContentResourceIntTest method createContent.
@Test
@Transactional
public void createContent() throws Exception {
int databaseSizeBeforeCreate = contentRepository.findAll().size();
// Create the Content
restContentMockMvc.perform(post("/api/contents").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(content))).andExpect(status().isCreated());
// Validate the Content in the database
List<Content> contentList = contentRepository.findAll();
assertThat(contentList).hasSize(databaseSizeBeforeCreate + 1);
Content testContent = contentList.get(contentList.size() - 1);
assertThat(testContent.getValue()).isEqualTo(DEFAULT_VALUE);
}
use of com.icthh.xm.ms.entity.domain.Content in project xm-ms-entity by xm-online.
the class ContentResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Content.class);
Content content1 = new Content();
content1.setId(1L);
Content content2 = new Content();
content2.setId(content1.getId());
assertThat(content1).isEqualTo(content2);
content2.setId(2L);
assertThat(content1).isNotEqualTo(content2);
content1.setId(null);
assertThat(content1).isNotEqualTo(content2);
}
use of com.icthh.xm.ms.entity.domain.Content in project xm-ms-entity by xm-online.
the class ContentResourceIntTest method updateContent.
@Test
@Transactional
public void updateContent() throws Exception {
// Initialize the database
contentRepository.saveAndFlush(content);
int databaseSizeBeforeUpdate = contentRepository.findAll().size();
// Update the content
Content updatedContent = contentRepository.findOne(content.getId());
updatedContent.value(UPDATED_VALUE);
restContentMockMvc.perform(put("/api/contents").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedContent))).andExpect(status().isOk());
// Validate the Content in the database
List<Content> contentList = contentRepository.findAll();
assertThat(contentList).hasSize(databaseSizeBeforeUpdate);
Content testContent = contentList.get(contentList.size() - 1);
assertThat(testContent.getValue()).isEqualTo(UPDATED_VALUE);
}
Aggregations