use of com.icthh.xm.ms.entity.domain.Link in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method testNoCycleJson.
@Test(expected = JsonMappingException.class)
@Transactional
public void testNoCycleJson() throws Exception {
XmEntity target = new XmEntity().typeKey("TARGET");
XmEntity source = new XmEntity().typeKey("SOURCE");
source.targets(Collections.singleton(new Link().typeKey("LINK1").source(source).target(target))).setId(1L);
target.targets(Collections.singleton(new Link().typeKey("LINK2").source(source).target(target))).setId(2L);
String targetJson = jacksonMessageConverter.getObjectMapper().writeValueAsString(target);
String sourceJson = jacksonMessageConverter.getObjectMapper().writeValueAsString(source);
assertEquals("1", JsonPath.read(targetJson, "$.targets[0].id"));
assertEquals("2", JsonPath.read(sourceJson, "$.targets[0].id"));
}
use of com.icthh.xm.ms.entity.domain.Link in project xm-ms-entity by xm-online.
the class LinkResourceExtendedIntTest method createLinkWithEntryDate.
@Test
@Transactional
public void createLinkWithEntryDate() throws Exception {
int databaseSizeBeforeCreate = linkRepository.findAll().size();
// Create the Link
restLinkMockMvc.perform(post("/api/links").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(link))).andExpect(status().isCreated()).andExpect(jsonPath("$.startDate").value(MOCKED_START_DATE.toString()));
// Validate the Link in the database
List<Link> voteList = linkRepository.findAll();
assertThat(voteList).hasSize(databaseSizeBeforeCreate + 1);
Link testLink = voteList.get(voteList.size() - 1);
assertThat(testLink.getStartDate()).isEqualTo(MOCKED_START_DATE);
// Validate the Link in Elasticsearch
Link linkEs = linkSearchRepository.findOne(testLink.getId());
assertThat(linkEs).isEqualToComparingFieldByField(testLink);
}
use of com.icthh.xm.ms.entity.domain.Link in project xm-ms-entity by xm-online.
the class LinkResourceExtendedIntTest method checkStartDateIsRequiredInDb.
@Test
@Transactional
public void checkStartDateIsRequiredInDb() throws Exception {
Link o = linkService.save(link);
// set the field null
when(startUpdateDateGenerationStrategy.generateStartDate()).thenReturn(null);
o.setStartDate(null);
linkService.save(o);
try {
linkRepository.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.Link in project xm-ms-entity by xm-online.
the class LinkResourceExtendedIntTest method checkStartDateIsNotRequired.
@Test
@Transactional
public void checkStartDateIsNotRequired() throws Exception {
int databaseSizeBeforeTest = linkRepository.findAll().size();
// set the field null
link.setStartDate(null);
// Create the Link.
restLinkMockMvc.perform(post("/api/links").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(link))).andExpect(status().isCreated()).andExpect(jsonPath("$.startDate").value(MOCKED_START_DATE.toString()));
List<Link> linkList = linkRepository.findAll();
assertThat(linkList).hasSize(databaseSizeBeforeTest + 1);
Link testLink = linkList.get(linkList.size() - 1);
assertThat(testLink.getStartDate()).isEqualTo(MOCKED_START_DATE);
// Validate the Link in Elasticsearch
Link linkEs = linkSearchRepository.findOne(testLink.getId());
assertThat(linkEs).isEqualToComparingFieldByField(testLink);
}
use of com.icthh.xm.ms.entity.domain.Link in project xm-ms-entity by xm-online.
the class LinkResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Link.class);
Link link1 = new Link();
link1.setId(1L);
Link link2 = new Link();
link2.setId(link1.getId());
assertThat(link1).isEqualTo(link2);
link2.setId(2L);
assertThat(link1).isNotEqualTo(link2);
link1.setId(null);
assertThat(link1).isNotEqualTo(link2);
}
Aggregations