RED-8823 - Add soft deleted time to type response #463

Merged
andrei.isvoran.ext merged 2 commits from RED-8823 into master 2024-04-23 13:17:32 +02:00
3 changed files with 37 additions and 1 deletions

View File

@ -273,6 +273,7 @@ public class DictionaryService {
.systemManaged(typeResult.isSystemManaged())
.autoHideSkipped(typeResult.isAutoHideSkipped())
.dossierDictionaryOnly(typeResult.isDossierDictionaryOnly())
.softDeletedTime(typeResult.getSoftDeletedTime())
.build())
.collect(Collectors.toList());
return new TypeResponse(typeValues);

View File

@ -1,6 +1,10 @@
package com.iqser.red.service.peristence.v1.server.integration.tests;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.assertj.core.util.Lists;
import org.junit.jupiter.api.Test;
@ -119,4 +123,31 @@ public class TypeTest extends AbstractPersistenceServerServiceTest {
assertThat(savedColors.getAppliedRedactionColor()).isEqualTo(colors.getAppliedRedactionColor());
}
@Test
public void testSoftDeletedTimeForTypes() {
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
var type1 = typeProvider.testAndProvideType(dossierTemplate, "type1", 100);
var type2 = typeProvider.testAndProvideType(dossierTemplate, "type2", 101);
var types = dictionaryClient.getAllTypes(dossierTemplate.getId(), null, true);
assertEquals(types.getTypes().size(), 2);
assertTrue(types.getTypes().stream().allMatch(typeValue -> typeValue.getSoftDeletedTime() == null));
dictionaryClient.deleteType(type2.getType(), dossierTemplate.getId());
types = dictionaryClient.getAllTypes(dossierTemplate.getId(), null, true);
assertEquals(types.getTypes().size(), 2);
assertNull(types.getTypes()
.stream()
.filter(t -> t.getType().equals(type1.getType()))
.findFirst()
.get().getSoftDeletedTime());
assertNotNull(types.getTypes()
.stream()
.filter(t -> t.getType().equals(type2.getType()))
.findFirst()
.get().getSoftDeletedTime());
}
}

View File

@ -1,7 +1,8 @@
package com.iqser.red.service.persistence.service.v1.api.shared.model;
import java.time.OffsetDateTime;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -65,4 +66,7 @@ public class TypeValue {
@Schema(description = "Flag to indicate the dictionary is on dossier level only")
private boolean dossierDictionaryOnly;
@Schema(description = "Time of soft deletion, will be null if it's not soft deleted")
private OffsetDateTime softDeletedTime;
}