Example #1
0
        private static void CreateCqlDocument(DocumentModel documentModel)
        {
            using var context = new CqlDbContext();
            var table = context.GetTable <CqlDocument>();

            table.Insert(documentModel.ToCqlDocument()).SetTimestamp(DateTimeOffset.UtcNow).Execute();
        }
        public void TestDownloadByteContent()
        {
            var content = string.Join("\n", new[] { "this is large file content" }.Concat(Enumerable.Range(0, 10000).Select(i => (i % 256).ToString())));
            var blobId  = Guid.NewGuid();

            using (var context = new CqlDbContext())
                context.GetTable <CqlActiveBoxState>().Insert(new CqlActiveBoxState
                {
                    PartitionKey         = "0",
                    LastProcessedEventId = "0",
                    BoxId   = blobId,
                    Content = Encoding.UTF8.GetBytes(content),
                }).SetTimestamp(DateTimeOffset.UtcNow).Execute();

            using var browser = new BrowserForTests();

            var tempFileStoragePage = browser.LoginAsSuperUser().SwitchTo <BusinessObjectTablePage>("CqlActiveBoxState");

            tempFileStoragePage.OpenFilter.Click();
            tempFileStoragePage.FilterModal.GetFilter("PartitionKey").Input.ClearAndInputText("0");
            tempFileStoragePage.FilterModal.GetFilter("BoxId").Input.ClearAndInputText(blobId.ToString());
            tempFileStoragePage.FilterModal.Apply.Click();
            tempFileStoragePage.BusinessObjectItems.WaitCount(1);

            var detailsPage = tempFileStoragePage.BusinessObjectItems[0].Details.ClickAndGoTo <BusinessObjectDetailsPage>();

            detailsPage.RootAccordion.FindField("Content").FieldValue.DownloadLink.Click();

            Thread.Sleep(1000);
            var file = browser.DownloadFile("CqlActiveBoxState-Content-dGhpcy.bin");

            file.Should().Be(content);
        }
Example #3
0
 private CqlConnectorDeliveryContext[] GetConnectorDeliveryContext(CqlConnectorDeliveryContext deliveryContext)
 {
     using var context = new CqlDbContext();
     return(context.GetTable <CqlConnectorDeliveryContext>()
            .Where(x => x.TimeSliceId == deliveryContext.TimeSliceId &&
                   x.TimeSliceShardNumber == deliveryContext.TimeSliceShardNumber &&
                   x.ContextId == deliveryContext.ContextId)
            .Execute()
            .ToArray());
 }
        private static void CreateApiClient(string objectId, string lastEventId)
        {
            using var context = new CqlDbContext();
            var table = context.GetTable <ApiClientThrift>();

            table.Insert(new ApiClientThrift
            {
                Id          = objectId,
                ScopeId     = "scopeId",
                ArrayIndex  = "arrayIndex",
                Description = lastEventId,
            }).SetTimestamp(DateTimeOffset.UtcNow).Execute();
        }
