Search in sources :

Example 21 with de.tum.in.www1.artemis.domain.participation

use of de.tum.in.www1.artemis.domain.participation 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 22 with de.tum.in.www1.artemis.domain.participation

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

the class ParticipationResourceIntTest method createParticipation.

@Test
@Transactional
public void createParticipation() throws Exception {
    int databaseSizeBeforeCreate = participationRepository.findAll().size();
    // Create the Participation
    restParticipationMockMvc.perform(post("/api/participations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(participation))).andExpect(status().isCreated());
    // Validate the Participation in the database
    List<Participation> participationList = participationRepository.findAll();
    assertThat(participationList).hasSize(databaseSizeBeforeCreate + 1);
    Participation testParticipation = participationList.get(participationList.size() - 1);
    assertThat(testParticipation.getRepositoryUrl()).isEqualTo(DEFAULT_REPOSITORY_URL);
    assertThat(testParticipation.getBuildPlanId()).isEqualTo(DEFAULT_BUILD_PLAN_ID);
    assertThat(testParticipation.getInitializationState()).isEqualTo(DEFAULT_INITIALIZATION_STATE);
    assertThat(testParticipation.getInitializationDate()).isEqualTo(DEFAULT_INITIALIZATION_DATE);
}
Also used : Participation(de.tum.in.www1.artemis.domain.Participation) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with de.tum.in.www1.artemis.domain.participation

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

the class ParticipationResourceIntTest method equalsVerifier.

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

Example 24 with de.tum.in.www1.artemis.domain.participation

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

the class ParticipationResourceIntTest method updateParticipation.

@Test
@Transactional
public void updateParticipation() throws Exception {
    // Initialize the database
    participationService.save(participation);
    int databaseSizeBeforeUpdate = participationRepository.findAll().size();
    // Update the participation
    Participation updatedParticipation = participationRepository.findOne(participation.getId());
    updatedParticipation.repositoryUrl(UPDATED_REPOSITORY_URL).buildPlanId(UPDATED_BUILD_PLAN_ID).initializationState(UPDATED_INITIALIZATION_STATE).initializationDate(UPDATED_INITIALIZATION_DATE);
    restParticipationMockMvc.perform(put("/api/participations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedParticipation))).andExpect(status().isOk());
    // Validate the Participation in the database
    List<Participation> participationList = participationRepository.findAll();
    assertThat(participationList).hasSize(databaseSizeBeforeUpdate);
    Participation testParticipation = participationList.get(participationList.size() - 1);
    assertThat(testParticipation.getRepositoryUrl()).isEqualTo(UPDATED_REPOSITORY_URL);
    assertThat(testParticipation.getBuildPlanId()).isEqualTo(UPDATED_BUILD_PLAN_ID);
    assertThat(testParticipation.getInitializationState()).isEqualTo(UPDATED_INITIALIZATION_STATE);
    assertThat(testParticipation.getInitializationDate()).isEqualTo(UPDATED_INITIALIZATION_DATE);
}
Also used : Participation(de.tum.in.www1.artemis.domain.Participation) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Participation (de.tum.in.www1.artemis.domain.Participation)14 Test (org.junit.Test)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)14 Repository (de.tum.in.www1.artemis.domain.Repository)7 Transactional (org.springframework.transaction.annotation.Transactional)7 Result (de.tum.in.www1.artemis.domain.Result)5 Timed (com.codahale.metrics.annotation.Timed)4 BadRequestAlertException (de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException)4 URI (java.net.URI)4 ResponseEntity (org.springframework.http.ResponseEntity)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)3 de.tum.in.www1.artemis.service (de.tum.in.www1.artemis.service)3 HeaderUtil (de.tum.in.www1.artemis.web.rest.util.HeaderUtil)3 URISyntaxException (java.net.URISyntaxException)3 URL (java.net.URL)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 HttpStatus (org.springframework.http.HttpStatus)3 Authentication (org.springframework.security.core.Authentication)3