Skip to content
Snippets Groups Projects
Commit 9a954244 authored by Tobias Bruns's avatar Tobias Bruns
Browse files

OZG-6988 fix tests

parent 43fc0c7a
No related branches found
No related tags found
1 merge request!3Ozg 6988 add reporting
This commit is part of merge request !3. Comments created here will be created in the context of that merge request.
...@@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; ...@@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.Singular; import lombok.Singular;
import lombok.ToString;
import lombok.extern.jackson.Jacksonized; import lombok.extern.jackson.Jacksonized;
@Document("settings") @Document("settings")
...@@ -22,6 +23,7 @@ import lombok.extern.jackson.Jacksonized; ...@@ -22,6 +23,7 @@ import lombok.extern.jackson.Jacksonized;
@Jacksonized @Jacksonized
@Builder @Builder
@Getter @Getter
@ToString
public class AggregationMapping { public class AggregationMapping {
@Id @Id
...@@ -39,6 +41,7 @@ public class AggregationMapping { ...@@ -39,6 +41,7 @@ public class AggregationMapping {
@Builder @Builder
@Getter @Getter
@ToString
static class FieldMapping { static class FieldMapping {
@NotBlank @NotBlank
private String sourcePath; private String sourcePath;
...@@ -48,6 +51,7 @@ public class AggregationMapping { ...@@ -48,6 +51,7 @@ public class AggregationMapping {
@Builder @Builder
@Getter @Getter
@ToString
static class FormIdentifier { static class FormIdentifier {
@NotBlank @NotBlank
private String formEngineName; private String formEngineName;
......
...@@ -9,7 +9,7 @@ class AggregationMappingTestFactory { ...@@ -9,7 +9,7 @@ class AggregationMappingTestFactory {
public static final String ID = UUID.randomUUID().toString(); public static final String ID = UUID.randomUUID().toString();
public static final String FORM_ENGINE_NAME = "A12"; public static final String FORM_ENGINE_NAME = "A12";
public static final String FORM_ID = "123AABC"; public static final String FORM_ID = "42";
public static final String SOURCE_PATH = "name"; public static final String SOURCE_PATH = "name";
public static final String TARGET_PATH = "antragsteller.name"; public static final String TARGET_PATH = "antragsteller.name";
......
...@@ -3,6 +3,7 @@ package de.ozgcloud.admin.reporting; ...@@ -3,6 +3,7 @@ package de.ozgcloud.admin.reporting;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
...@@ -39,13 +40,14 @@ class ReportingSettingITCase { ...@@ -39,13 +40,14 @@ class ReportingSettingITCase {
void shouldHaveLinkToReporting() { void shouldHaveLinkToReporting() {
mockMvc.perform(get("/api/configuration")) mockMvc.perform(get("/api/configuration"))
.andExpect(status().is2xxSuccessful()) .andExpect(status().is2xxSuccessful())
.andExpect(jsonPath("$._links.reportingSettings").exists()); .andDo(print())
.andExpect(jsonPath("$._links.aggregationMappings").exists());
} }
@Test @Test
@SneakyThrows @SneakyThrows
void shouldDenyWhileMissingFields() { void shouldDenyWhileMissingFields() {
mockMvc.perform(post("/api/configuration/reportingSettings").with(csrf()) mockMvc.perform(post("/api/configuration/aggregationMappings").with(csrf())
.contentType(MediaType.APPLICATION_JSON).content("{}")) .contentType(MediaType.APPLICATION_JSON).content("{}"))
.andExpect(status().isUnprocessableEntity()); .andExpect(status().isUnprocessableEntity());
} }
...@@ -53,18 +55,20 @@ class ReportingSettingITCase { ...@@ -53,18 +55,20 @@ class ReportingSettingITCase {
@Test @Test
@SneakyThrows @SneakyThrows
void shouldAddReportingSetting() { void shouldAddReportingSetting() {
mockMvc.perform(post("/api/configuration/reportingSettings").with(csrf()) mockMvc.perform(post("/api/configuration/aggregationMappings").with(csrf())
.contentType(MediaType.APPLICATION_JSON).content(TestUtils.loadTextFile("reporting/request.json"))) .contentType(MediaType.APPLICATION_JSON).content(TestUtils.loadTextFile("reporting/request.json")))
.andExpect(status().isCreated()); .andExpect(status().isCreated());
var collection = mongoOperations.getCollection("settings"); var collection = mongoOperations.getCollection("settings");
assertThat(collection.countDocuments()).isEqualTo(1); assertThat(collection.countDocuments()).isEqualTo(1);
var mapping = mongoOperations.findAll(AggregationMapping.class).getFirst();
assertThat(mapping).usingRecursiveComparison().ignoringFields("id").isEqualTo(AggregationMappingTestFactory.create());
} }
@Test @Test
@SneakyThrows @SneakyThrows
void shouldListReportings() { void shouldListReportings() {
mockMvc.perform(get("/api/configuration/reportingSettings")) mockMvc.perform(get("/api/configuration/aggregationMappings"))
.andExpect(status().is2xxSuccessful()); .andExpect(status().is2xxSuccessful());
} }
......
{ {
"formIdentifier": { "formIdentifier": {
"formEngineName": "AFM", "formEngineName": "A12",
"formId": "42" "formId": "42"
}, },
"mappings": [ "mappings": [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment