Started fixing the tests to include the auditor web-controller argument
This commit is contained in:
parent
352bff0859
commit
55c7c35ba0
@ -35,6 +35,8 @@ public class DossierTemplateTesterAndProvider {
|
||||
@Autowired
|
||||
private DictionaryClient dictionaryClient;
|
||||
|
||||
@Autowired
|
||||
private TestAuditor auditor;
|
||||
|
||||
public Colors provideDefaultColors(String dossierTemplateId) {
|
||||
|
||||
@ -70,7 +72,7 @@ public class DossierTemplateTesterAndProvider {
|
||||
cru.setValidTo(OffsetDateTime.now().plusHours(1).truncatedTo(ChronoUnit.MILLIS));
|
||||
cru.setOcrByDefault(ocrByDefault);
|
||||
|
||||
var result = dossierTemplateClient.createOrUpdateDossierTemplate(cru);
|
||||
var result = dossierTemplateClient.createOrUpdateDossierTemplate(cru, auditor);
|
||||
|
||||
assertThat(result.getName()).isEqualTo(name);
|
||||
|
||||
@ -78,8 +80,10 @@ public class DossierTemplateTesterAndProvider {
|
||||
|
||||
assertThat(loadedTemplate).isEqualTo(result);
|
||||
|
||||
rulesClient.upload(new RulesUploadRequest("ABCD", loadedTemplate.getDossierTemplateId()));
|
||||
legalBasisClient.setLegalBasisMapping(List.of(new LegalBasis("name", "description", "reason")), loadedTemplate.getDossierTemplateId());
|
||||
rulesClient.upload(new RulesUploadRequest("ABCD", loadedTemplate.getDossierTemplateId()), auditor);
|
||||
legalBasisClient.setLegalBasisMapping(
|
||||
List.of(new LegalBasis("name", "description", "reason")),
|
||||
loadedTemplate.getDossierTemplateId(), auditor);
|
||||
|
||||
loadedTemplate = dossierTemplateClient.getDossierTemplate(result.getDossierTemplateId());
|
||||
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package com.iqser.red.service.peristence.v1.server.integration.service;
|
||||
|
||||
import com.knecon.fforesight.auditor.BaseAuditor;
|
||||
import com.knecon.fforesight.auditor.model.AuditMessage;
|
||||
import com.knecon.fforesight.auditor.model.Detail;
|
||||
import lombok.NonNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class TestAuditor extends BaseAuditor {
|
||||
private List<AuditMessage> audits = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public @NonNull AuditMessage audit(@NonNull String category, @NonNull String message, Detail<?>... details) {
|
||||
var mappedDetails = Arrays.stream(details)
|
||||
.collect(Collectors.toMap(Detail::getKey, Detail::getValue));
|
||||
var auditMessage = AuditMessage.builder()
|
||||
.category(category)
|
||||
.message(message)
|
||||
.details((Map<String, Object>) mappedDetails)
|
||||
.build();
|
||||
|
||||
audits.add(auditMessage);
|
||||
return auditMessage;
|
||||
}
|
||||
|
||||
public void deleteAll() {
|
||||
audits.clear();
|
||||
}
|
||||
}
|
||||
@ -62,9 +62,14 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
var entries = List.of("word1", "word2");
|
||||
var falsePositives = List.of("false_positive1", "false_positive");
|
||||
var falseRecommendations = List.of("false_recommendation1", "false_recommendation2");
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), entries, false, null, DictionaryEntryType.ENTRY));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), falsePositives, false, null, DictionaryEntryType.FALSE_POSITIVE));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), falseRecommendations, false, null, DictionaryEntryType.FALSE_RECOMMENDATION));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.addEntry(type.getType(),
|
||||
type.getDossierTemplateId(), entries, false, null, DictionaryEntryType.ENTRY, auditor));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.addEntry(type.getType(),
|
||||
type.getDossierTemplateId(), falsePositives, false, null, DictionaryEntryType.FALSE_POSITIVE,
|
||||
auditor));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.addEntry(type.getType(),
|
||||
type.getDossierTemplateId(), falseRecommendations, false, null, DictionaryEntryType.FALSE_RECOMMENDATION,
|
||||
auditor));
|
||||
|
||||
var loadedType1 = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
assertThat(loadedType1).isNotNull();
|
||||
@ -72,12 +77,21 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(loadedType1.getFalsePositiveEntries()).isEmpty();
|
||||
assertThat(loadedType1.getFalseRecommendationEntries()).isEmpty();
|
||||
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntries(type.getType(), type.getDossierTemplateId(), entries, null, DictionaryEntryType.ENTRY));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntries(type.getType(), type.getDossierTemplateId(), falsePositives, null, DictionaryEntryType.FALSE_POSITIVE));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntries(type.getType(), type.getDossierTemplateId(), falseRecommendations, null, DictionaryEntryType.FALSE_RECOMMENDATION));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntry(type.getType(), type.getDossierTemplateId(), entries.get(0), null, DictionaryEntryType.ENTRY));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntry(type.getType(), type.getDossierTemplateId(), falsePositives.get(0), null, DictionaryEntryType.FALSE_POSITIVE));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntry(type.getType(), type.getDossierTemplateId(), falseRecommendations.get(0), null, DictionaryEntryType.FALSE_RECOMMENDATION));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntries(type.getType(),
|
||||
type.getDossierTemplateId(), entries, null, DictionaryEntryType.ENTRY, auditor));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntries(type.getType(),
|
||||
type.getDossierTemplateId(), falsePositives, null, DictionaryEntryType.FALSE_POSITIVE, auditor));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntries(type.getType(),
|
||||
type.getDossierTemplateId(), falseRecommendations, null, DictionaryEntryType.FALSE_RECOMMENDATION,
|
||||
auditor));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntry(type.getType(),
|
||||
type.getDossierTemplateId(), entries.get(0), null, DictionaryEntryType.ENTRY, auditor));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntry(type.getType(),
|
||||
type.getDossierTemplateId(), falsePositives.get(0), null, DictionaryEntryType.FALSE_POSITIVE,
|
||||
auditor));
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () -> dictionaryClient.deleteEntry(type.getType(),
|
||||
type.getDossierTemplateId(), falseRecommendations.get(0), null, DictionaryEntryType.FALSE_RECOMMENDATION,
|
||||
auditor));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -89,14 +103,17 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(type.getSkippedHexColor()).isEqualTo("#aaaaaa");
|
||||
assertThat(type.isDossierDictionaryOnly()).isFalse();
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("word1", "word2"), false, null, DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("false_positive1", "false_positive"), false, null, DictionaryEntryType.FALSE_POSITIVE);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("word1", "word2"), false,
|
||||
null, DictionaryEntryType.ENTRY, auditor);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("false_positive1", "false_positive"),
|
||||
false, null, DictionaryEntryType.FALSE_POSITIVE, auditor);
|
||||
dictionaryClient.addEntry(type.getType(),
|
||||
type.getDossierTemplateId(),
|
||||
List.of("false_recommendation1", "false_recommendation2"),
|
||||
false,
|
||||
null,
|
||||
DictionaryEntryType.FALSE_RECOMMENDATION);
|
||||
DictionaryEntryType.FALSE_RECOMMENDATION,
|
||||
auditor);
|
||||
|
||||
var loadedType1 = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.iqser.red.service.peristence.v1.server.integration.service.TestAuditor;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -59,7 +60,6 @@ import com.iqser.red.service.persistence.management.v1.processor.service.Applica
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.FileManagementStorageService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.RedactionLogService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.ApplicationConfigRepository;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.AuditRepository;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DigitalSignatureRepository;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DossierAttributeConfigRepository;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DossierAttributeRepository;
|
||||
@ -143,7 +143,7 @@ public abstract class AbstractPersistenceServerServiceTest {
|
||||
@Autowired
|
||||
protected NotificationRepository notificationRepository;
|
||||
@Autowired
|
||||
protected AuditRepository auditRepository;
|
||||
protected TestAuditor auditor;
|
||||
@Autowired
|
||||
protected TypeRepository typeRepository;
|
||||
@Autowired
|
||||
@ -383,7 +383,7 @@ public abstract class AbstractPersistenceServerServiceTest {
|
||||
typeRepository.deleteAll();
|
||||
viewedPagesRepository.deleteAll();
|
||||
notificationRepository.deleteAll();
|
||||
auditRepository.deleteAll();
|
||||
auditor.deleteAll();
|
||||
manualRedactionRepository.deleteAll();
|
||||
forceRedactionRepository.deleteAll();
|
||||
removeRedactionRepository.deleteAll();
|
||||
|
||||
@ -3,8 +3,6 @@ package com.iqser.red.service.persistence.service.v1.api.shared.model.common;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.audit.AuditModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user