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);
}
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);
}
Aggregations