Skip to content

Commit

Permalink
Extended tests to cover form deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
sindremb committed Feb 14, 2024
1 parent 4801607 commit bdc563d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
32 changes: 26 additions & 6 deletions Client.UnitTests/DeploymentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Zeebe.Client
public class DeploymentTest : BaseZeebeTest
{
private readonly string _demoProcessPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "demo-process.bpmn");
private readonly string _demoFormPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "demo-form.form");

[Test]
public async Task ShouldSendDeployResourceFileAsExpected()
Expand Down Expand Up @@ -240,16 +241,16 @@ public async Task ShouldSendMultipleDeployResourceAsExpected()
},
new Resource
{
Content = ByteString.FromStream(File.OpenRead(_demoProcessPath)),
Name = _demoProcessPath,
Content = ByteString.FromStream(File.OpenRead(_demoFormPath)),
Name = _demoFormPath,
}
}
};

// when
await ZeebeClient.NewDeployCommand()
.AddResourceFile(_demoProcessPath)
.AddResourceStream(File.OpenRead(_demoProcessPath), _demoProcessPath)
.AddResourceStream(File.OpenRead(_demoFormPath), _demoFormPath)
.Send();

// then
Expand Down Expand Up @@ -299,24 +300,36 @@ public async Task ShouldSendMultipleDeployResourceAndGetResponseAsExpected()
DmnDecisionRequirementsId = "id",
DmnDecisionRequirementsName = "nameRequirement"
}
},
new Deployment
{
Form = new FormMetadata
{
FormKey = 3,
Version = 1,
ResourceName = "form",
FormId = "demoForm",
TenantId = "formTenantId"
}
}
}
};

TestService.AddRequestHandler(typeof(DeployResourceRequest), request => expectedResponse);

// when
var fileContent = File.ReadAllText(_demoProcessPath);
var processFileContent = await File.ReadAllTextAsync(_demoProcessPath);
var deployProcessResponse = await ZeebeClient.NewDeployCommand()
.AddResourceFile(_demoProcessPath)
.AddResourceString(fileContent, Encoding.UTF8, _demoProcessPath)
.AddResourceString(processFileContent, Encoding.UTF8, _demoProcessPath)
.AddResourceFile(_demoFormPath)
.Send();

// then
Assert.AreEqual(1, deployProcessResponse.Key);
Assert.AreEqual(1, deployProcessResponse.Processes.Count);
Assert.AreEqual(1, deployProcessResponse.Decisions.Count);
Assert.AreEqual(1, deployProcessResponse.DecisionRequirements.Count);
Assert.AreEqual(1, deployProcessResponse.Forms.Count);

var processMetadata = deployProcessResponse.Processes[0];
Assert.AreEqual("process", processMetadata.BpmnProcessId);
Expand All @@ -338,6 +351,13 @@ public async Task ShouldSendMultipleDeployResourceAndGetResponseAsExpected()
Assert.AreEqual("requirement", decisionRequirementsMetadata.ResourceName);
Assert.AreEqual("nameRequirement", decisionRequirementsMetadata.DmnDecisionRequirementsName);
Assert.AreEqual("id", decisionRequirementsMetadata.DmnDecisionRequirementsId);

var formMetadata = deployProcessResponse.Forms[0];
Assert.AreEqual(3, formMetadata.FormKey);
Assert.AreEqual(1, formMetadata.Version);
Assert.AreEqual("form", formMetadata.ResourceName);
Assert.AreEqual("demoForm", formMetadata.FormId);
Assert.AreEqual("formTenantId", formMetadata.TenantId);
}

[Test]
Expand Down
23 changes: 23 additions & 0 deletions Client.UnitTests/Resources/demo-form.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"components": [
{
"label": "Demo checkbox",
"type": "checkbox",
"layout": {
"row": "Row_0b67lfv",
"columns": null
},
"id": "Field_18jrp23",
"key": "demoCheckbox"
}
],
"type": "default",
"id": "demoForm",
"executionPlatform": "Camunda Cloud",
"executionPlatformVersion": "8.4.0",
"exporter": {
"name": "Camunda Modeler",
"version": "5.19.0"
},
"schemaVersion": 14
}

0 comments on commit bdc563d

Please sign in to comment.