-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a146799
commit 25ada23
Showing
5 changed files
with
165 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
...gner.Tests/Controllers/ProcessModelingController/UpsertProcessDefinitionAndNotifyTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Net.Mime; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
using System.Xml.Linq; | ||
using Altinn.Studio.Designer.Models.Dto; | ||
using Designer.Tests.Controllers.ApiTests; | ||
using Designer.Tests.Utils; | ||
using FluentAssertions; | ||
using Microsoft.AspNetCore.Mvc.Testing; | ||
using SharedResources.Tests; | ||
using Xunit; | ||
|
||
namespace Designer.Tests.Controllers.ProcessModelingController; | ||
|
||
public class UpsertProcessDefinitionAndNotifyTests : DisagnerEndpointsTestsBase<UpsertProcessDefinitionAndNotifyTests>, IClassFixture<WebApplicationFactory<Program>> | ||
{ | ||
private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/process-modelling/process-definition-latest"; | ||
|
||
public UpsertProcessDefinitionAndNotifyTests(WebApplicationFactory<Program> factory) : base(factory) | ||
{ | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(UpsertProcessDefinitionAndNotifyTestData))] | ||
public async Task UpsertProcessDefinition_ShouldReturnOk(string org, string app, string developer, string bpmnFilePath, ProcessDefinitionMetadata metadata) | ||
{ | ||
string targetRepository = TestDataHelper.GenerateTestRepoName(); | ||
await CopyRepositoryForTest(org, app, developer, targetRepository); | ||
string fileContent = SharedResourcesHelper.LoadTestDataAsString(bpmnFilePath); | ||
fileContent = metadata.TaskIdChanges.Aggregate(fileContent, (current, metadataTaskIdChange) => current.Replace(metadataTaskIdChange.OldId, metadataTaskIdChange.NewId)); | ||
var fileStream = GenerateStreamFromString(fileContent); | ||
|
||
string url = VersionPrefix(org, targetRepository); | ||
|
||
var form = new MultipartFormDataContent(); | ||
Check warning Code scanning / CodeQL Missing Dispose call on local IDisposable Warning test
Disposable 'MultipartFormDataContent' is created but not disposed.
|
||
string metadataString = JsonSerializer.Serialize(metadata, | ||
new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); | ||
form.Add(new StreamContent(fileStream), "content", "process.bpmn"); | ||
form.Add(new StringContent(metadataString, Encoding.UTF8, MediaTypeNames.Application.Json), "metadata"); | ||
|
||
using var response = await HttpClient.PostAsync(url, form); | ||
response.StatusCode.Should().Be(HttpStatusCode.OK); | ||
|
||
string savedFile = TestDataHelper.GetFileFromRepo(org, targetRepository, developer, "App/config/process/process.bpmn"); | ||
|
||
XDocument expectedXml = XDocument.Parse(fileContent); | ||
XDocument savedXml = XDocument.Parse(savedFile); | ||
XNode.DeepEquals(savedXml, expectedXml).Should().BeTrue(); | ||
} | ||
|
||
private static Stream GenerateStreamFromString(string s) | ||
{ | ||
var stream = new MemoryStream(); | ||
var writer = new StreamWriter(stream); | ||
Check warning Code scanning / CodeQL Missing Dispose call on local IDisposable Warning test
Disposable 'StreamWriter' is created but not disposed.
|
||
writer.Write(s); | ||
writer.Flush(); | ||
stream.Position = 0; | ||
return stream; | ||
} | ||
|
||
public static IEnumerable<object[]> UpsertProcessDefinitionAndNotifyTestData() | ||
{ | ||
yield return new object[] { "ttd", "empty-app", "testUser", "App/config/process/process.bpmn", | ||
new ProcessDefinitionMetadata | ||
{ | ||
TaskIdChanges = new List<TaskIdChange> { new() { OldId = "Task_1", NewId = "SomeNewId" } } | ||
} }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions id="Altinn_SingleDataTask_Process_Definition" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:altinn="http://altinn.no" | ||
xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" | ||
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" | ||
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" | ||
xmlns:di="http://www.omg.org/spec/DD/20100524/DI" targetNamespace="http://bpmn.io/schema/bpmn"> | ||
<bpmn:process id="SingleDataTask" isExecutable="false"> | ||
<bpmn:startEvent id="StartEvent_1" name="Start"> | ||
<bpmn:outgoing>To_Task_1</bpmn:outgoing> | ||
</bpmn:startEvent> | ||
<bpmn:task id="Task_1" name="Utfylling (message)" altinn:tasktype="data"> | ||
<bpmn:incoming>To_Task_1</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_2</bpmn:outgoing> | ||
</bpmn:task> | ||
<bpmn:task id="Task_2" name="Utfylling (changename)" altinn:tasktype="data"> | ||
<bpmn:incoming>To_Task_2</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_3</bpmn:outgoing> | ||
</bpmn:task> | ||
<bpmn:task id="Task_3" name="Utfylling (group)" altinn:tasktype="data"> | ||
<bpmn:incoming>To_Task_3</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_4</bpmn:outgoing> | ||
</bpmn:task> | ||
<bpmn:task id="Task_4" name="Utfylling (likert)" altinn:tasktype="data"> | ||
<bpmn:incoming>To_Task_4</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_5</bpmn:outgoing> | ||
</bpmn:task> | ||
<bpmn:task id="Task_5" name="Utfylling (datalist)" altinn:tasktype="data"> | ||
<bpmn:incoming>To_Task_5</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_6</bpmn:outgoing> | ||
</bpmn:task> | ||
<bpmn:task id="Task_6" name="Tilbakemelding" altinn:tasktype="confirmation"> | ||
<bpmn:incoming>To_Task_6</bpmn:incoming> | ||
<bpmn:outgoing>To_End</bpmn:outgoing> | ||
</bpmn:task> | ||
<bpmn:endEvent id="EndEvent_1" name="End"> | ||
<bpmn:incoming>To_End</bpmn:incoming> | ||
</bpmn:endEvent> | ||
<bpmn:sequenceFlow id="To_Task_1" sourceRef="StartEvent_1" targetRef="Task_1" /> | ||
<bpmn:sequenceFlow id="To_Task_2" sourceRef="Task_1" targetRef="Task_2" /> | ||
<bpmn:sequenceFlow id="To_Task_3" sourceRef="Task_2" targetRef="Task_3" /> | ||
<bpmn:sequenceFlow id="To_Task_4" sourceRef="Task_3" targetRef="Task_4" /> | ||
<bpmn:sequenceFlow id="To_Task_5" sourceRef="Task_4" targetRef="Task_5" /> | ||
<bpmn:sequenceFlow id="To_Task_6" sourceRef="Task_5" targetRef="Task_6" /> | ||
<bpmn:sequenceFlow id="To_End" sourceRef="Task_6" targetRef="EndEvent_1" /> | ||
</bpmn:process> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<bpmn:definitions id="Altinn_SingleDataTask_Process_Definition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:altinn="http://altinn.no/process" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" targetNamespace="http://bpmn.io/schema/bpmn"> | ||
<bpmn:process id="SingleDataTask" isExecutable="false"> | ||
<bpmn:startEvent id="StartEvent_1" name="Start"> | ||
<bpmn:outgoing>To_Task_1</bpmn:outgoing> | ||
</bpmn:startEvent> | ||
<bpmn:task id="Task_1" name="Utfylling (message)"> | ||
<bpmn:incoming>To_Task_1</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_2</bpmn:outgoing> | ||
<bpmn:extensionElements> | ||
<altinn:taskExtension> | ||
<altinn:taskType>data</altinn:taskType> | ||
</altinn:taskExtension> | ||
</bpmn:extensionElements> | ||
</bpmn:task> | ||
<bpmn:task id="Task_2" name="Utfylling (changename)"> | ||
<bpmn:incoming>To_Task_2</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_3</bpmn:outgoing> | ||
<bpmn:extensionElements> | ||
<altinn:taskExtension> | ||
<altinn:taskType>data</altinn:taskType> | ||
<altinn:actions> | ||
<altinn:action type="serverAction">fill</altinn:action> | ||
</altinn:actions> | ||
</altinn:taskExtension> | ||
</bpmn:extensionElements> | ||
</bpmn:task> | ||
<bpmn:task id="Task_3" name="Utfylling (group)"> | ||
<bpmn:incoming>To_Task_3</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_4</bpmn:outgoing> | ||
<bpmn:extensionElements> | ||
<altinn:taskExtension> | ||
<altinn:taskType>data</altinn:taskType> | ||
</altinn:taskExtension> | ||
</bpmn:extensionElements> | ||
</bpmn:task> | ||
<bpmn:task id="Task_4" name="Utfylling (likert)"> | ||
<bpmn:incoming>To_Task_4</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_5</bpmn:outgoing> | ||
<bpmn:extensionElements> | ||
<altinn:taskExtension> | ||
<altinn:taskType>data</altinn:taskType> | ||
</altinn:taskExtension> | ||
</bpmn:extensionElements> | ||
</bpmn:task> | ||
<bpmn:task id="Task_5" name="Utfylling (datalist)"> | ||
<bpmn:incoming>To_Task_5</bpmn:incoming> | ||
<bpmn:outgoing>To_Task_6</bpmn:outgoing> | ||
<bpmn:extensionElements> | ||
<altinn:taskExtension> | ||
<altinn:taskType>data</altinn:taskType> | ||
</altinn:taskExtension> | ||
</bpmn:extensionElements> | ||
</bpmn:task> | ||
<bpmn:task id="Task_6" name="Tilbakemelding"> | ||
<bpmn:incoming>To_Task_6</bpmn:incoming> | ||
<bpmn:outgoing>To_End</bpmn:outgoing> | ||
<bpmn:extensionElements> | ||
<altinn:taskExtension> | ||
<altinn:taskType>confirmation</altinn:taskType> | ||
<altinn:actions> | ||
<altinn:action>confirm</altinn:action> | ||
</altinn:actions> | ||
</altinn:taskExtension> | ||
</bpmn:extensionElements> | ||
</bpmn:task> | ||
<bpmn:endEvent id="EndEvent_1" name="End"> | ||
<bpmn:incoming>To_End</bpmn:incoming> | ||
</bpmn:endEvent> | ||
<bpmn:sequenceFlow id="To_Task_1" sourceRef="StartEvent_1" targetRef="Task_1" /> | ||
<bpmn:sequenceFlow id="To_Task_2" sourceRef="Task_1" targetRef="Task_2" /> | ||
<bpmn:sequenceFlow id="To_Task_3" sourceRef="Task_2" targetRef="Task_3" /> | ||
<bpmn:sequenceFlow id="To_Task_4" sourceRef="Task_3" targetRef="Task_4" /> | ||
<bpmn:sequenceFlow id="To_Task_5" sourceRef="Task_4" targetRef="Task_5" /> | ||
<bpmn:sequenceFlow id="To_Task_6" sourceRef="Task_5" targetRef="Task_6" /> | ||
<bpmn:sequenceFlow id="To_End" sourceRef="Task_6" targetRef="EndEvent_1" /> | ||
</bpmn:process> | ||
</bpmn:definitions> |