Search in sources :

Example 1 with Participation

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

the class GitServiceIntTest method testGetOrCheckoutRepositoryForExistingRepo.

@Test
public void testGetOrCheckoutRepositoryForExistingRepo() throws IOException, GitAPIException {
    Participation participation = new Participation();
    participation.setRepositoryUrl(remoteTestRepo);
    Repository repo = gitService.getOrCheckoutRepository(participation);
    Repository repo2 = gitService.getOrCheckoutRepository(participation);
    assertThat(repo.getDirectory()).isEqualTo(repo2.getDirectory());
    assertThat(repo2.getBranch()).isEqualTo("master");
    assertThat(repo2.getDirectory()).exists();
    gitService.deleteLocalRepository(repo2);
}
Also used : Participation(de.tum.in.www1.artemis.domain.Participation) Repository(de.tum.in.www1.artemis.domain.Repository) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Participation

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

the class GitServiceIntTest method testDeleteLocalRepository.

@Test
public void testDeleteLocalRepository() throws IOException, GitAPIException {
    Participation participation = new Participation();
    participation.setRepositoryUrl(remoteTestRepo);
    Repository repo = gitService.getOrCheckoutRepository(participation);
    assertThat(repo.getDirectory()).exists();
    gitService.deleteLocalRepository(repo);
    assertThat(repo.getDirectory()).doesNotExist();
}
Also used : Participation(de.tum.in.www1.artemis.domain.Participation) Repository(de.tum.in.www1.artemis.domain.Repository) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with Participation

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

the class GitServiceIntTest method testListFiles.

@Test
public void testListFiles() throws IOException, GitAPIException {
    Participation participation = new Participation();
    participation.setRepositoryUrl(remoteTestRepo);
    Repository repo = gitService.getOrCheckoutRepository(participation);
    Collection<de.tum.in.www1.artemis.domain.File> files = gitService.listFiles(repo);
    assertThat(files.size()).isGreaterThan(0);
    gitService.deleteLocalRepository(repo);
}
Also used : Participation(de.tum.in.www1.artemis.domain.Participation) Repository(de.tum.in.www1.artemis.domain.Repository) File(java.io.File) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with Participation

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

the class LtiServiceIntTest method assertThatUnsuccessfulResultWithoutTextReturnsZeroScore.

@Test
public void assertThatUnsuccessfulResultWithoutTextReturnsZeroScore() {
    Participation participation = new Participation();
    participationRepository.save(participation);
    Result result = new Result();
    result.setParticipation(participation);
    result.setSuccessful(false);
    resultRepository.save(result);
    // String score = ltiService.getScoreForParticipation(participation);
    // assertThat(score).isEqualTo("0.00");
    // cleanup
    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 5 with Participation

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

the class LtiServiceIntTest method assertThatSuccessfulResultReturnsFullScore.

@Test
public void assertThatSuccessfulResultReturnsFullScore() {
    Participation participation = new Participation();
    participationRepository.save(participation);
    Result result = new Result();
    result.setParticipation(participation);
    result.setSuccessful(true);
    resultRepository.save(result);
    // String score = ltiService.getScoreForParticipation(participation);
    // assertThat(score).isEqualTo("1.00");
    // cleanup
    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)

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