Skip to content

Commit

Permalink
Feature/Programming Exercise/Sequential test runs (ls1intum#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
thilo-behnke authored and Stephan Krusche committed Jul 2, 2019
1 parent ddb5d3f commit 785a4ca
Show file tree
Hide file tree
Showing 95 changed files with 2,068 additions and 449 deletions.
4 changes: 4 additions & 0 deletions .jhipster/ProgrammingExercise.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
{
"fieldName": "packageName",
"fieldType": "String"
},
{
"fieldName": "sequentialTestRuns",
"fieldType": "Boolean"
}
],
"relationships": [
Expand Down
38 changes: 38 additions & 0 deletions .jhipster/ProgrammingExerciseTestCase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"fluentMethods": true,
"clientRootFolder": "",
"relationships": [
{
"relationshipName": "exercise",
"otherEntityName": "exercise",
"relationshipType": "many-to-one",
"relationshipValidateRules": [],
"otherEntityField": "id"
}
],
"fields": [
{
"fieldName": "testName",
"fieldType": "String",
"fieldValidateRules": []
},
{
"fieldName": "weight",
"fieldType": "Integer",
"fieldValidateRules": []
},
{
"fieldName": "active",
"fieldType": "Boolean",
"fieldValidateRules": []
}
],
"changelogDate": "20190526152122",
"dto": "no",
"searchEngine": false,
"service": "yes",
"entityTableName": "programming_exercise_test_case",
"databaseType": "sql",
"jpaMetamodelFiltering": false,
"pagination": "no"
}
242 changes: 123 additions & 119 deletions src/main/java/de/tum/in/www1/artemis/config/CacheConfiguration.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Objects;
import java.util.*;

import javax.persistence.*;

