use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityLifeCycleSupportIntTest method createEntity.
public static XmEntity createEntity(String key) {
val data = new HashMap<String, Object>();
data.put("updateState", 0);
data.put("updateByEntity", 0);
data.put("updateByTargetState", 0);
data.put("updateByTransition", 0);
val entity = new XmEntity().key(key).typeKey("TEST_LIFECYCLE").stateKey("STATE1").name("DEFAULT_NAME").description("DEFAULT_DESCRIPTION");
entity.setData(data);
return entity;
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityLifeCycleSupportIntTest method testNotLep.
@Test
@Transactional
public void testNotLep() throws Exception {
MutableLong id = new MutableLong();
// Create the XmEntity
restXmEntityMockMvc.perform(post("/api/xm-entities").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(createEntity("KEY1")))).andDo(r -> {
log.info(r.getResponse().getContentAsString());
final ObjectNode node = new ObjectMapper().readValue(r.getResponse().getContentAsString(), ObjectNode.class);
id.setValue(node.get("id").longValue());
}).andExpect(status().isCreated());
changeState(id, "STATE2", updateStateNotCalled(), updateByEntityNotCalled(), updateByTargetStateNotCalled(), updateByTransitionNotCalled());
initLeps();
changeState(id, "STATE3", updateStateCalled(), updateByEntityCalled(), updateByTargetStateNotCalled(), updateByTransitionNotCalled());
changeState(id, "STATE4", updateStateCalled(), updateByEntityCalled(), updateByTargetStateCalled(), updateByTransitionNotCalled());
changeState(id, "STATE5", updateStateCalled(), updateByEntityCalled(), updateByTargetStateNotCalled(), updateByTransitionNotCalled());
changeState(id, "STATE6", updateStateCalled(), updateByEntityCalled(), updateByTargetStateNotCalled(), updateByTransitionCalled());
changeState(id, "STATE7", updateStateCalled(), updateByEntityCalled(), updateByTargetStateCalled(), updateByTransitionCalled());
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method createXmEntityWithLargeData.
@Test
@Transactional
public void createXmEntityWithLargeData() throws Exception {
int databaseSizeBeforeCreate = xmEntityRepository.findAll().size();
xmEntityIncoming.setData(LARGE_DATA);
// Create the XmEntity
MvcResult result = performPost("/api/xm-entities", xmEntityIncoming).andExpect(status().isCreated()).andReturn();
Integer id = JsonPath.read(result.getResponse().getContentAsString(), "$.id");
// 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(LARGE_VALUE));
// Validate the XmEntity in the database
List<XmEntity> xmEntityList = validateEntityInDB(databaseSizeBeforeCreate + 1);
XmEntity testXmEntity = xmEntityList.get(xmEntityList.size() - 1);
assertThat(testXmEntity.getData()).isEqualTo(LARGE_DATA);
// Validate the XmEntity in Elasticsearch
XmEntity xmEntityEs = xmEntitySearchRepository.findOne(testXmEntity.getId());
assertThat(xmEntityEs).isEqualToComparingFieldByField(testXmEntity);
assertThat(xmEntityEs.getData()).isEqualTo(LARGE_DATA);
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method xmEntityFildsNoRelationFields.
@Test
@Transactional
public void xmEntityFildsNoRelationFields() 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", 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").value(nullValue())).andExpect(jsonPath("$.tags").value(nullValue())).andExpect(jsonPath("$.locations").value(nullValue()));
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method getAllXmEntitiesByTypeKeyNo.
@Test
@Transactional
@WithMockUser(authorities = "SUPER-ADMIN")
public void getAllXmEntitiesByTypeKeyNo() throws Exception {
XmEntity entity = createEntityComplexPersisted(em);
// Get all the xmEntityList
performGet("/api/xm-entities?sort=id,desc&typeKey=PRICE").andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(everyItem(nullValue())));
}
Aggregations