Skip to content

Commit

Permalink
Merge pull request #652 from catenax-ng/feat/orchestrator_pool_valida…
Browse files Browse the repository at this point in the history
…te_tests

Feat/orchestrator pool validate tests
  • Loading branch information
nicoprow authored Dec 8, 2023
2 parents cbf601f + 9e00fee commit 22b6970
Show file tree
Hide file tree
Showing 2 changed files with 792 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class RequestValidationService(
.map {
AddressBridge(address = it.businessPartner.site?.mainAddress!!, request = it, bpnA = null)
}
val additionalAddressBridges = requestsWithMainAddressNotNull.filter { it.businessPartner.site != null && it.businessPartner.address != null }
val additionalAddressBridges = requestsWithMainAddressNotNull
.filter { it.businessPartner.site != null && it.businessPartner.address != null }
.map {
AddressBridge(address = it.businessPartner.address!!, request = it, bpnA = null)
}
Expand Down Expand Up @@ -223,15 +224,26 @@ class RequestValidationService(
val identifiersValidator = ValidateIdentifierTypesExists(addressDtos, messages.identifierNotFound)
val identifiersDuplicateValidator = ValidateAddressIdentifiersDuplicated(addressDtos, messages.duplicateIdentifier)

return addressBridges.associate { bridge ->
val addressDto = bridge.address
val request = bridge.request
val result: MutableMap<RequestWithKey, List<ErrorInfo<ERROR>>> = mutableMapOf()
// there could be second bridge for the same request, e.g. main address and additional address
addressBridges.forEach{ bridge ->
val legalAddressDto = bridge.address
val request: RequestWithKey = bridge.request
val validationErrors =
regionValidator.validate(addressDto, request) +
identifiersValidator.validate(addressDto, request) +
identifiersDuplicateValidator.validate(addressDto, request, bridge.bpnA)
request to validationErrors
}.filterValues { it.isNotEmpty() }
regionValidator.validate(legalAddressDto, request) +
identifiersValidator.validate(legalAddressDto, request) +
identifiersDuplicateValidator.validate(legalAddressDto, request, bridge.bpnA)

if(validationErrors.isNotEmpty()) {
val existing = result[request];
if (existing == null) {
result[request] = validationErrors
} else {
result[request] = existing + validationErrors
}
}
}
return result;
}

fun validateSitesToCreateFromController(
Expand Down
Loading

0 comments on commit 22b6970

Please sign in to comment.