Merge branch 'develop' into group-creation-maintain-selection
This commit is contained in:
commit
27ef8599f0
core
@ -32,6 +32,10 @@
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
|
@ -6,7 +6,11 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import jakarta.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.util.*;
|
||||
@ -15,6 +19,9 @@ import org.junit.jupiter.api.Test;
|
||||
import se.su.dsv.scipro.finalseminar.FinalSeminar;
|
||||
import se.su.dsv.scipro.finalseminar.FinalSeminarOpposition;
|
||||
import se.su.dsv.scipro.finalseminar.OppositionApprovedEvent;
|
||||
import se.su.dsv.scipro.grading.GetGradeError;
|
||||
import se.su.dsv.scipro.grading.GradingServiceImpl;
|
||||
import se.su.dsv.scipro.grading.Result;
|
||||
import se.su.dsv.scipro.project.Project;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
import se.su.dsv.scipro.system.DegreeType;
|
||||
@ -149,6 +156,44 @@ public class GradingReportServiceImplIntegrationTest extends IntegrationTest {
|
||||
assertNull(oppositionCriterion.getFeedback());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_json_deserialization() throws IOException {
|
||||
String json =
|
||||
"""
|
||||
{
|
||||
"grade": "A",
|
||||
"reported": "2021-01-01"
|
||||
}
|
||||
""";
|
||||
HttpServer httpServer = startHttpServerWithJsonResponse(json);
|
||||
|
||||
int port = httpServer.getAddress().getPort();
|
||||
|
||||
GradingServiceImpl gradingService = new GradingServiceImpl("http://localhost:" + port);
|
||||
Either<GetGradeError, Optional<Result>> result = gradingService.getResult("token", 1, 2, 3);
|
||||
|
||||
Optional<Result> right = result.right();
|
||||
assertTrue(right.isPresent());
|
||||
assertEquals(LocalDate.of(2021, 1, 1), right.get().reported());
|
||||
|
||||
httpServer.stop(0);
|
||||
}
|
||||
|
||||
private static HttpServer startHttpServerWithJsonResponse(String json) throws IOException {
|
||||
HttpServer httpServer = HttpServer.create();
|
||||
httpServer.createContext("/", exchange -> {
|
||||
try (exchange) {
|
||||
byte[] response = json.getBytes(StandardCharsets.UTF_8);
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json");
|
||||
exchange.sendResponseHeaders(200, response.length);
|
||||
exchange.getResponseBody().write(response);
|
||||
}
|
||||
});
|
||||
httpServer.bind(new InetSocketAddress("localhost", 0), 0);
|
||||
httpServer.start();
|
||||
return httpServer;
|
||||
}
|
||||
|
||||
private void addOppositionCriterion() {
|
||||
gradingReportTemplate = createOppositionCriteria(gradingReportTemplate, 2);
|
||||
gradingReport = createGradingReport(project, student);
|
||||
|
Loading…
x
Reference in New Issue
Block a user