use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method xmEntityFildsDefaultFields.
@Test
@Transactional
public void xmEntityFildsDefaultFields() throws Exception {
assertThat(xmEntityIncoming.getAttachments().size()).isGreaterThan(0);
assertThat(xmEntityIncoming.getTags().size()).isGreaterThan(0);
assertThat(xmEntityIncoming.getLocations().size()).isGreaterThan(0);
// Create the XmEntity with tag
MvcResult result = performPost("/api/xm-entities", xmEntityIncoming).andExpect(status().isCreated()).andExpect(jsonPath("$.key").value(DEFAULT_KEY)).andReturn();
int id = JsonPath.read(result.getResponse().getContentAsString(), "$.id");
List<XmEntity> xmEntityList = xmEntityRepository.findAll();
em.detach(xmEntityList.get(xmEntityList.size() - 1));
// );
performGet("/api/xm-entities/{id}", id).andExpect(status().isOk()).andDo(this::printMvcResult).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(id)).andExpect(jsonPath("$.key").value(DEFAULT_KEY)).andExpect(jsonPath("$.typeKey").value(DEFAULT_TYPE_KEY)).andExpect(jsonPath("$.stateKey").value(DEFAULT_STATE_KEY)).andExpect(jsonPath("$.name").value(DEFAULT_NAME)).andExpect(jsonPath("$.startDate").value(sameInstant(MOCKED_START_DATE))).andExpect(jsonPath("$.updateDate").value(sameInstant(MOCKED_UPDATE_DATE))).andExpect(jsonPath("$.endDate").value(sameInstant(DEFAULT_END_DATE))).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION)).andExpect(jsonPath("$.data.AAAAAAAAAA").value("BBBBBBBBBB")).andExpect(jsonPath("$.attachments.length()").value(1)).andExpect(jsonPath("$.tags.length()").value(1)).andExpect(jsonPath("$.locations.length()").value(1));
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method createXmEntityWithTagsAttachmentsLocations.
@Test
@Transactional
public void createXmEntityWithTagsAttachmentsLocations() throws Exception {
int databaseSizeBeforeCreate = xmEntityRepository.findAll().size();
// Create the XmEntity with tag, attachment and location
MvcResult result = performPost("/api/xm-entities", xmEntityIncoming).andExpect(status().isCreated()).andExpect(jsonPath("$.key").value(DEFAULT_KEY)).andReturn();
Integer id = JsonPath.read(result.getResponse().getContentAsString(), "$.id");
List<XmEntity> xmEntityList = validateEntityInDB(databaseSizeBeforeCreate + 1);
XmEntity testXmEntity = xmEntityList.get(xmEntityList.size() - 1);
// Get the xmEntityPersisted by ID
performGet("/api/xm-entities/{id}", id).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(id)).andExpect(jsonPath("$.key").value(DEFAULT_KEY)).andExpect(jsonPath("$.typeKey").value(DEFAULT_TYPE_KEY)).andExpect(jsonPath("$.stateKey").value(DEFAULT_STATE_KEY)).andExpect(jsonPath("$.name").value(DEFAULT_NAME)).andExpect(jsonPath("$.startDate").value(sameInstant(MOCKED_START_DATE))).andExpect(jsonPath("$.updateDate").value(sameInstant(MOCKED_UPDATE_DATE))).andExpect(jsonPath("$.endDate").value(sameInstant(DEFAULT_END_DATE))).andExpect(jsonPath("$.avatarUrl").value(containsString("aaaaa.jpg"))).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION)).andExpect(jsonPath("$.data.AAAAAAAAAA").value("BBBBBBBBBB")).andExpect(jsonPath("$.tags[0].id").value(notNullValue())).andExpect(jsonPath("$.tags[0].name").value(DEFAULT_TAG_NAME)).andExpect(jsonPath("$.tags[0].typeKey").value(DEFAULT_TAG_KEY)).andExpect(jsonPath("$.tags[0].xmEntity").value(id)).andExpect(jsonPath("$.attachments[0].id").value(notNullValue())).andExpect(jsonPath("$.attachments[0].typeKey").value(DEFAULT_ATTACHMENT_KEY)).andExpect(jsonPath("$.attachments[0].name").value(DEFAULT_ATTACHMENT_NAME)).andExpect(jsonPath("$.attachments[0].contentUrl").value(DEFAULT_ATTACHMENT_URL)).andExpect(jsonPath("$.attachments[0].description").value(DEFAULT_ATTACHMENT_DESCRIPTION)).andExpect(jsonPath("$.attachments[0].startDate").value(DEFAULT_ATTACHMENT_START_DATE.toString())).andExpect(jsonPath("$.attachments[0].endDate").value(DEFAULT_ATTACHMENT_END_DATE.toString())).andExpect(jsonPath("$.attachments[0].valueContentType").value(DEFAULT_ATTACHMENT_CONTENT_TYPE)).andExpect(jsonPath("$.attachments[0].valueContentSize").value(DEFAULT_ATTACHMENT_CONTENT_SIZE)).andExpect(jsonPath("$.attachments[0].xmEntity").value(id)).andExpect(jsonPath("$.locations[0].id").value(notNullValue())).andExpect(jsonPath("$.locations[0].typeKey").value(DEFAULT_LOCATION_KEY)).andExpect(jsonPath("$.locations[0].name").value(DEFAULT_LOCATION_NAME)).andExpect(jsonPath("$.locations[0].countryKey").value(DEFAULT_LOCATION_COUNTRY_KEY)).andExpect(jsonPath("$.locations[0].xmEntity").value(id));
// Validate the XmEntity in Elasticsearch
XmEntity xmEntityEs = xmEntitySearchRepository.findOne(Long.valueOf(id.toString()));
assertThat(xmEntityEs).isEqualToComparingFieldByField(testXmEntity);
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method createEntityComplexPersisted.
/**
* Creates XmEntiy with tags and persist to DB.
* Emulates existing XM entity manipulation
*
* @param em - Entity manager
* @return XmEntity persisted in DB
*/
public static XmEntity createEntityComplexPersisted(EntityManager em) {
XmEntity entity = createEntity(em);
em.persist(entity);
em.flush();
entity.addTags(new Tag().typeKey(DEFAULT_TAG_KEY).startDate(DEFAULT_START_DATE).name(DEFAULT_TAG_NAME));
em.persist(entity);
em.flush();
return entity;
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method createXmEntityWithLinks.
@Test
@Transactional
public void createXmEntityWithLinks() throws Exception {
XmEntity presaved = xmEntityService.save(createEntity(em));
int databaseSizeBeforeCreate = xmEntityRepository.findAll().size();
XmEntity entity = xmEntityIncoming;
entity.getTargets().add(new Link().typeKey(DEFAULT_LN_TARGET_KEY).name(DEFAULT_LN_TARGET_NAME).startDate(DEFAULT_LN_TARGET_START_DATE).target(presaved));
// Create the XmEntity with tag
MvcResult result = performPost("/api/xm-entities", entity).andExpect(status().isCreated()).andExpect(jsonPath("$.key").value(DEFAULT_KEY)).andReturn();
Integer id = JsonPath.read(result.getResponse().getContentAsString(), "$.id");
List<XmEntity> xmEntityList = validateEntityInDB(databaseSizeBeforeCreate + 1);
XmEntity testXmEntity = xmEntityList.get(xmEntityList.size() - 1);
// Get the xmEntityPersisted with tag by ID
performGet("/api/xm-entities/{id}", id).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(id)).andExpect(jsonPath("$.key").value(DEFAULT_KEY)).andExpect(jsonPath("$.typeKey").value(DEFAULT_TYPE_KEY)).andExpect(jsonPath("$.stateKey").value(DEFAULT_STATE_KEY)).andExpect(jsonPath("$.name").value(DEFAULT_NAME)).andExpect(jsonPath("$.startDate").value(sameInstant(MOCKED_START_DATE))).andExpect(jsonPath("$.updateDate").value(sameInstant(MOCKED_UPDATE_DATE))).andExpect(jsonPath("$.endDate").value(sameInstant(DEFAULT_END_DATE))).andExpect(jsonPath("$.avatarUrl").value(containsString("aaaaa.jpg"))).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION)).andExpect(jsonPath("$.data.AAAAAAAAAA").value("BBBBBBBBBB")).andExpect(jsonPath("$.targets[0].id").value(notNullValue())).andExpect(jsonPath("$.targets[0].name").value(DEFAULT_LN_TARGET_NAME)).andExpect(jsonPath("$.targets[0].typeKey").value(DEFAULT_LN_TARGET_KEY)).andExpect(jsonPath("$.targets[0].source").value(id)).andExpect(jsonPath("$.targets[0].target.id").value(presaved.getId())).andExpect(jsonPath("$.targets[0].target.typeKey").value(presaved.getTypeKey()));
// Validate the XmEntity in Elasticsearch
XmEntity xmEntityEs = xmEntitySearchRepository.findOne(Long.valueOf(id.toString()));
assertThat(xmEntityEs).isEqualToComparingFieldByField(testXmEntity);
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method xmEntityFildsTwoFields.
@Test
@Transactional
public void xmEntityFildsTwoFields() throws Exception {
assertThat(xmEntityIncoming.getAttachments().size()).isGreaterThan(0);
assertThat(xmEntityIncoming.getTags().size()).isGreaterThan(0);
assertThat(xmEntityIncoming.getLocations().size()).isGreaterThan(0);
// Create the XmEntity with tag
MvcResult result = performPost("/api/xm-entities", xmEntityIncoming).andExpect(status().isCreated()).andExpect(jsonPath("$.key").value(DEFAULT_KEY)).andReturn();
int id = JsonPath.read(result.getResponse().getContentAsString(), "$.id");
List<XmEntity> xmEntityList = xmEntityRepository.findAll();
em.detach(xmEntityList.get(xmEntityList.size() - 1));
// );
performGet("/api/xm-entities/{id}?embed=id,attachments,tags", id).andExpect(status().isOk()).andDo(this::printMvcResult).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(id)).andExpect(jsonPath("$.key").value(DEFAULT_KEY)).andExpect(jsonPath("$.typeKey").value(DEFAULT_TYPE_KEY)).andExpect(jsonPath("$.stateKey").value(DEFAULT_STATE_KEY)).andExpect(jsonPath("$.name").value(DEFAULT_NAME)).andExpect(jsonPath("$.startDate").value(sameInstant(MOCKED_START_DATE))).andExpect(jsonPath("$.updateDate").value(sameInstant(MOCKED_UPDATE_DATE))).andExpect(jsonPath("$.endDate").value(sameInstant(DEFAULT_END_DATE))).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION)).andExpect(jsonPath("$.data.AAAAAAAAAA").value("BBBBBBBBBB")).andExpect(jsonPath("$.attachments.length()").value(1)).andExpect(jsonPath("$.tags.length()").value(1)).andExpect(jsonPath("$.locations").value(nullValue()));
}
Aggregations