Search in sources :

Example 1 with LtiUserId

use of de.tum.in.www1.artemis.domain.LtiUserId in project ArTEMiS by ls1intum.

the class LtiUserIdResourceIntTest method createLtiUserId.

@Test
@Transactional
public void createLtiUserId() throws Exception {
    int databaseSizeBeforeCreate = ltiUserIdRepository.findAll().size();
    // Create the LtiUserId
    restLtiUserIdMockMvc.perform(post("/api/lti-user-ids").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(ltiUserId))).andExpect(status().isCreated());
    // Validate the LtiUserId in the database
    List<LtiUserId> ltiUserIdList = ltiUserIdRepository.findAll();
    assertThat(ltiUserIdList).hasSize(databaseSizeBeforeCreate + 1);
    LtiUserId testLtiUserId = ltiUserIdList.get(ltiUserIdList.size() - 1);
    assertThat(testLtiUserId.getLtiUserId()).isEqualTo(DEFAULT_LTI_USER_ID);
}
Also used : LtiUserId(de.tum.in.www1.artemis.domain.LtiUserId) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with LtiUserId

use of de.tum.in.www1.artemis.domain.LtiUserId in project ArTEMiS by ls1intum.

the class LtiUserIdResource method getLtiUserId.

// Deactivated because it would load all lti user ids and overload the server
// TODO: activate this call again using the infinite scroll page mechanism
// /**
// * GET  /lti-user-ids : get all the ltiUserIds.
// *
// * @return the ResponseEntity with status 200 (OK) and the list of ltiUserIds in body
// */
// @GetMapping("/lti-user-ids")
// @Timed
// public List<LtiUserId> getAllLtiUserIds() {
// log.debug("REST request to get all LtiUserIds");
// return ltiUserIdRepository.findAll();
// }
/**
 * GET  /lti-user-ids/:id : get the "id" ltiUserId.
 *
 * @param id the id of the ltiUserId to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the ltiUserId, or with status 404 (Not Found)
 */
@GetMapping("/lti-user-ids/{id}")
@Timed
public ResponseEntity<LtiUserId> getLtiUserId(@PathVariable Long id) {
    log.debug("REST request to get LtiUserId : {}", id);
    LtiUserId ltiUserId = ltiUserIdRepository.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(ltiUserId));
}
Also used : LtiUserId(de.tum.in.www1.artemis.domain.LtiUserId) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with LtiUserId

use of de.tum.in.www1.artemis.domain.LtiUserId in project ArTEMiS by ls1intum.

the class LtiUserIdResource method createLtiUserId.

/**
 * POST  /lti-user-ids : Create a new ltiUserId.
 *
 * @param ltiUserId the ltiUserId to create
 * @return the ResponseEntity with status 201 (Created) and with body the new ltiUserId, or with status 400 (Bad Request) if the ltiUserId has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/lti-user-ids")
@Timed
public ResponseEntity<LtiUserId> createLtiUserId(@RequestBody LtiUserId ltiUserId) throws URISyntaxException {
    log.debug("REST request to save LtiUserId : {}", ltiUserId);
    if (ltiUserId.getId() != null) {
        return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "idexists", "A new ltiUserId cannot already have an ID")).body(null);
    }
    LtiUserId result = ltiUserIdRepository.save(ltiUserId);
    return ResponseEntity.created(new URI("/api/lti-user-ids/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : LtiUserId(de.tum.in.www1.artemis.domain.LtiUserId) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 4 with LtiUserId

use of de.tum.in.www1.artemis.domain.LtiUserId in project ArTEMiS by ls1intum.

the class LtiUserIdResource method updateLtiUserId.

/**
 * PUT  /lti-user-ids : Updates an existing ltiUserId.
 *
 * @param ltiUserId the ltiUserId to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated ltiUserId,
 * or with status 400 (Bad Request) if the ltiUserId is not valid,
 * or with status 500 (Internal Server Error) if the ltiUserId couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/lti-user-ids")
@Timed
public ResponseEntity<LtiUserId> updateLtiUserId(@RequestBody LtiUserId ltiUserId) throws URISyntaxException {
    log.debug("REST request to update LtiUserId : {}", ltiUserId);
    if (ltiUserId.getId() == null) {
        return createLtiUserId(ltiUserId);
    }
    LtiUserId result = ltiUserIdRepository.save(ltiUserId);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, ltiUserId.getId().toString())).body(result);
}
Also used : LtiUserId(de.tum.in.www1.artemis.domain.LtiUserId) Timed(com.codahale.metrics.annotation.Timed)

Example 5 with LtiUserId

use of de.tum.in.www1.artemis.domain.LtiUserId in project ArTEMiS by ls1intum.

the class LtiUserIdResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(LtiUserId.class);
    LtiUserId ltiUserId1 = new LtiUserId();
    ltiUserId1.setId(1L);
    LtiUserId ltiUserId2 = new LtiUserId();
    ltiUserId2.setId(ltiUserId1.getId());
    assertThat(ltiUserId1).isEqualTo(ltiUserId2);
    ltiUserId2.setId(2L);
    assertThat(ltiUserId1).isNotEqualTo(ltiUserId2);
    ltiUserId1.setId(null);
    assertThat(ltiUserId1).isNotEqualTo(ltiUserId2);
}
Also used : LtiUserId(de.tum.in.www1.artemis.domain.LtiUserId) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

LtiUserId (de.tum.in.www1.artemis.domain.LtiUserId)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 URI (java.net.URI)1