-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectNegativeImportTests.cs
More file actions
126 lines (112 loc) · 4.48 KB
/
ObjectNegativeImportTests.cs
File metadata and controls
126 lines (112 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// ----------------------------------------------------------------------------
// <copyright file="ObjectNegativeImportTests.cs" company="Relativity ODA LLC">
// © Relativity All Rights Reserved.
// </copyright>
// ----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Relativity.Server.Import.SDK.Samples.Helpers;
namespace Relativity.Server.Import.SDK.Samples.Tests
{
/// <summary>
/// Represents tests that fails to import objects and validates the results.
/// </summary>
[TestFixture]
public class ObjectNegativeImportTests : ObjectImportTestsBase
{
/// <summary>
/// Gets the test case data.
/// </summary>
/// <value>
/// The <see cref="TestCaseData"/> instances.
/// </value>
private static IEnumerable<TestCaseData> TestCases =>
new List<TestCaseData>
{
new TestCaseData("Negative-Transfer-1", "Negative-Detail-1", "Negative-DataSourceName-1"),
};
[Test]
[TestCaseSource(nameof(TestCases))]
public void ShouldNotImportDuplicateSingleObjectFields(
string name,
string detailName,
string dataSourceName)
{
// Arrange
this.CreateAssociatedDetailInstance(detailName);
this.CreateAssociatedDetailInstance(detailName);
this.CreateAssociatedDataSourceInstance(dataSourceName);
kCura.Relativity.DataReaderClient.ImportBulkArtifactJob job = this.CreateImportBulkArtifactJob();
string description = RandomHelper.NextString(50, 450);
decimal requestBytes = RandomHelper.NextDecimal(10, 1000000);
DateTime requestDate = DateTime.Now;
decimal requestFiles = RandomHelper.NextDecimal(1000, 10000);
this.DataSource.Rows.Add(
name,
description,
requestBytes,
requestFiles,
requestDate,
detailName,
dataSourceName);
job.SourceData.SourceData = this.DataSource.CreateDataReader();
// Act
job.Execute();
// Assert - the job completed and the report matches the expected values.
Assert.That(this.PublishedJobReport, Is.Not.Null);
Assert.That(this.PublishedJobReport.EndTime, Is.GreaterThan(this.PublishedJobReport.StartTime));
// Assert - duplicate single-object field yields a job-level error.
Assert.That(this.PublishedJobReport.ErrorRowCount, Is.Positive);
Assert.That(this.PublishedJobReport.FatalException, Is.Null);
Assert.That(this.PublishedJobReport.TotalRows, Is.EqualTo(1));
// Assert - the events match the expected values.
Assert.That(this.PublishedErrors.Count, Is.Positive);
Assert.That(this.PublishedFatalException, Is.Null);
Assert.That(this.PublishedMessages.Count, Is.Positive);
Assert.That(this.PublishedProcessProgress.Count, Is.Positive);
Assert.That(this.PublishedProgressRows.Count, Is.Positive);
}
[Test]
[TestCaseSource(nameof(TestCases))]
public void ShouldNotImportDuplicateMultiObjectFields(
string name,
string detailName,
string dataSourceName)
{
// Arrange
this.CreateAssociatedDetailInstance(detailName);
this.CreateAssociatedDataSourceInstance(dataSourceName);
this.CreateAssociatedDataSourceInstance(dataSourceName);
kCura.Relativity.DataReaderClient.ImportBulkArtifactJob job = this.CreateImportBulkArtifactJob();
string description = RandomHelper.NextString(50, 450);
decimal requestBytes = RandomHelper.NextDecimal(10, 1000000);
DateTime requestDate = DateTime.Now;
decimal requestFiles = RandomHelper.NextDecimal(1000, 10000);
this.DataSource.Rows.Add(
name,
description,
requestBytes,
requestFiles,
requestDate,
detailName,
dataSourceName);
job.SourceData.SourceData = this.DataSource.CreateDataReader();
// Act
job.Execute();
// Assert - the job completed and the report matches the expected values.
Assert.That(this.PublishedJobReport, Is.Not.Null);
Assert.That(this.PublishedJobReport.EndTime, Is.GreaterThan(this.PublishedJobReport.StartTime));
// Assert - duplicate multi-object field currently yields a fatal error.
Assert.That(this.PublishedJobReport.ErrorRowCount, Is.EqualTo(1));
Assert.That(this.PublishedJobReport.FatalException, Is.Null);
Assert.That(this.PublishedJobReport.TotalRows, Is.EqualTo(1));
// Assert - the events match the expected values.
Assert.That(this.PublishedErrors.Count, Is.EqualTo(1));
Assert.That(this.PublishedFatalException, Is.Null);
Assert.That(this.PublishedMessages.Count, Is.Positive);
Assert.That(this.PublishedProcessProgress.Count, Is.Positive);
Assert.That(this.PublishedProgressRows.Count, Is.Positive);
}
}
}