Skip to content

Commit 9c08b76

Browse files
authored
Merge pull request #12 from IndicoDataSolutions/bugfix/INT-136-submit-review-empty-changes
INT-136 Submit review empty changes
2 parents 892bd1a + 2ff8ec6 commit 9c08b76

4 files changed

Lines changed: 26 additions & 23 deletions

File tree

Indico.BluePrism.Connector.IntegrationTests/IndicoConnectorTests/ConnectorTestsBase.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,28 @@ public void PerformAction_ShouldReturnResult()
2828
}
2929

3030
[Test]
31-
public void PerformAction_ShouldThrow_WhenBaseUrlNotFound() =>
31+
public void PerformAction_ShouldThrow_WhenBaseUrlNotFound() =>
3232
new IndicoConnectorBuilder().WithBaseUrl("https://invalid.indico.io").Build()
3333
.Invoking(PerformAction)
34-
.Should().Throw<HttpRequestException>()
35-
.WithMessage("No such host is known.");
34+
.Should().Throw<HttpRequestException>();
3635

3736
[Test]
3837
public void PerformAction_ShouldThrow_WhenBaseUrlIncorrectFormat() =>
3938
new IndicoConnectorBuilder().WithBaseUrl("invalid").Build()
4039
.Invoking(PerformAction)
41-
.Should().Throw<UriFormatException>()
42-
.WithMessage("Invalid URI: The format of the URI could not be determined.");
40+
.Should().Throw<UriFormatException>();
4341

4442
[Test]
4543
public void PerformAction_ShouldThrow_WhenApiTokenIncorrect() =>
4644
new IndicoConnectorBuilder().WithToken("invalid").Build()
4745
.Invoking(PerformAction)
48-
.Should().Throw<HttpRequestException>()
49-
.WithMessage("[error] : Unauthorized");
46+
.Should().Throw<HttpRequestException>();
5047

5148
[Test]
5249
public void PerformAction_ShouldThrow_WhenApiTokenNull() =>
5350
new IndicoConnectorBuilder().WithToken(null)
5451
.Invoking(bld => PerformAction(bld.Build()))
55-
.Should().Throw<ArgumentNullException>()
56-
.WithMessage("Value cannot be null. (Parameter 'apiToken')");
52+
.Should().Throw<ArgumentNullException>();
5753

5854

5955
protected abstract TActionResult PerformAction(IndicoConnector connector);

Indico.BluePrism.Connector.IntegrationTests/IndicoConnectorTests/ListSubmissionsTests.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,20 @@ public void ListSubmissions_Throws_WhenIncorrectWorkflowId()
1414
var connector = new IndicoConnectorBuilder().Build();
1515
const string expectedExceptionMessage =
1616
@"1 : http://sunbow:5000/api/submission?workflow_ids=0&limit=1&filters=%7B%7D: {""code"": 403, ""content"": {}, ""error_class"": ""ServiceException"", ""error_type"": ""ForbiddenAccess"", ""message"": ""This user does not have access to this resource""}";
17-
connector.Invoking(c => c.ListSubmissions(null, new decimal[] {0}.ToDataTable(), null, null, null, 1))
17+
connector.Invoking(c => c.ListSubmissions(null, new decimal[] { 0 }.ToDataTable(), null, null, null, 1))
1818
.Should()
1919
.Throw<GraphQLException>()
2020
.WithMessage(expectedExceptionMessage);
2121
}
2222

23-
2423
protected override DataTable PerformAction(IndicoConnector connector) =>
2524
connector.ListSubmissions(
25+
DataTableHelpers.ToDataTable(new[] { _dataHelper.GetAnySubmissionId() }),
26+
null,
27+
null,
28+
null,
2629
null,
27-
DataTableHelpers.ToDataTable(new[] { _dataHelper.GetAnySubmissionId() }),
28-
null,
29-
null,
30-
null,
31-
1);
30+
1);
3231

3332
protected override void AssertResultCorrect(DataTable result) => result.Rows.Count.Should().Be(1);
3433
}

Indico.BluePrism.Connector.IntegrationTests/Utils/TestDataHelper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ public class TestDataHelper
88

99
public TestDataHelper(IndicoConnector connector) => _connector = connector;
1010

11-
public decimal GetAnyWorkflowId() => 1087;
11+
public decimal GetAnyWorkflowId() => (int)GetSubmission()["WorkflowId"];
1212

13-
public decimal GetAnySubmissionId() => (int)_connector.ListSubmissions(null, null, null, null, null, 1).Rows[0]["Id"];
13+
public decimal GetAnySubmissionId() => (int)GetSubmission()["Id"];
1414

1515
public decimal GetNewSubmissionId() => (int)_connector.WorkflowSubmission(
1616
null,
@@ -27,5 +27,7 @@ public decimal GetNewSubmissionId() => (int)_connector.WorkflowSubmission(
2727

2828
private (decimal submisisonId, DataTable submissionResult) GetSubmissionResult(decimal submissionId) => (submissionId,
2929
_connector.SubmissionResult(submissionId, default));
30+
31+
private DataRow GetSubmission() => _connector.ListSubmissions(null, null, null, null, null, 1).Rows[0];
3032
}
3133
}

Indico.BluePrism.Connector/IndicoConnector.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public IndicoConnector(ISubmissionsClient submissionsClient, ISubmissionResultAw
5252

5353
public DataTable WorkflowSubmission(DataTable filepaths, DataTable uris, decimal workflowId)
5454
{
55-
bool filepathsProvided = ValidateInputDataTable(filepaths);
56-
bool urisProvided = ValidateInputDataTable(uris);
55+
bool filepathsProvided = HasAnyRows(filepaths);
56+
bool urisProvided = HasAnyRows(uris);
5757

5858
if (!filepathsProvided && !urisProvided)
5959
{
@@ -166,9 +166,15 @@ public DataTable SubmitReview(decimal submissionIdDec, DataTable changesTable, b
166166
private DataTable SubmitReview(decimal submissionIdDec, DataTable changesTable, bool rejected, bool? forceComplete)
167167
{
168168
var submissionId = (int)submissionIdDec;
169-
var changes = _jsonUtility.ConvertToJSON(changesTable ?? throw new ArgumentNullException(nameof(changesTable)));
169+
var changesProvided = HasAnyRows(changesTable);
170+
JObject changes = null;
170171

171-
var jobResult = Task.Run(() => SubmitReviewAsync(submissionId, (JObject)changes, rejected, forceComplete))
172+
if (changesProvided)
173+
{
174+
changes = (JObject)_jsonUtility.ConvertToJSON(changesTable);
175+
}
176+
177+
var jobResult = Task.Run(() => SubmitReviewAsync(submissionId, changes, rejected, forceComplete))
172178
.GetAwaiter()
173179
.GetResult();
174180

@@ -188,7 +194,7 @@ private async Task<JObject> SubmitReviewAsync(int submissionId, JObject changes,
188194
}
189195
}
190196

191-
private static bool ValidateInputDataTable(DataTable dataTable)
197+
private static bool HasAnyRows(DataTable dataTable)
192198
{
193199
if (dataTable == null || dataTable.Rows.Count == 0)
194200
{

0 commit comments

Comments
 (0)