use of io.github.jhipster.sample.service.dto.LabelDTO in project jhipster-sample-app-dto by jhipster.
the class LabelResourceIntTest method createLabel.
@Test
@Transactional
public void createLabel() throws Exception {
int databaseSizeBeforeCreate = labelRepository.findAll().size();
// Create the Label
LabelDTO labelDTO = labelMapper.toDto(label);
restLabelMockMvc.perform(post("/api/labels").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(labelDTO))).andExpect(status().isCreated());
// Validate the Label in the database
List<Label> labelList = labelRepository.findAll();
assertThat(labelList).hasSize(databaseSizeBeforeCreate + 1);
Label testLabel = labelList.get(labelList.size() - 1);
assertThat(testLabel.getLabel()).isEqualTo(DEFAULT_LABEL);
}
use of io.github.jhipster.sample.service.dto.LabelDTO in project jhipster-sample-app-dto by jhipster.
the class LabelResourceIntTest method dtoEqualsVerifier.
@Test
@Transactional
public void dtoEqualsVerifier() throws Exception {
TestUtil.equalsVerifier(LabelDTO.class);
LabelDTO labelDTO1 = new LabelDTO();
labelDTO1.setId(1L);
LabelDTO labelDTO2 = new LabelDTO();
assertThat(labelDTO1).isNotEqualTo(labelDTO2);
labelDTO2.setId(labelDTO1.getId());
assertThat(labelDTO1).isEqualTo(labelDTO2);
labelDTO2.setId(2L);
assertThat(labelDTO1).isNotEqualTo(labelDTO2);
labelDTO1.setId(null);
assertThat(labelDTO1).isNotEqualTo(labelDTO2);
}
use of io.github.jhipster.sample.service.dto.LabelDTO in project jhipster-sample-app-dto by jhipster.
the class LabelResource method createLabel.
/**
* POST /labels : Create a new label.
*
* @param labelDTO the labelDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new labelDTO, or with status 400 (Bad Request) if the label has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/labels")
@Timed
public ResponseEntity<LabelDTO> createLabel(@Valid @RequestBody LabelDTO labelDTO) throws URISyntaxException {
log.debug("REST request to save Label : {}", labelDTO);
if (labelDTO.getId() != null) {
throw new BadRequestAlertException("A new label cannot already have an ID", ENTITY_NAME, "idexists");
}
Label label = labelMapper.toEntity(labelDTO);
label = labelRepository.save(label);
LabelDTO result = labelMapper.toDto(label);
return ResponseEntity.created(new URI("/api/labels/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Aggregations