Expand Down Expand Up @@ -42,6 +42,9 @@ public class ProgrammingExercise extends Exercise implements Serializable {
@Column(name = "package_name")
private String packageName;

@Column(name = "sequential_test_runs")
private Boolean sequentialTestRuns;

@OneToOne(cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(unique = true)
@JsonIgnoreProperties("exercise")
Expand All @@ -52,6 +55,10 @@ public class ProgrammingExercise extends Exercise implements Serializable {
@JsonIgnoreProperties("exercise")
private Participation solutionParticipation;

@OneToMany(mappedBy = "exercise", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.LAZY)
@JsonIgnoreProperties("exercise")
private Set<ProgrammingExerciseTestCase> testCases = new HashSet<>();

// jhipster-needle-entity-add-field - Jhipster will add fields here, do not remove
@JsonIgnore // we now store it in templateParticipation --> this is just a convenience getter
public String getTemplateRepositoryUrl() {
Expand Down Expand Up @@ -236,6 +243,11 @@ public URL getTestRepositoryUrlAsUrl() {
return null;
}

@JsonIgnore
public boolean isParticipationSolutionParticipationOfThisExercise(Participation participation) {
return this.getSolutionParticipation() != null && this.getSolutionParticipation().getId().equals(participation.getId());
}

@JsonIgnore
public String getProjectKey() {
// this is the key used for Bitbucket and Bamboo
Expand All @@ -254,6 +266,25 @@ public String getPackageFolderName() {
return getPackageName().replace(".", "/");
}

public Set<ProgrammingExerciseTestCase> getTestCases() {
return testCases;
}

public void setTestCases(Set<ProgrammingExerciseTestCase> testCases) {
this.testCases = testCases;
}

public Boolean hasSequentialTestRuns() {
if (sequentialTestRuns == null) {
return false;
}
return sequentialTestRuns;
}

public void setSequentialTestRuns(Boolean sequentialTestRuns) {
this.sequentialTestRuns = sequentialTestRuns;
}

/**
* set all sensitive information to null, so no info with respect to the solution gets leaked to students through json
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package de.tum.in.www1.artemis.domain;

import java.io.Serializable;
import java.util.Objects;

import javax.persistence.*;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
* A ProgrammingExerciseTestCase.
*/
@Entity
@Table(name = "programming_exercise_test_case")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ProgrammingExerciseTestCase implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "test_name")
private String testName;

@Column(name = "weight")
private Integer weight;

@Column(name = "active")
private Boolean active;

@ManyToOne(fetch = FetchType.LAZY)
@JsonIgnoreProperties("programmingExerciseTestCase")
private ProgrammingExercise exercise;

// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public ProgrammingExerciseTestCase id(Long id) {
this.id = id;
return this;
}

public String getTestName() {
return testName;
}

public ProgrammingExerciseTestCase testName(String testName) {
this.testName = testName;
return this;
}

public void setTestName(String testName) {
this.testName = testName;
}

public Integer getWeight() {
return weight;
}

public ProgrammingExerciseTestCase weight(Integer weight) {
this.weight = weight;
return this;
}

public void setWeight(Integer weight) {
this.weight = weight;
}

public Boolean isActive() {
return active;
}

public ProgrammingExerciseTestCase active(Boolean active) {
this.active = active;
return this;
}

public void setActive(Boolean active) {
this.active = active;
}

public Exercise getExercise() {
return exercise;
}

public ProgrammingExerciseTestCase exercise(ProgrammingExercise exercise) {
this.exercise = exercise;
return this;
}

public void setExercise(ProgrammingExercise exercise) {
this.exercise = exercise;
}

// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

/**
* This method needs to be checked and updated if there is a new class attribute. Creates a clone with all attributes set to the value of the object, including the id.
*
* @return a clone of the object.
*/
public ProgrammingExerciseTestCase clone() {
ProgrammingExerciseTestCase clone = new ProgrammingExerciseTestCase().testName(this.getTestName()).weight(this.getWeight()).active(this.isActive()).exercise(this.exercise);
clone.setId(this.getId());
return clone;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ProgrammingExerciseTestCase programmingExerciseTestCase = (ProgrammingExerciseTestCase) o;
if (programmingExerciseTestCase.getTestName().equals(this.getTestName()) && this.getExercise().getId().equals(programmingExerciseTestCase.getExercise().getId())) {
return true;
}
if (getId() == null && programmingExerciseTestCase.getId() == null) {
return false;
}
return Objects.equals(getId(), programmingExerciseTestCase.getId());
}

@Override
public int hashCode() {
return Objects.hashCode(testName) + Objects.hashCode(getExercise().getId());
}

@Override
public String toString() {
return "ProgrammingExerciseTestCase{" + "id=" + getId() + ", testName='" + getTestName() + "'" + ", weight=" + getWeight() + ", active='" + isActive() + "'" + "}";
}
}
5 changes: 5 additions & 0 deletions src/main/java/de/tum/in/www1/artemis/domain/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ public Result addFeedback(Feedback feedback) {
return this;
}

public Result addFeedbacks(List<Feedback> feedbacks) {
feedbacks.forEach(feedback -> addFeedback(feedback));
return this;
}

public Result removeFeedback(Feedback feedback) {
this.feedbacks.remove(feedback);
feedback.setResult(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.tum.in.www1.artemis.domain.enumeration;

public enum RepositoryType {

TEMPLATE("BASE"), SOLUTION("SOLUTION"), TESTS("TESTS");

private String name;

RepositoryType(String name) {
this.name = name;
}

public String getName() {
return name;
}

@Override
public String toString() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.tum.in.www1.artemis.repository;

import java.util.Set;

import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;

import de.tum.in.www1.artemis.domain.ProgrammingExerciseTestCase;

/**
* Spring Data repository for the ProgrammingExerciseTestCase entity.
*/
@SuppressWarnings("unused")
@Repository
public interface ProgrammingExerciseTestCaseRepository extends JpaRepository<ProgrammingExerciseTestCase, Long> {

Set<ProgrammingExerciseTestCase> findByExerciseId(Long exerciseId);

Set<ProgrammingExerciseTestCase> findByExerciseIdAndActive(Long exerciseId, Boolean active);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public FeedbackService(ResultRepository resultService, Optional<ContinuousIntegr
* Checking if the result already has feedbacks if not try retrieving them from bamboo and create them. Having feedbacks create a JSONObject which will be converted into the
* bamboo format to fit the already used frontend system
*
* @deprecated This method is deprecated and is planned to be removed September 2019. The reason is that we store the build results in our database now and don't have to query
* the integration service for them.
* @param result for which the feedback is supposed to be retrieved
* @return a set of feedback objects including test case names and error messages
*/
Expand Down
Loading

0 comments on commit 785a4ca

Please sign in to comment.