Search in sources :

Example 31 with Result

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

the class LtiServiceIntTest method assertThatMultipleResultsReturnLatestScore.

@Test
public void assertThatMultipleResultsReturnLatestScore() {
    Participation participation = new Participation();
    participationRepository.save(participation);
    Result oldResult = new Result();
    oldResult.setParticipation(participation);
    oldResult.setSuccessful(false);
    oldResult.setCompletionDate(ZonedDateTime.now().minusHours(1));
    oldResult.setResultString("2 of 4 failed");
    resultRepository.save(oldResult);
    Result result = new Result();
    result.setParticipation(participation);
    result.setSuccessful(false);
    result.setCompletionDate(ZonedDateTime.now());
    result.setResultString("1 of 4 failed");
    resultRepository.save(result);
    // String score = ltiService.getScoreForParticipation(participation);
    // assertThat(score).isEqualTo("0.75");
    // cleanup
    resultRepository.delete(oldResult);
    resultRepository.delete(result);
    participationRepository.delete(participation);
}
Also used : Participation(de.tum.in.www1.artemis.domain.Participation) Result(de.tum.in.www1.artemis.domain.Result) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 32 with Result

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

the class ResultResourceIntTest method updateResult.

@Test
@Transactional
public void updateResult() throws Exception {
    // Initialize the database
    resultRepository.saveAndFlush(result);
    int databaseSizeBeforeUpdate = resultRepository.findAll().size();
    // Update the result
    Result updatedResult = resultRepository.findOne(result.getId());
    // Disconnect from session so that the updates on updatedResult are not directly saved in db
    em.detach(updatedResult);
    updatedResult.resultString(UPDATED_RESULT_STRING).completionDate(UPDATED_COMPLETION_DATE).successful(UPDATED_SUCCESSFUL).buildArtifact(UPDATED_BUILD_ARTIFACT).score(UPDATED_SCORE).rated(UPDATED_RATED).hasFeedback(UPDATED_HAS_FEEDBACK);
    restResultMockMvc.perform(put("/api/results").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedResult))).andExpect(status().isOk());
    // Validate the Result in the database
    List<Result> resultList = resultRepository.findAll();
    assertThat(resultList).hasSize(databaseSizeBeforeUpdate);
    Result testResult = resultList.get(resultList.size() - 1);
    assertThat(testResult.getResultString()).isEqualTo(UPDATED_RESULT_STRING);
    assertThat(testResult.getCompletionDate()).isEqualTo(UPDATED_COMPLETION_DATE);
    assertThat(testResult.isSuccessful()).isEqualTo(UPDATED_SUCCESSFUL);
    assertThat(testResult.isBuildArtifact()).isEqualTo(UPDATED_BUILD_ARTIFACT);
    assertThat(testResult.getScore()).isEqualTo(UPDATED_SCORE);
    assertThat(testResult.isRated()).isEqualTo(UPDATED_RATED);
    assertThat(testResult.getHasFeedback()).isEqualTo(UPDATED_HAS_FEEDBACK);
}
Also used : Result(de.tum.in.www1.artemis.domain.Result) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)15 URI (java.net.URI)10 Result (de.tum.in.www1.artemis.domain.Result)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)8 Test (org.junit.Test)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 BadRequestAlertException (de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException)6 RestTemplate (org.springframework.web.client.RestTemplate)6 MalformedURLException (java.net.MalformedURLException)5 Transactional (org.springframework.transaction.annotation.Transactional)5 Participation (de.tum.in.www1.artemis.domain.Participation)4 BambooException (de.tum.in.www1.artemis.exception.BambooException)4 GitException (de.tum.in.www1.artemis.exception.GitException)4 HeaderUtil (de.tum.in.www1.artemis.web.rest.util.HeaderUtil)4 IOException (java.io.IOException)4 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)4 HttpEntity (org.springframework.http.HttpEntity)4 HttpHeaders (org.springframework.http.HttpHeaders)4 ResponseEntity (org.springframework.http.ResponseEntity)4 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)3