Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUT/PATCH/POST routes for test now work with json #256

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.ugent.pidgeon.auth.Roles;
import com.ugent.pidgeon.model.Auth;
import com.ugent.pidgeon.model.json.TestJson;
import com.ugent.pidgeon.model.json.TestUpdateJson;
import com.ugent.pidgeon.model.submissionTesting.DockerSubmissionTestModel;
import com.ugent.pidgeon.postgre.models.*;
import com.ugent.pidgeon.postgre.models.types.UserRole;
Expand Down Expand Up @@ -58,37 +59,31 @@ public class TestController {
@PostMapping(ApiRoutes.PROJECT_BASE_PATH + "/{projectid}/tests")
@Roles({UserRole.teacher, UserRole.student})
public ResponseEntity<?> updateTests(
@RequestParam(name = "dockerimage", required = false) String dockerImage,
@RequestParam(name = "dockerscript", required = false) String dockerTest,
@RequestParam(name = "dockertemplate", required = false) String dockerTemplate,
@RequestParam(name = "structuretest", required = false) String structureTest,
@RequestBody TestUpdateJson testJson,
@PathVariable("projectid") long projectId,
Auth auth) {
return alterTests(projectId, auth.getUserEntity(), dockerImage, dockerTest, dockerTemplate, structureTest, HttpMethod.POST);
return alterTests(projectId, auth.getUserEntity(), testJson.getDockerImage(), testJson.getDockerScript(),
testJson.getDockerTemplate(), testJson.getStructureTest(), HttpMethod.POST);
}

@PatchMapping(ApiRoutes.PROJECT_BASE_PATH + "/{projectid}/tests")
@Roles({UserRole.teacher, UserRole.student})
public ResponseEntity<?> patchTests(
@RequestParam(name = "dockerimage", required = false) String dockerImage,
@RequestParam(name = "dockerscript", required = false) String dockerTest,
@RequestParam(name = "dockertemplate", required = false) String dockerTemplate,
@RequestParam(name = "structuretest", required = false) String structureTest,
@RequestBody TestUpdateJson testJson,
@PathVariable("projectid") long projectId,
Auth auth) {
return alterTests(projectId, auth.getUserEntity(), dockerImage, dockerTest, dockerTemplate, structureTest, HttpMethod.PATCH);
return alterTests(projectId, auth.getUserEntity(), testJson.getDockerImage(), testJson.getDockerScript(),
testJson.getDockerTemplate(), testJson.getStructureTest(), HttpMethod.PATCH);
}

@PutMapping(ApiRoutes.PROJECT_BASE_PATH + "/{projectid}/tests")
@Roles({UserRole.teacher, UserRole.student})
public ResponseEntity<?> putTests(
@RequestParam(name = "dockerimage", required = false) String dockerImage,
@RequestParam(name = "dockerscript", required = false) String dockerTest,
@RequestParam(name = "dockertemplate", required = false) String dockerTemplate,
@RequestParam(name = "structuretest", required = false) String structureTest,
@RequestBody TestUpdateJson testJson,
@PathVariable("projectid") long projectId,
Auth auth) {
return alterTests(projectId, auth.getUserEntity(), dockerImage, dockerTest, dockerTemplate, structureTest, HttpMethod.PUT);
return alterTests(projectId, auth.getUserEntity(), testJson.getDockerImage(), testJson.getDockerScript(),
testJson.getDockerTemplate(), testJson.getStructureTest(), HttpMethod.PUT);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.ugent.pidgeon.model.json;

public class TestUpdateJson {
private String dockerImage;
private String dockerScript;
private String dockerTemplate;
private String structureTest;

public TestUpdateJson(String dockerImage, String dockerScript, String dockerTemplate, String structureTest) {
this.dockerImage = dockerImage;
this.dockerScript = dockerScript;
this.dockerTemplate = dockerTemplate;
this.structureTest = structureTest;
}

public String getDockerImage() {
return dockerImage;
}

public void setDockerImage(String dockerImage) {
this.dockerImage = dockerImage;
}

public String getDockerScript() {
return dockerScript;
}

public void setDockerScript(String dockerScript) {
this.dockerScript = dockerScript;
}

public String getDockerTemplate() {
return dockerTemplate;
}

public void setDockerTemplate(String dockerTemplate) {
this.dockerTemplate = dockerTemplate;
}

public String getStructureTest() {
return structureTest;
}

public void setStructureTest(String structureTest) {
this.structureTest = structureTest;
}

}

Loading