use of io.github.jhipster.sample.domain.Label in project jhipster-sample-app-hazelcast by jhipster.
the class LabelResource method updateLabel.
/**
* PUT /labels : Updates an existing label.
*
* @param label the label to update
* @return the ResponseEntity with status 200 (OK) and with body the updated label,
* or with status 400 (Bad Request) if the label is not valid,
* or with status 500 (Internal Server Error) if the label couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/labels")
@Timed
public ResponseEntity<Label> updateLabel(@Valid @RequestBody Label label) throws URISyntaxException {
log.debug("REST request to update Label : {}", label);
if (label.getId() == null) {
return createLabel(label);
}
Label result = labelRepository.save(label);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, label.getId().toString())).body(result);
}
use of io.github.jhipster.sample.domain.Label in project jhipster-sample-app-elasticsearch by jhipster.
the class LabelResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Label.class);
Label label1 = new Label();
label1.setId(1L);
Label label2 = new Label();
label2.setId(label1.getId());
assertThat(label1).isEqualTo(label2);
label2.setId(2L);
assertThat(label1).isNotEqualTo(label2);
label1.setId(null);
assertThat(label1).isNotEqualTo(label2);
}
use of io.github.jhipster.sample.domain.Label in project jhipster-sample-app-elasticsearch by jhipster.
the class LabelResourceIntTest 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 Label createEntity(EntityManager em) {
Label label = new Label();
label.setLabel(DEFAULT_LABEL);
return label;
}
use of io.github.jhipster.sample.domain.Label in project jhipster-sample-app-elasticsearch by jhipster.
the class LabelResourceIntTest method updateLabel.
@Test
@Transactional
public void updateLabel() throws Exception {
// Initialize the database
labelRepository.saveAndFlush(label);
int databaseSizeBeforeUpdate = labelRepository.findAll().size();
// Update the label
Label updatedLabel = labelRepository.findById(label.getId()).get();
// Disconnect from session so that the updates on updatedLabel are not directly saved in db
em.detach(updatedLabel);
updatedLabel.setLabel(UPDATED_LABEL);
restLabelMockMvc.perform(put("/api/labels").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedLabel))).andExpect(status().isOk());
// Validate the Label in the database
List<Label> labelList = labelRepository.findAll();
assertThat(labelList).hasSize(databaseSizeBeforeUpdate);
Label testLabel = labelList.get(labelList.size() - 1);
assertThat(testLabel.getLabel()).isEqualTo(UPDATED_LABEL);
// Validate the Label in Elasticsearch
verify(mockLabelSearchRepository, times(1)).save(testLabel);
}
use of io.github.jhipster.sample.domain.Label in project jhipster-sample-app-elasticsearch by jhipster.
the class LabelResourceIntTest method createLabel.
@Test
@Transactional
public void createLabel() throws Exception {
int databaseSizeBeforeCreate = labelRepository.findAll().size();
// Create the Label
restLabelMockMvc.perform(post("/api/labels").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(label))).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);
// Validate the Label in Elasticsearch
verify(mockLabelSearchRepository, times(1)).save(testLabel);
}
Aggregations