public void BpSearch_ExistingBP_Returns200Ok() { // Arrange var controller = GetController(); var request = new BpSearchRequest() { FirstName = "Feng", LastName = "Chan" }; var responseForExistingBp = new BpSearchModel() { MatchFound = true, BpId = 1234567, Reason = "Valid match.", ReasonCode = "match", BpSearchIdentifiers = new List <IdentifierModel>() { new IdentifierModel() { IdentifierType = IdentifierType.ZDOB, IdentifierValue = "01/01/1975" } } }; MoveInLogicMock.Setup(m => m.GetDuplicateBusinessPartnerIfExists(It.IsAny <BpSearchRequest>())) .ReturnsAsync(responseForExistingBp); // Act var response = controller.BpSearch(request).Result; // Assert response.ShouldBeOfType <OkObjectResult>(); }
/// <inheritdoc /> public async Task <BpSearchModel> GetDuplicateBusinessPartnerIfExists(BpSearchRequest request) { try { _logger.LogInformation($"GetDuplicateBusinessPartnerIfExists({nameof(request)}: {request})"); var mcfResponse = await _mcfClient.GetDuplicateBusinessPartnerIfExists(request); // if these Threshhold and Unique conditions are met // we can return the response and bpid // unique = 1 (good bp to use) // threshold = x(true..has been met) if (mcfResponse != null) { var response = new BpSearchModel(); if (mcfResponse.Threshhold != null && mcfResponse.Threshhold.ToUpper().Contains("X") && mcfResponse.Unique != null && Convert.ToInt32(mcfResponse.Unique) == 1) { response.MatchFound = true; response.BpId = Convert.ToInt64(mcfResponse.BpId); response.BpSearchIdentifiers = mcfResponse.BpSearchIdInfoSet.Results?.ToList(); response.Reason = mcfResponse.Reason; response.ReasonCode = mcfResponse.ReasonCode; } else { response.MatchFound = false; var resultCount = mcfResponse.BpSearchIdInfoSet != null?mcfResponse.BpSearchIdInfoSet.Results.ToList().Count : 0; response.Reason = string.IsNullOrEmpty(mcfResponse.Reason) ? $"{resultCount} search results found as partial match." : mcfResponse.Reason; response.ReasonCode = string.IsNullOrEmpty(mcfResponse.ReasonCode) ? $"Threshhold not met." : mcfResponse.ReasonCode; } return(response); } else { return(null); } } catch (Exception e) { this._logger.LogError(e, "Failed to search for Business Partner."); throw e; } }