Exemple #1
0
        public void SerializeToXmlString_WhenApplicationHostValues_HasNoUserFields_SerializedXmlOutput_ShouldNotHaveUserFieldNodes()
        {
            // ARRANGE
            var app = GetApplication_NonAddOn();

            app.HostValues.RemoveAll(hv => hv.Field1.Contains("AddAccount.Message.DataUpdate.Account.UserFields.UserField"));

            var applicant = GetApplicant();
            var userToken = "aBc123";

            var dto = GetAddAccountDto(app, applicant, userToken);

            var xml = dto.Message.SerializeToXmlString();

            xml = HostValueTranslator.UpdateRequestWithHostValues(
                xml,
                app.HostValues,
                dto.Message?.HostValueParentNode
                );

            xml = HostValueTranslator.UpdateRequestWithHostValues(
                xml,
                applicant.HostValues,
                dto.Message?.HostValueParentNode
                );

            var xDoc = XDocument.Parse(xml);

            // ACT
            var hasUserFieldNodes = xDoc.Descendants().Where(n => n.Name.LocalName == "UserField").Any();

            // ASSERT
            Assert.IsFalse(hasUserFieldNodes);
        }
Exemple #2
0
        public MessageResponse UpdatePerson(UpdatePerson person, Application app)
        {
            MessageResponse messageResponse = null;
            string          messageXml      = string.Empty;

            using (var tr = new Tracer("LMS.Connector.CCM.Repositories.SoapRepository.UpdateAccount"))
            {
                try
                {
                    messageXml = person.Message?.SerializeToXmlString();
                    tr.Log($"UpdatePerson: BEFORE setting host values => {messageXml}");

                    tr.Log("UpdatePerson: Set Application-level host values ");
                    messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                        messageXml,
                        app.HostValues.Where(hv => hv.Field1.StartsWith("UpdatePerson.")).ToList(),
                        person.Message?.HostValueParentNode
                        );
                    tr.Log($"UpdatePerson: AFTER Application-level host values => {messageXml}");

                    tr.Log("UpdatePerson: Calling ISoapRepository.ProcessMessage");
                    messageResponse = ProcessMessage(messageXml);
                }
                catch (Exception ex)
                {
                    // Handle serialization and host value translation exceptions here

                    tr.LogException(ex);
                    Utility.LogError(ex, "LMS.Connector.CCM.Repositories.SoapRepository.UpdatePerson");
                    throw;
                }
            }

            return(messageResponse);
        }
Exemple #3
0
        public void SerializeToXmlString_GivenADto_ShouldSerializeDtoInProperXmlFormat()
        {
            // ARRANGE
            var app       = GetApplication_NonAddOn();
            var applicant = GetApplicant();
            var userToken = "aBc123";

            var dto = GetAddAccountDto(app, applicant, userToken);

            // ACT
            var xml = dto.Message.SerializeToXmlString();

            xml = HostValueTranslator.UpdateRequestWithHostValues(
                xml,
                app.HostValues,
                dto.Message?.HostValueParentNode
                );

            xml = HostValueTranslator.UpdateRequestWithHostValues(
                xml,
                applicant.HostValues,
                dto.Message?.HostValueParentNode
                );

            // ASSERT
            Assert.IsNotEmpty(xml);
        }
Exemple #4
0
        public void AddAccount_GivenAPersonThatExistsInCCM_ShouldBeAbleToCreateACreditCardAccountInCCM()
        {
            // ARRANGE
            var primaryApplicant = GetApplicant();

            var credentials = new Credentials()
            {
                BaseUrl  = "https://some.bank.or.cu/api",
                Username = "******",
                Password = "******",
                Facility = "validFacility"
            };

            var credentialsHeader = GetCredentialsHeader(credentials);

            var messageXml = _account.Message?.SerializeToXmlString();

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                _app.HostValues.Where(hv => hv.Field1.StartsWith("AddAccount.")).ToList(),
                _account.Message?.HostValueParentNode
                );

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                primaryApplicant.HostValues.Where(hv => hv.Field1.StartsWith("AddAccount.")).ToList(),
                _account.Message?.HostValueParentNode
                );

            var processMessageNodeRequest = new ProcessMessageNodeRequest()
            {
                CredentialsHeader = credentialsHeader,
                request           = GetXmlNode(messageXml)
            };

            var stubServiceRepo = Substitute.For <ISoapRepository>();

            stubServiceRepo.GetProcessMessageNodeRequest(credentialsHeader, messageXml).Returns(processMessageNodeRequest);

            _messageResponse = GetMessageResponseSuccess();

            stubServiceRepo.AddAccount(_account, _app, primaryApplicant).Returns(_messageResponse);
            var stubLmsRepo = Substitute.For <ILmsRepository>();

            stubLmsRepo.GetUserFullNameById(_app.FinalDecisionUserId.GetValueOrDefault()).Returns("Steve Higgs");

            var mockBehavior = new AddAccountBehavior(_app, _userToken, stubServiceRepo, stubLmsRepo);

            mockBehavior.Account = _account;

            // ACT
            var result        = mockBehavior.AddAccount(primaryApplicant);
            var accountNumber = mockBehavior.MessageResponse.AccountNumber;

            // ASSERT
            Assert.AreEqual(0, result.Messages.Count(m => m.Type == MessageType.Error));
            Assert.IsTrue(result.Result);
            Assert.AreEqual("Success", mockBehavior.MessageResponse.ResponseCode);
            Assert.AreEqual("9000000000007", accountNumber);
        }
