use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method getAllXmEntitiesByTypeKey.
@Test
@Transactional
@WithMockUser(authorities = "SUPER-ADMIN")
public void getAllXmEntitiesByTypeKey() throws Exception {
XmEntity entity = createEntityComplexPersisted(em);
// Get all the xmEntityList
performGet("/api/xm-entities?sort=id,desc&typeKey=ACCOUNT").andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(entity.getId().intValue()))).andExpect(jsonPath("$.[*].typeKey").value(hasItem(DEFAULT_TYPE_KEY)));
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method updateTenantXmEntity.
@Test
@Transactional
public void updateTenantXmEntity() throws Exception {
// Initialize the database
XmEntity tenantEntity = createEntity(em);
tenantEntity.setTypeKey(Constants.TENANT_TYPE_KEY);
tenantEntity.setStateKey(null);
tenantEntity.setData(null);
xmEntityRepository.save(tenantEntity);
int databaseSizeBeforeUpdate = xmEntityRepository.findAll().size();
// Update the xmEntity
XmEntity updatedTenantEntity = createEntity(em);
updatedTenantEntity.setId(tenantEntity.getId());
updatedTenantEntity.setTypeKey(Constants.TENANT_TYPE_KEY);
updatedTenantEntity.setStateKey(null);
updatedTenantEntity.setData(null);
updatedTenantEntity.setName("updatedName");
restXmEntityMockMvc.perform(put("/api/xm-entities").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedTenantEntity))).andExpect(status().isOk());
// Validate the XmEntity in the database
List<XmEntity> xmEntityList = xmEntityRepository.findAll();
assertThat(xmEntityList).hasSize(databaseSizeBeforeUpdate);
XmEntity testXmEntity = xmEntityList.get(xmEntityList.size() - 1);
assertThat(testXmEntity.getName()).isEqualTo(DEFAULT_NAME);
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method prepareCalendar.
private int prepareCalendar() throws Exception {
// 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");
xmEntityIncoming.setId((long) id);
val calendar = new Calendar().name("name").typeKey("TYPEKEY").startDate(Instant.now()).xmEntity(xmEntityIncoming);
MvcResult resultSaveCalendar = performPost("/api/calendars", calendar).andExpect(status().is2xxSuccessful()).andReturn();
int calendarId = JsonPath.read(resultSaveCalendar.getResponse().getContentAsString(), "$.id");
calendar.setId((long) calendarId);
val event = new Event().typeKey("TYPEKEY").title("title").startDate(Instant.now()).calendar(calendar).assigned(xmEntityIncoming);
MvcResult resultSaveEvent = performPost("/api/events", event).andExpect(status().is2xxSuccessful()).andReturn();
List<XmEntity> xmEntityList = xmEntityRepository.findAll();
em.detach(xmEntityList.get(xmEntityList.size() - 1));
List<Calendar> calendarList = calendarService.findAll(null);
em.detach(calendarList.get(calendarList.size() - 1));
return id;
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResourceIntTest method changeStateError.
@Test
@Transactional
public void changeStateError() throws Exception {
XmEntitySpecService xmEntitySpecService = Mockito.mock(XmEntitySpecService.class);
StateSpec nextSpec = new StateSpec();
nextSpec.setKey("NEXT_STATE");
when(xmEntitySpecService.nextStates(eq(DEFAULT_TYPE_KEY), eq(DEFAULT_STATE_KEY))).thenReturn(Collections.singletonList(nextSpec));
XmEntity tenant = createEntity(em);
xmEntityServiceImpl.save(tenant);
restXmEntityMockMvc.perform(put("/api/xm-entities/{idOrKey}/states/{stateKey}", tenant.getId(), "INVALID_NEXT_STATE").contentType(TestUtil.APPLICATION_JSON_UTF8)).andExpect(status().is4xxClientError());
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class FunctionContextResourceIntTest method createEntity.
/**
* Create an entity for this test.
*
* 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 FunctionContext createEntity(EntityManager em) {
FunctionContext functionContext = new FunctionContext().key(DEFAULT_KEY).typeKey(DEFAULT_TYPE_KEY).description(DEFAULT_DESCRIPTION).startDate(DEFAULT_START_DATE).updateDate(DEFAULT_UPDATE_DATE).endDate(DEFAULT_END_DATE).data(DEFAULT_DATA);
// Add required entity
XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
em.persist(xmEntity);
em.flush();
functionContext.setXmEntity(xmEntity);
return functionContext;
}
Aggregations