Example #5
0
 private DocumentBindingsMeta[] GetBindingMeta(DocumentBindingsMeta meta)
 {
     using var context = new CqlDbContext();
     return(context.GetTable <DocumentBindingsMeta>()
            .Where(x => x.BindingType == meta.BindingType &&
                   x.FirstPartnerPartyId == meta.FirstPartnerPartyId &&
                   x.SecondPartnerPartyId == meta.SecondPartnerPartyId &&
                   x.DocumentNumber == meta.DocumentNumber &&
                   x.DocumentDate == meta.DocumentDate &&
                   x.DocumentTime == meta.DocumentTime &&
                   x.DocumentType == meta.DocumentType &&
                   x.DocumentCirculationId == meta.DocumentCirculationId)
            .Execute()
            .ToArray());
 }
        private void CreateTable <T>(CqlDbContext context, int count)
            where T : class
        {
            context.DropTable <T>();
            var table = context.GetTable <T>();

            var fixture = new Fixture();

            fixture.Register((DateTime dt) => dt.ToLocalDate());
            fixture.Register((DateTime dt) => CassandraPrimitivesExtensions.ToLocalTime(dt));

            for (var i = 0; i < count; i++)
            {
                table.Insert(Modify <T>(fixture)).SetTimestamp(DateTimeOffset.UtcNow).Execute();
            }
        }
        public void TestNonSuperUserCantEditOrDeleteObject()
        {
            var document = CqlDocumentsForTests.GetCqlDocumentPrintingInfo();

            using (var context = new CqlDbContext())
                context.GetTable <DocumentPrintingInfo>().Insert(document).SetTimestamp(DateTimeOffset.UtcNow).Execute();

            using var browser = new BrowserForTests();
            var printingInfoPage = browser.SwitchTo <BusinessObjectTablePage>("DocumentPrintingInfo");

            printingInfoPage.OpenFilter.Click();
            printingInfoPage.FilterModal.GetFilter("Id").Input.ClearAndInputText(document.Id.ToString());
            printingInfoPage.FilterModal.Apply.Click();

            var detailsPage = printingInfoPage.BusinessObjectItems[0].Details.ClickAndGoTo <BusinessObjectDetailsPage>();

            detailsPage.RootAccordion.FindField("PartyId").Edit.WaitAbsence();
            detailsPage.Delete.WaitAbsence();
        }
        public void TestLinkFromFindShouldReferToDetailPage()
        {
            var document = CqlDocumentsForTests.GetCqlDocumentPrintingInfo();

            using (var context = new CqlDbContext())
                context.GetTable <DocumentPrintingInfo>().Insert(document).SetTimestamp(DateTimeOffset.UtcNow).Execute();

            using var browser = new BrowserForTests();
            var printingInfoPage = browser.LoginAsSuperUser().SwitchTo <BusinessObjectTablePage>("DocumentPrintingInfo");

            printingInfoPage.BusinessObjectItems.Count.Wait().That(Is.GreaterThan(0));
            printingInfoPage.OpenFilter.Click();
            printingInfoPage.FilterModal.GetFilter("Id").Input.ClearAndInputText(document.Id.ToString());
            printingInfoPage.FilterModal.Apply.Click();

            printingInfoPage.BusinessObjectItems.WaitCount(1);
            printingInfoPage.BusinessObjectItems[0].FindColumn("Id").WaitText(document.Id.ToString());
            var detailsPage = printingInfoPage.BusinessObjectItems[0].Details.ClickAndGoTo <BusinessObjectDetailsPage>();

            detailsPage.Header.WaitPresence();

            CheckDocumentPrintingInfoFields(detailsPage, document);
        }
        public void TestSuperUserCanEditOrDeleteObject()
        {
            var document = CqlDocumentsForTests.GetCqlDocumentPrintingInfo();

            using (var context = new CqlDbContext())
                context.GetTable <DocumentPrintingInfo>().Insert(document).SetTimestamp(DateTimeOffset.UtcNow).Execute();

            using var browser = new BrowserForTests();
            var printingInfoPage = browser.LoginAsSuperUser().SwitchTo <BusinessObjectTablePage>("DocumentPrintingInfo");

            printingInfoPage.OpenFilter.Click();
            printingInfoPage.FilterModal.GetFilter("Id").Input.ClearAndInputText(document.Id.ToString());
            printingInfoPage.FilterModal.Apply.Click();

            var detailsPage = printingInfoPage.BusinessObjectItems[0].Details.ClickAndGoTo <BusinessObjectDetailsPage>();

            var id = detailsPage.RootAccordion.FindField("Id");

            id.Edit.WaitAbsence();

            var partyId = detailsPage.RootAccordion.FindField("PartyId");

            partyId.Edit.WaitAbsence();

            var fileId = detailsPage.RootAccordion.FindField("FileId");

            fileId.Edit.Click();
            fileId.FieldValue.Input.ClearAndInputText("Abc");
            fileId.Save.Click();
            fileId.Value.WaitText("Abc");

            var status = detailsPage.RootAccordion.FindField("Status");

            status.Edit.Click();
            status.FieldValue.EnumSelect.WaitText("Finished");
            status.FieldValue.EnumSelect.WaitItems(new[] { "Unknown", "Pending", "Failed", "Finished" });
            status.FieldValue.EnumSelect.SelectValueByText("Failed");
            status.Save.Click();
            status.Value.WaitText("Failed");

            var timestamp = detailsPage.RootAccordion.FindField("Timestamp");

            timestamp.Edit.Click();
            timestamp.FieldValue.Date.ClearAndInputText("13.12.2013");
            timestamp.Save.Click();
            timestamp.Value.Text.Wait().That(Does.StartWith("2013-12-13"));

            document.FileId = "Abc";
            document.Status = DocumentPrintingStatus.Failed;

            detailsPage = browser.Refresh(detailsPage);
            CheckDocumentPrintingInfoFields(detailsPage, document);

            detailsPage.Delete.Click();
            printingInfoPage = detailsPage.ConfirmDeleteObjectModal.Delete.ClickAndGoTo <BusinessObjectTablePage>();
            printingInfoPage.OpenFilter.Click();
            printingInfoPage.FilterModal.GetFilter("Id").Input.ClearAndInputText(document.Id.ToString());
            printingInfoPage.FilterModal.Apply.Click();
            printingInfoPage.NothingFound.WaitPresence();
            printingInfoPage.BusinessObjectItems.WaitAbsence();
        }