Exemple #5
0
        public void UpdateAccount_WhenApplicationIsAnAddon_AndPrimaryPersonExistsInCCM_ShouldSuccessfullyUpdateCreditLimitInCCM()
        {
            // ARRANGE
            _applicationAddOn         = GetApplication_AddOn();
            _primaryApplicant         = GetApplicant();
            _userToken                = "aBc123";
            _account                  = GetUpdateAccountDto(_applicationAddOn, _primaryApplicant, _userToken);
            _applicationAddOn.IsAddon = true;

            var credentials = new Credentials()
            {
                BaseUrl  = "https://some.bank.or.cu/api",
                Username = "******",
                Password = "******",
                Facility = "validFacility"
            };

            var credentialsHeader = GetCredentialsHeader(credentials);

            var messageXml = _account.Message?.SerializeToXmlString();

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                _applicationAddOn.HostValues.Where(hv => hv.Field1.StartsWith("UpdateAccount.")).ToList(),
                _account.Message?.HostValueParentNode
                );

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                _primaryApplicant.HostValues.Where(hv => hv.Field1.StartsWith("UpdateAccount.")).ToList(),
                _account.Message?.HostValueParentNode
                );

            var processMessageNodeRequest = new ProcessMessageNodeRequest()
            {
                CredentialsHeader = credentialsHeader,
                request           = GetXmlNode(messageXml)
            };

            var stubServiceRepo = Substitute.For <ISoapRepository>();

            stubServiceRepo.GetProcessMessageNodeRequest(credentialsHeader, messageXml).Returns(processMessageNodeRequest);

            _messageResponse = GetMessageResponseSuccess();

            stubServiceRepo.UpdateAccount(_account, _applicationAddOn, _primaryApplicant).Returns(_messageResponse);

            var mockBehavior = new UpdateAccountBehavior(_applicationAddOn, _userToken, stubServiceRepo);

            mockBehavior.Account = _account;

            // ACT
            var result = mockBehavior.UpdateAccount(_primaryApplicant);

            // ASSERT
            Assert.AreEqual(0, result.Messages.Count(m => m.Type == MessageType.Error));
            Assert.IsTrue(result.Result);
            Assert.AreEqual("Success", mockBehavior.MessageResponse.ResponseCode);
        }
Exemple #6
0
        public MessageResponse AddCard(AddCard card, Application app, LmsPerson lmsPerson)
        {
            MessageResponse messageResponse = null;
            string          messageXml      = string.Empty;

            using (var tr = new Tracer("LMS.Connector.CCM.Repositories.SoapRepository.AddCard"))
            {
                try
                {
                    messageXml = card.Message?.SerializeToXmlString();
                    tr.Log($"AddCard: BEFORE setting host values => {messageXml}");

                    tr.Log("AddCard: Set Application-level host values ");
                    messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                        messageXml,
                        app.HostValues.Where(hv => hv.Field1.StartsWith("AddCard.")).ToList(),
                        card.Message?.HostValueParentNode
                        );
                    tr.Log($"AddCard: AFTER Application-level host values => {messageXml}");

                    if (lmsPerson.Applicant != null)
                    {
                        tr.Log("AddCard: Set Applicant-level host values");
                        messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                            messageXml,
                            lmsPerson.Applicant.HostValues.Where(hv => hv.Field1.StartsWith("AddCard.")).ToList(),
                            card.Message?.HostValueParentNode
                            );
                        tr.Log($"AddCard: AFTER Applicant-level host values => {messageXml}");
                    }
                    else if (lmsPerson.Applicant == null && lmsPerson.AuthorizedUser != null)
                    {
                        tr.Log("AddCard: Set Authorized User-level host values");
                        messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                            messageXml,
                            lmsPerson.AuthorizedUser.HostValues.Where(hv => hv.Field1.StartsWith("AddCard.")).ToList(),
                            card.Message?.HostValueParentNode
                            );
                        tr.Log($"AddCard: AFTER Authorized User-level host values => {messageXml}");
                    }

                    tr.LogObject(CredentialsHeader);

                    tr.Log("AddCard: Calling ISoapRepository.ProcessMessage");
                    messageResponse = ProcessMessage(messageXml);
                }
                catch (Exception ex)
                {
                    // Handle serialization and host value translation exceptions here

                    tr.LogException(ex);
                    Utility.LogError(ex, "LMS.Connector.CCM.Repositories.SoapRepository.AddCard");
                    throw;
                }
            }

            return(messageResponse);
        }
