Skip to content
Snippets Groups Projects
Commit f3428ac7 authored by Paul PEYREFITTE's avatar Paul PEYREFITTE Committed by bouhaddouzay
Browse files

[RABB-911] Always display contract identifiers in tenant logbook

parent c346dec6
No related branches found
No related tags found
No related merge requests found
......@@ -83,23 +83,10 @@ public class TenantConverter implements Converter<TenantDto, Tenant> {
logbookData.put(ENABLED_KEY, LogbookUtils.getValue(tenant.getEnabled()));
Optional<Owner> owner = ownerRepository.findById(tenant.getOwnerId());
owner.ifPresent(o -> logbookData.put(OWNER_ID_KEY, o.getIdentifier()));
final String accessContractHoldingIdentifier = tenant.getAccessContractHoldingIdentifier();
if (StringUtils.isNotBlank(accessContractHoldingIdentifier)) {
logbookData.put(ACCESS_CONTRACT_HOLDING_IDENTIFIER_KEY, accessContractHoldingIdentifier);
}
final String accessContractLogbookIdentifier = tenant.getAccessContractLogbookIdentifier();
if (StringUtils.isNotBlank(accessContractLogbookIdentifier)) {
logbookData.put(ACCESS_CONTRACT_LOGBOOK_IDENTIFIER_KEY, accessContractLogbookIdentifier);
}
final String ingestContractHoldingIdentifier = tenant.getIngestContractHoldingIdentifier();
if (StringUtils.isNotBlank(ingestContractHoldingIdentifier)) {
logbookData.put(INGEST_CONTRACT_HOLDING_IDENTIFIER_KEY, ingestContractHoldingIdentifier);
}
final String itemIngestContractIdentifier = tenant.getItemIngestContractIdentifier();
if (StringUtils.isNotBlank(itemIngestContractIdentifier)) {
logbookData.put(ITEM_INGEST_CONTRACT_IDENTIFIER_KEY, itemIngestContractIdentifier);
}
logbookData.put(ACCESS_CONTRACT_HOLDING_IDENTIFIER_KEY, LogbookUtils.getValue(tenant.getAccessContractHoldingIdentifier()));
logbookData.put(ACCESS_CONTRACT_LOGBOOK_IDENTIFIER_KEY, LogbookUtils.getValue(tenant.getAccessContractLogbookIdentifier()));
logbookData.put(INGEST_CONTRACT_HOLDING_IDENTIFIER_KEY, LogbookUtils.getValue(tenant.getIngestContractHoldingIdentifier()));
logbookData.put(ITEM_INGEST_CONTRACT_IDENTIFIER_KEY, LogbookUtils.getValue(tenant.getItemIngestContractIdentifier()));
return ApiUtils.toJson(logbookData);
}
......
......@@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import fr.gouv.vitam.common.exception.InvalidParseOperationException;
import fr.gouv.vitam.common.json.JsonHandler;
import fr.gouv.vitamui.commons.api.domain.TenantDto;
import fr.gouv.vitamui.commons.logbook.util.LogbookUtils;
import fr.gouv.vitamui.iam.commons.utils.IamDtoBuilder;
import fr.gouv.vitamui.iam.internal.server.owner.dao.OwnerRepository;
import fr.gouv.vitamui.iam.internal.server.owner.domain.Owner;
......@@ -68,17 +69,22 @@ public class TenantConverterTest {
tenantDto.setAccessContractHoldingIdentifier(null);
json = tenantConverter.convertToLogbook(tenantDto);
jsonNode = JsonHandler.getFromString(json);
assertThat(jsonNode.get(TenantConverter.ACCESS_CONTRACT_HOLDING_IDENTIFIER_KEY)).isNull();
assertThat(jsonNode.get(TenantConverter.ACCESS_CONTRACT_HOLDING_IDENTIFIER_KEY)).isNotNull();
tenantDto.setAccessContractLogbookIdentifier(null);;
json = tenantConverter.convertToLogbook(tenantDto);
jsonNode = JsonHandler.getFromString(json);
assertThat(jsonNode.get(TenantConverter.ACCESS_CONTRACT_LOGBOOK_IDENTIFIER_KEY)).isNull();
assertThat(jsonNode.get(TenantConverter.ACCESS_CONTRACT_LOGBOOK_IDENTIFIER_KEY)).isNotNull();
tenantDto.setIngestContractHoldingIdentifier(null);
json = tenantConverter.convertToLogbook(tenantDto);
jsonNode = JsonHandler.getFromString(json);
assertThat(jsonNode.get(TenantConverter.INGEST_CONTRACT_HOLDING_IDENTIFIER_KEY)).isNull();
assertThat(jsonNode.get(TenantConverter.INGEST_CONTRACT_HOLDING_IDENTIFIER_KEY)).isNotNull();
tenantDto.setItemIngestContractIdentifier(null);
json = tenantConverter.convertToLogbook(tenantDto);
jsonNode = JsonHandler.getFromString(json);
assertThat(jsonNode.get(TenantConverter.ITEM_INGEST_CONTRACT_IDENTIFIER_KEY)).isNotNull();
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment