Search in sources :

Example 1 with Achievement

use of com.furyviewer.domain.Achievement in project FuryViewer by TheDoctor-95.

the class AchievementResource method getAchievement.

/**
 * GET  /achievements/:id : get the "id" achievement.
 *
 * @param id the id of the achievement to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the achievement, or with status 404 (Not Found)
 */
@GetMapping("/achievements/{id}")
@Timed
public ResponseEntity<Achievement> getAchievement(@PathVariable Long id) {
    log.debug("REST request to get Achievement : {}", id);
    Achievement achievement = achievementRepository.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(achievement));
}
Also used : Achievement(com.furyviewer.domain.Achievement) Timed(com.codahale.metrics.annotation.Timed)

Example 2 with Achievement

use of com.furyviewer.domain.Achievement in project FuryViewer by TheDoctor-95.

the class AchievementResource method createAchievement.

/**
 * POST  /achievements : Create a new achievement.
 *
 * @param achievement the achievement to create
 * @return the ResponseEntity with status 201 (Created) and with body the new achievement, or with status 400 (Bad Request) if the achievement has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/achievements")
@Timed
public ResponseEntity<Achievement> createAchievement(@RequestBody Achievement achievement) throws URISyntaxException {
    log.debug("REST request to save Achievement : {}", achievement);
    if (achievement.getId() != null) {
        throw new BadRequestAlertException("A new achievement cannot already have an ID", ENTITY_NAME, "idexists");
    }
    Achievement result = achievementRepository.save(achievement);
    return ResponseEntity.created(new URI("/api/achievements/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) Achievement(com.furyviewer.domain.Achievement) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with Achievement

use of com.furyviewer.domain.Achievement in project FuryViewer by TheDoctor-95.

the class AchievementResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(Achievement.class);
    Achievement achievement1 = new Achievement();
    achievement1.setId(1L);
    Achievement achievement2 = new Achievement();
    achievement2.setId(achievement1.getId());
    assertThat(achievement1).isEqualTo(achievement2);
    achievement2.setId(2L);
    assertThat(achievement1).isNotEqualTo(achievement2);
    achievement1.setId(null);
    assertThat(achievement1).isNotEqualTo(achievement2);
}
Also used : Achievement(com.furyviewer.domain.Achievement) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Achievement

use of com.furyviewer.domain.Achievement in project FuryViewer by TheDoctor-95.

the class AchievementResourceIntTest method createAchievement.

@Test
@Transactional
public void createAchievement() throws Exception {
    int databaseSizeBeforeCreate = achievementRepository.findAll().size();
    // Create the Achievement
    restAchievementMockMvc.perform(post("/api/achievements").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(achievement))).andExpect(status().isCreated());
    // Validate the Achievement in the database
    List<Achievement> achievementList = achievementRepository.findAll();
    assertThat(achievementList).hasSize(databaseSizeBeforeCreate + 1);
    Achievement testAchievement = achievementList.get(achievementList.size() - 1);
    assertThat(testAchievement.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testAchievement.getAmount()).isEqualTo(DEFAULT_AMOUNT);
    assertThat(testAchievement.getAchievementType()).isEqualTo(DEFAULT_ACHIEVEMENT_TYPE);
    assertThat(testAchievement.getEntity()).isEqualTo(DEFAULT_ENTITY);
    assertThat(testAchievement.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
    assertThat(testAchievement.getImg()).isEqualTo(DEFAULT_IMG);
    assertThat(testAchievement.getImgContentType()).isEqualTo(DEFAULT_IMG_CONTENT_TYPE);
}
Also used : Achievement(com.furyviewer.domain.Achievement) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Achievement

use of com.furyviewer.domain.Achievement in project FuryViewer by TheDoctor-95.

the class AchievementResourceIntTest method updateAchievement.

@Test
@Transactional
public void updateAchievement() throws Exception {
    // Initialize the database
    achievementRepository.saveAndFlush(achievement);
    int databaseSizeBeforeUpdate = achievementRepository.findAll().size();
    // Update the achievement
    Achievement updatedAchievement = achievementRepository.findOne(achievement.getId());
    updatedAchievement.name(UPDATED_NAME).amount(UPDATED_AMOUNT).achievementType(UPDATED_ACHIEVEMENT_TYPE).entity(UPDATED_ENTITY).description(UPDATED_DESCRIPTION).img(UPDATED_IMG).imgContentType(UPDATED_IMG_CONTENT_TYPE);
    restAchievementMockMvc.perform(put("/api/achievements").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedAchievement))).andExpect(status().isOk());
    // Validate the Achievement in the database
    List<Achievement> achievementList = achievementRepository.findAll();
    assertThat(achievementList).hasSize(databaseSizeBeforeUpdate);
    Achievement testAchievement = achievementList.get(achievementList.size() - 1);
    assertThat(testAchievement.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testAchievement.getAmount()).isEqualTo(UPDATED_AMOUNT);
    assertThat(testAchievement.getAchievementType()).isEqualTo(UPDATED_ACHIEVEMENT_TYPE);
    assertThat(testAchievement.getEntity()).isEqualTo(UPDATED_ENTITY);
    assertThat(testAchievement.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
    assertThat(testAchievement.getImg()).isEqualTo(UPDATED_IMG);
    assertThat(testAchievement.getImgContentType()).isEqualTo(UPDATED_IMG_CONTENT_TYPE);
}
Also used : Achievement(com.furyviewer.domain.Achievement) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Achievement (com.furyviewer.domain.Achievement)6 Timed (com.codahale.metrics.annotation.Timed)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (org.springframework.transaction.annotation.Transactional)3 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1