Exemple #7
0
        public void AddCard_GivenAPersonThatHasAnAccountInCCM_ShouldBeAbleToCreateAPlasticCard()
        {
            // ARRANGE
            var applicant = GetApplicant();
            var lmsPerson = new LmsPerson()
            {
                Applicant = applicant
            };

            var credentials = new Credentials()
            {
                BaseUrl  = "https://some.bank.or.cu/api",
                Username = "******",
                Password = "******",
                Facility = "validFacility"
            };

            var credentialsHeader = GetCredentialsHeader(credentials);

            var messageXml = _card.Message?.SerializeToXmlString();

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                applicant.HostValues.Where(hv => hv.Field1.StartsWith("AddCard.")).ToList(),
                _card.Message?.HostValueParentNode
                );

            var processMessageNodeRequest = new ProcessMessageNodeRequest()
            {
                CredentialsHeader = credentialsHeader,
                request           = GetXmlNode(messageXml)
            };

            var stubServiceRepo = Substitute.For <ISoapRepository>();

            stubServiceRepo.GetProcessMessageNodeRequest(credentialsHeader, messageXml).Returns(processMessageNodeRequest);

            _messageResponse = GetMessageResponseSuccess();

            stubServiceRepo.AddCard(_card, _app, lmsPerson).Returns(_messageResponse);

            var stubLmsRepo = Substitute.For <ILmsRepository>();

            var mockBehavior = new AddCardBehavior(_app, _userToken, stubServiceRepo, stubLmsRepo);

            mockBehavior.Card = _card;

            // ACT
            var result     = mockBehavior.AddCard(lmsPerson);
            var cardNumber = mockBehavior.MessageResponse?.CardNumber;

            // ASSERT
            Assert.AreEqual(0, result.Messages.Count(m => m.Type == MessageType.Error));
            Assert.IsTrue(result.Result);
            Assert.AreEqual("Success", mockBehavior.MessageResponse.ResponseCode);
            Assert.AreEqual("4398790000000001", cardNumber);
        }
Exemple #8
0
        public void AddAccountPartyRelationship_GivenAJointPersonThatExistsInCCM_ShouldNotBeAbleToAddThatJointToTheAccountInCCM()
        {
            // ARRANGE
            var jointApplicant = GetApplicant();

            var credentials = new Credentials()
            {
                BaseUrl  = "https://some.bank.or.cu/api",
                Username = "******",
                Password = "******",
                Facility = "validFacility"
            };

            var credentialsHeader = GetCredentialsHeader(credentials);

            var messageXml = _accountPartyRelationship.Message?.SerializeToXmlString();

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                _app.HostValues.Where(hv => hv.Field1.StartsWith("AddAccountPartyRelationship.")).ToList(),
                _accountPartyRelationship.Message?.HostValueParentNode
                );

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                jointApplicant.HostValues.Where(hv => hv.Field1.StartsWith("AddAccountPartyRelationship.")).ToList(),
                _accountPartyRelationship.Message?.HostValueParentNode
                );

            var processMessageNodeRequest = new ProcessMessageNodeRequest()
            {
                CredentialsHeader = credentialsHeader,
                request           = GetXmlNode(messageXml)
            };

            var stubServiceRepo = Substitute.For <ISoapRepository>();

            stubServiceRepo.GetProcessMessageNodeRequest(credentialsHeader, messageXml).Returns(processMessageNodeRequest);

            _messageResponse = GetMessageResponseFail();

            stubServiceRepo.AddAccountPartyRelationship(_accountPartyRelationship, _app, jointApplicant).Returns(_messageResponse);

            var mockBehavior = new AddAccountPartyRelationshipBehavior(_app, _userToken, stubServiceRepo);

            mockBehavior.AccountPartyRelationship = _accountPartyRelationship;

            // ACT
            var result = mockBehavior.AddAccountPartyRelationship(jointApplicant);

            // ASSERT
            Assert.AreEqual(0, result.Messages.Count(m => m.Type == MessageType.Error));
            Assert.IsTrue(result.Result);
            Assert.AreEqual("SystemMalfunction", mockBehavior.MessageResponse.ResponseCode);
        }
