RED-6853 - Update dictionary entries #484
@ -129,9 +129,9 @@ public class DictionaryController implements DictionaryResource {
|
||||
.details(Map.of("Type",
|
||||
type,
|
||||
"Number of added entries",
|
||||
updateEntries.entriesToAdd().size(),
|
||||
updateEntries.entriesToAdd() == null ? 0 : updateEntries.entriesToAdd().size(),
|
||||
"Number of deleted entries",
|
||||
updateEntries.entriesToDelete().size()))
|
||||
updateEntries.entriesToDelete() == null ? 0 : updateEntries.entriesToDelete().size()))
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ public interface DictionaryResource {
|
||||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
@PostMapping(value = DICTIONARY_REST_PATH + DIFFERENCE + DOSSIER_TEMPLATE_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Returns the difference between the dictionaries of the dossier template and all the dossiers inside the template for a list of given types.", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "202", description = "Successfully returned DictionaryDifferenceResponse."), @ApiResponse(responseCode = "400", description = "The request is not valid.")})
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Successfully returned DictionaryDifferenceResponse."), @ApiResponse(responseCode = "400", description = "The request is not valid.")})
|
||||
DictionaryDifferenceResponse getDictionaryDifference(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @RequestBody Set<String> types);
|
||||
|
||||
}
|
||||
@ -132,7 +132,7 @@ public class DictionaryService {
|
||||
if (entriesToDelete != null && !entriesToDelete.isEmpty()) {
|
||||
deleteGlobalEntries(type, dossierTemplateId, entriesToDelete, dictionaryEntryType);
|
||||
}
|
||||
if (entriesToAdd != null && !entriesToAdd.isEmpty()) {
|
||||
if (entriesToAdd != null && !entriesToAdd.isEmpty() && !entriesToAdd.stream().allMatch(String::isEmpty)) {
|
||||
addGlobalEntries(type, dossierTemplateId, entriesToAdd, false, dictionaryEntryType);
|
||||
}
|
||||
}
|
||||
@ -150,7 +150,7 @@ public class DictionaryService {
|
||||
if (entriesToDelete != null && !entriesToDelete.isEmpty()) {
|
||||
deleteDossierEntries(type, dossierTemplateId, entriesToDelete, dossierId, dictionaryEntryType);
|
||||
}
|
||||
if (entriesToAdd != null && !entriesToAdd.isEmpty()) {
|
||||
if (entriesToAdd != null && !entriesToAdd.isEmpty() && !entriesToAdd.stream().allMatch(String::isEmpty)) {
|
||||
addDossierEntries(type, dossierTemplateId, entriesToAdd, false, dossierId, dictionaryEntryType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -594,6 +594,32 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateDossierEntriesWithEmptyFields() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var createdType = createDossierRedactionsDictionary(dossierTemplate.getId());
|
||||
|
||||
var entriesToAdd = new ArrayList<String>();
|
||||
var entriesToDelete = new ArrayList<String>();
|
||||
|
||||
UpdateEntries updateEntries = new UpdateEntries(null, entriesToDelete);
|
||||
UpdateEntries finalUpdateEntries = updateEntries;
|
||||
Assertions.assertDoesNotThrow(() -> dictionaryClient.updateEntries(createdType.getType(),
|
||||
createdType.getDossierTemplateId(),
|
||||
finalUpdateEntries,
|
||||
null,
|
||||
DictionaryEntryType.ENTRY));
|
||||
|
||||
updateEntries = new UpdateEntries(entriesToAdd, null);
|
||||
UpdateEntries finalUpdateEntries1 = updateEntries;
|
||||
Assertions.assertDoesNotThrow(() -> dictionaryClient.updateEntries(createdType.getType(),
|
||||
createdType.getDossierTemplateId(),
|
||||
finalUpdateEntries1,
|
||||
null,
|
||||
DictionaryEntryType.ENTRY));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDossierTemplateAndDossierMissmatched() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user