summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/stileeducation/markr/controller/TestResultsControllerTest.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/java/com/stileeducation/markr/controller/TestResultsControllerTest.java b/src/test/java/com/stileeducation/markr/controller/TestResultsControllerTest.java
index 4db9008..7d6eb37 100644
--- a/src/test/java/com/stileeducation/markr/controller/TestResultsControllerTest.java
+++ b/src/test/java/com/stileeducation/markr/controller/TestResultsControllerTest.java
@@ -1,6 +1,7 @@
package com.stileeducation.markr.controller;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.stileeducation.markr.dto.AggregatedTestResultsDTO;
import com.stileeducation.markr.dto.MCQTestResultsDTO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,16 +27,43 @@ public class TestResultsControllerTest {
@Test
public void testImport() throws Exception {
+ // Given
MCQTestResultsDTO request = new MCQTestResultsDTO();
String requestXml = xmlMapper.writeValueAsString(request);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_XML);
+ // When
HttpEntity<String> entity = new HttpEntity<>(requestXml, headers);
ResponseEntity<String> response = restTemplate.postForEntity(IMPORT_ENDPOINT, entity, String.class);
+ // Then
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}
+ @Test
+ public void testAggregate() throws Exception {
+ // Given
+ String testId = "123"; // Example test ID
+ String url = "/results/" + testId + "/aggregate";
+
+ // When
+ ResponseEntity<AggregatedTestResultsDTO> response = restTemplate.getForEntity(url, AggregatedTestResultsDTO.class);
+
+ // Then
+ assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
+
+ AggregatedTestResultsDTO results = response.getBody();
+ assertThat(results).isNotNull();
+ assertThat(results.getMean()).isEqualTo(65.0);
+ assertThat(results.getStddev()).isEqualTo(0.0);
+ assertThat(results.getMin()).isEqualTo(65.0);
+ assertThat(results.getMax()).isEqualTo(65.0);
+ assertThat(results.getP25()).isEqualTo(65.0);
+ assertThat(results.getP50()).isEqualTo(65.0);
+ assertThat(results.getP75()).isEqualTo(65.0);
+ assertThat(results.getCount()).isEqualTo(1);
+ }
+
}