Exemple #9
0
        public void AddAccount_GivenValidCredentialsAndDto_ShouldAddTheAccountSuccessfully(int applicationId, string personNumber)
        {
            // ARRANGE
            var    app         = GetApplication(applicationId);
            var    applicant   = GetApplicant();
            var    addAccount  = GetAddAccount(personNumber);
            var    credentials = GetCredentials();
            string messageXml  = addAccount.Message?.SerializeToXmlString();

            var stubSoapClient = Substitute.For <CcmWebServiceSoap>();
            //var stubSoapClient = new CcmWebServiceSoapClient("CcmWebServiceSoap", "https://dna-ccmapp-ttd.uccu.com/ccm-Test-ws/ccmwebservice/ccmwebservice.asmx");

            var repo = new SoapRepository("ABC123", credentials, stubSoapClient);

            var credentialsHeader = new CredentialsHeader()
            {
                Username  = credentials.Username,
                Password  = credentials.Password,
                Facility  = credentials.Facility,
                CultureId = "en"
            };

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(messageXml, app.HostValues, addAccount.Message?.HostValueParentNode);
            messageXml = HostValueTranslator.UpdateRequestWithHostValues(messageXml, applicant.HostValues, addAccount.Message?.HostValueParentNode);

            var processMessageNodeRequest = new ProcessMessageNodeRequest();

            processMessageNodeRequest.CredentialsHeader = credentialsHeader;
            processMessageNodeRequest.request           = GetXmlNode(messageXml);
            repo.ProcessMessageNodeRequest = processMessageNodeRequest;

            var messageResponse = new MessageResponse()
            {
                TraceNumber   = applicationId.ToString(),
                ResponseCode  = "Success",
                AccountNumber = "2001158945704"
            };
            var messageResponseXml = messageResponse.SerializeToXmlString();

            var processMessageNodeResponse = new ProcessMessageNodeResponse()
            {
                ProcessMessageNodeResult = GetXmlNode(messageResponseXml)
            };

            repo.SoapClient.ProcessMessageNode(processMessageNodeRequest).Returns(processMessageNodeResponse);

            // ACT
            var messageNodeResponse = repo.ProcessMessage(messageXml);

            // ASSERT
            Assert.IsNotNull(repo.MessageResponse);
            Assert.AreEqual("Success", repo.MessageResponse.ResponseCode);
        }
Exemple #10
0
        public void TestConnection_WhenGivenValidCredentials_ShouldEstablishConnectivityWithCCM()
        {
            // ARRANGE
            _app.IsAddon = true;

            var credentials = new Credentials()
            {
                BaseUrl  = "https://some.bank.or.cu/api",
                Username = "******",
                Password = "******",
                Facility = "validFacility"
            };

            var credentialsHeader = GetCredentialsHeader(credentials);

            var messageXml = _person.Message?.SerializeToXmlString();

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                _app.HostValues.Where(hv => hv.Field1.StartsWith("UpdatePerson.")).ToList(),
                _person.Message?.HostValueParentNode
                );

            var processMessageNodeRequest = new ProcessMessageNodeRequest()
            {
                CredentialsHeader = credentialsHeader,
                request           = GetXmlNode(messageXml)
            };

            var stubServiceRepo = Substitute.For <ISoapRepository>();

            stubServiceRepo.GetProcessMessageNodeRequest(credentialsHeader, messageXml).Returns(processMessageNodeRequest);

            _messageResponse = GetMessageResponseSystemMalfunction();

            stubServiceRepo.UpdatePerson(_person, _app).Returns(_messageResponse);

            var mockBehavior = new TestConnectionBehavior(_app, _userToken, stubServiceRepo);

            mockBehavior.Person = _person;

            // ACT
            var result = mockBehavior.TestConnection("fooServiceUrl", "barUserName", "fooPassword", "barFacility");

            // ASSERT
            Assert.IsTrue(result.Result);
            Assert.AreEqual("SystemMalfunction", mockBehavior.MessageResponse.ResponseCode);
            Assert.AreEqual("Modify Party request failed. Party 99999999 not found.", mockBehavior.MessageResponse.ErrorMessage);
            Assert.IsTrue(mockBehavior.ConnectionEstablished);
        }
