コード例 #1
0
        /// <summary>
        /// This is the message that initiates the saga.
        /// </summary>
        /// <param name="message">SiteRequestCommand message.</param>
        public void Handle(SiteRequestCommand message)
        {
            Data.ProjectId = message.ProjectId;
            Data.RequestId = -1;
            Data.SiteUrl   = null;
            Data.ProvisioningRequestStatus = ProvisioningRequestStatus.Pending.ToString();

            Bus.Publish <ProvisioningStatusChanged>(m =>
            {
                m.ProjectId = Data.ProjectId;
                m.RequestId = Data.RequestId;
                m.ProvisioningRequestStatusId = (int)ProvisioningRequestStatus.Pending;
                m.SiteUrl = Data.SiteUrl;
            });

            Log.InfoFormat("[URDMS] Sending request to SharePoint integration endpoint to create site for Project {0}", Data.ProjectId);
            Bus.Send <CreateSiteRequest>(m =>
            {
                m.ProjectId       = Data.ProjectId;
                m.SiteTitle       = message.ProjectTitle;
                m.SiteDescription = message.ProjectDescription;
                m.UsersInRoles    = CreateSiteUserList(message.UserRoles);
            });

            // Send notifocatioon to Principal Investigator that their request has been received.
            Bus.Send <NotifyRequestForSiteReceived>(m =>
            {
                m.ProjectId   = Data.ProjectId;
                m.ProjectName = message.ProjectTitle;
                m.UserIds     = new List <string> {
                    message.UserRoles["Owners"]
                };
            });
        }
コード例 #2
0
        public void Perform_review_submission_for_a_non_deposit_project()
        {
            // Arrange
            var vm = Builder <ConfirmDataManagementPlanViewModel>
                     .CreateNew()
                     .With(o => o.DataManagementPlanId = 1)
                     .Build();

            _project.SourceProjectType = PickHelper.RandomEnumExcept(SourceProjectType.DEPOSIT, SourceProjectType.None);
            _project.DataDeposit       = null;

            // Act
            _projectRepository.GetByDataManagementPlanId(Arg.Is(vm.DataManagementPlanId)).Returns(_project);


            _bus.When(c => c.Send(Arg.Any <Action <SiteRequestCommand> >()))
            .Do(a =>
            {
                var message = new SiteRequestCommand();
                var lambda  = a.Arg <Action <SiteRequestCommand> >();

                lambda(message);

                Assert.That(message.ProjectId, Is.EqualTo(_project.Id), "Invalid project id passed to the bus");
                Assert.That(message.ProjectDescription, Is.EqualTo(_project.Description), "Invalid project description passed to the bus");
                Assert.That(message.ProjectTitle, Is.EqualTo(_project.Title), "Invalid project name passed to the bus");
            });
            // Assert
            _controller.WithCallTo(c => c.Review(vm)).ShouldRedirectTo(_controller.GetType().GetMethod("Submitted"));
            // Saving a new data collection
            _dataCollectionRepository.Received().Save(Arg.Any <DataCollection>());
            _projectRepository.Received().GetByDataManagementPlanId(Arg.Is(vm.DataManagementPlanId));
        }
コード例 #3
0
        public void Submit_confirmation_for_DataManagementPlan_invokes_bus_send_request_site_collection_command()
        {
            // Arrange
            var vm = Builder <ConfirmDataManagementPlanViewModel>
                     .CreateNew()
                     .With(o => o.DataManagementPlanId = _project.DataManagementPlan.Id)
                     .Build();

            _bus.When(c => c.Send(Arg.Any <Action <SiteRequestCommand> >())).Do(a =>
            {
                // Arrange
                var rsc    = new SiteRequestCommand();
                var lambda = a.Arg <Action <SiteRequestCommand> >();

                // Act
                lambda(rsc);

                // Assert
                Assert.That(rsc.ProjectId, Is.EqualTo(_project.Id), "Invalid project id passed to the bus");
                Assert.That(rsc.ProjectTitle, Is.EqualTo(_project.Title), "Invalid project name passed to the bus");
                Assert.That(rsc.ProjectDescription, Is.EqualTo(_project.Description), "Invalid project description passed to the bus");

                foreach (var party in _project.Parties.Where(p => p.Role != AccessRole.None))
                {
                    Assert.That(rsc.UserRoles.Any(u => u.Value.Contains(party.Party.UserId) && u.Key == party.Role.ToString()), "No site user passed to the bus for party " + party.Party.UserId);
                }
            });

            // Assert
            _controller.WithCallTo(c => c.Review(vm)).ShouldRedirectTo(_controller.GetType().GetMethod("Submitted"));
        }
コード例 #4
0
        public void Perform_review_submission_confirmation_for_a_data_deposit_project()
        {
            _project.SourceProjectType  = SourceProjectType.DEPOSIT;
            _project.DataManagementPlan = null;

            // Arrange
            var vm = Builder <ConfirmDataDepositViewModel>
                     .CreateNew()
                     .With(o => o.ProjectId  = _project.Id)
                     .And(o => o.ProjectType = SourceProjectType.DEPOSIT)
                     .Build();

            _bus.When(c => c.Send(Arg.Any <Action <SiteRequestCommand> >())).Do(a =>
            {
                // Arrange
                var command = new SiteRequestCommand();
                var lambda  = a.Arg <Action <SiteRequestCommand> >();

                // Act
                lambda(command);

                // Assert
                Assert.That(command.ProjectId, Is.EqualTo(_project.Id), "Invalid project id passed to the bus");
                Assert.That(command.ProjectTitle, Is.EqualTo(_project.Title), "Invalid project name passed to the bus");
                Assert.That(command.ProjectDescription, Is.EqualTo(_project.Description), "Invalid project description passed to the bus");

                foreach (var party in _project.Parties.Where(u => u.Role != AccessRole.None))
                {
                    Assert.That(command.UserRoles.Any(u => u.Value.Contains(party.Party.UserId) && u.Key == party.Role.ToString()), "No site user passed to the bus for party " + party.Party.UserId);
                }
            });

            // Assert
            _controller.WithCallTo(c => c.ReviewDataDeposit(vm)).ShouldRedirectTo(_controller.GetType().GetMethod("SubmittedDataDeposit", new[] { typeof(int) }));

            _dataCollectionRepository.Received().Save(Arg.Any <DataCollection>());
        }