use of com.arnaugarcia.uplace.domain.Company in project uplace.es by Uplace.
the class CompanyResourceIntTest method createCompany.
@Test
@Transactional
public void createCompany() throws Exception {
int databaseSizeBeforeCreate = companyRepository.findAll().size();
// Create the Company
restCompanyMockMvc.perform(post("/api/companies").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(company))).andExpect(status().isCreated());
// Validate the Company in the database
List<Company> companyList = companyRepository.findAll();
assertThat(companyList).hasSize(databaseSizeBeforeCreate + 1);
Company testCompany = companyList.get(companyList.size() - 1);
assertThat(testCompany.getName()).isEqualTo(DEFAULT_NAME);
assertThat(testCompany.getPhoto()).isEqualTo(DEFAULT_PHOTO);
assertThat(testCompany.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
assertThat(testCompany.getNif()).isEqualTo(DEFAULT_NIF);
}
use of com.arnaugarcia.uplace.domain.Company in project uplace.es by Uplace.
the class CompanyResource method updateCompany.
/**
* PUT /companies : Updates an existing company.
*
* @param company the company to update
* @return the ResponseEntity with status 200 (OK) and with body the updated company,
* or with status 400 (Bad Request) if the company is not valid,
* or with status 500 (Internal Server Error) if the company couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/company")
@Timed
public ResponseEntity<Company> updateCompany(@RequestBody Company company) throws URISyntaxException {
log.debug("REST request to update Company : {}", company);
if (company.getId() == null) {
return createCompany(company);
}
Company result = companyService.save(company);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, company.getId().toString())).body(result);
}
use of com.arnaugarcia.uplace.domain.Company in project uplace.es by Uplace.
the class CompanyResource method createCompany.
/**
* POST /companies : Create a new company.
*
* @param company the company to create
* @return the ResponseEntity with status 201 (Created) and with body the new company, or with status 400 (Bad Request) if the company has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/company")
@Timed
public ResponseEntity<Company> createCompany(@RequestBody Company company) throws URISyntaxException {
log.debug("REST request to save Company : {}", company);
if (company.getId() != null) {
throw new BadRequestAlertException("A new company cannot already have an ID", ENTITY_NAME, "idexists");
}
Company result = companyService.save(company);
return ResponseEntity.created(new URI("/api/companies/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.arnaugarcia.uplace.domain.Company in project uplace.es by Uplace.
the class CompanyResourceIntTest method updateCompany.
@Test
@Transactional
public void updateCompany() throws Exception {
// Initialize the database
companyService.save(company);
int databaseSizeBeforeUpdate = companyRepository.findAll().size();
// Update the company
Company updatedCompany = companyRepository.findOne(company.getId());
// Disconnect from session so that the updates on updatedCompany are not directly saved in db
em.detach(updatedCompany);
updatedCompany.name(UPDATED_NAME).photo(UPDATED_PHOTO).description(UPDATED_DESCRIPTION).nif(UPDATED_NIF);
restCompanyMockMvc.perform(put("/api/companies").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedCompany))).andExpect(status().isOk());
// Validate the Company in the database
List<Company> companyList = companyRepository.findAll();
assertThat(companyList).hasSize(databaseSizeBeforeUpdate);
Company testCompany = companyList.get(companyList.size() - 1);
assertThat(testCompany.getName()).isEqualTo(UPDATED_NAME);
assertThat(testCompany.getPhoto()).isEqualTo(UPDATED_PHOTO);
assertThat(testCompany.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
assertThat(testCompany.getNif()).isEqualTo(UPDATED_NIF);
}
use of com.arnaugarcia.uplace.domain.Company in project uplace.es by Uplace.
the class CompanyResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Company.class);
Company company1 = new Company();
company1.setId(1L);
Company company2 = new Company();
company2.setId(company1.getId());
assertThat(company1).isEqualTo(company2);
company2.setId(2L);
assertThat(company1).isNotEqualTo(company2);
company1.setId(null);
assertThat(company1).isNotEqualTo(company2);
}
Aggregations