Exemple #11
0
        public MessageResponse AddAccountPartyRelationship(AddAccountPartyRelationship accountPartyRelationship, Application app, Applicant applicant)
        {
            MessageResponse messageResponse = null;
            string          messageXml      = string.Empty;

            using (var tr = new Tracer("LMS.Connector.CCM.Repositories.SoapRepository.AddAccountPartyRelationship"))
            {
                try
                {
                    messageXml = accountPartyRelationship.Message?.SerializeToXmlString();
                    tr.Log($"AddAccountPartyRelationship: BEFORE setting host values => {messageXml}");

                    tr.Log("AddAccountPartyRelationship: Set Application-level host values");
                    messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                        messageXml,
                        app.HostValues.Where(hv => hv.Field1.StartsWith("AddAccountPartyRelationship.")).ToList(),
                        accountPartyRelationship.Message?.HostValueParentNode
                        );
                    tr.Log($"AddAccountPartyRelationship: AFTER Application-level host values => {messageXml}");

                    tr.Log("AddAccountPartyRelationship: Set Applicant-level host values");
                    messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                        messageXml,
                        applicant.HostValues.Where(hv => hv.Field1.StartsWith("AddAccountPartyRelationship.")).ToList(),
                        accountPartyRelationship.Message?.HostValueParentNode
                        );
                    tr.Log($"AddAccountPartyRelationship: AFTER Applicant-level host values => {messageXml}");

                    tr.LogObject(CredentialsHeader);

                    tr.Log("AddAccountPartyRelationship: Calling ISoapRepository.ProcessMessage");
                    messageResponse = ProcessMessage(messageXml);
                }
                catch (Exception ex)
                {
                    // Handle serialization and host value translation exceptions here

                    tr.LogException(ex);
                    Utility.LogError(ex, "LMS.Connector.CCM.Repositories.SoapRepository.AddAccountPartyRelationship");
                    throw;
                }
            }

            return(messageResponse);
        }
Exemple #12
0
        public void AddOrganization_GivenAnOrganizationThatExistsInDNA_ButNotInCCM_ShouldBeAbleToAddThatOrganizationInCCM()
        {
            // ARRANGE
            var applicant = GetOrganization();
            var lmsPerson = new LmsPerson()
            {
                Applicant = applicant
            };

            var address = applicant.Addresses.FirstOrDefault(a => a.AddressTypeId == 311);
            var phone   = applicant.Phones.FirstOrDefault();

            var credentials = new Credentials()
            {
                BaseUrl  = "https://some.bank.or.cu/api",
                Username = "******",
                Password = "******",
                Facility = "validFacility"
            };

            var credentialsHeader = GetCredentialsHeader(credentials);

            var messageXml = _organization.Message?.SerializeToXmlString();

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                _app.HostValues.Where(hv => hv.Field1.StartsWith("AddOrganization.")).ToList(),
                _organization.Message?.HostValueParentNode
                );

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                applicant.HostValues.Where(hv => hv.Field1.StartsWith("AddOrganization.")).ToList(),
                _organization.Message?.HostValueParentNode
                );

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                address.HostValues.Where(hv => hv.Field1.StartsWith("AddOrganization.")).ToList(),
                _organization.Message?.HostValueParentNode
                );

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                phone.HostValues.Where(hv => hv.Field1.StartsWith("AddOrganization.")).ToList(),
                _organization.Message?.HostValueParentNode
                );

            var processMessageNodeRequest = new ProcessMessageNodeRequest()
            {
                CredentialsHeader = credentialsHeader,
                request           = GetXmlNode(messageXml)
            };

            var stubServiceRepo = Substitute.For <ISoapRepository>();

            stubServiceRepo.GetProcessMessageNodeRequest(credentialsHeader, messageXml).Returns(processMessageNodeRequest);

            _messageResponse = GetMessageResponseSuccess();

            stubServiceRepo.AddOrganization(_organization, _app, applicant, address, phone).Returns(_messageResponse);
            var stubLmsRepo = Substitute.For <ILmsRepository>();

            var mockBehavior = new AddOrganizationBehavior(_app, _userToken, stubServiceRepo, stubLmsRepo);

            mockBehavior.Organization   = _organization;
            mockBehavior.CurrentAddress = address;
            mockBehavior.MainPhone      = phone;

            // ACT
            var result = mockBehavior.AddOrganization(applicant);

            // ASSERT
            Assert.AreEqual(0, result.Messages.Count(m => m.Type == MessageType.Error));
            Assert.IsTrue(result.Result);
            Assert.AreEqual("Success", mockBehavior.MessageResponse.ResponseCode);
        }