Skip to content

Commit fe6fde7

Browse files
committed
WIP: refactor mission definition tasks
1 parent 4ab0772 commit fe6fde7

56 files changed

Lines changed: 556 additions & 2418 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/api.test/Controllers/InspectionAreaControllerTests.cs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Api.Services;
1111
using Api.Test.Database;
1212
using Microsoft.Extensions.DependencyInjection;
13+
using Org.BouncyCastle.Asn1.X509;
1314
using Testcontainers.PostgreSql;
1415
using Xunit;
1516

@@ -107,25 +108,21 @@ public async Task CheckThatMissionDefinitionIsCreatedInInspectionAreaWhenSchedul
107108
inspectionArea.Id
108109
);
109110

110-
var inspection = new CustomInspectionQuery
111-
{
112-
InspectionTarget = new Position(),
113-
InspectionType = InspectionType.Image,
114-
};
115-
var tasks = new List<CustomTaskQuery>
111+
var tasks = new List<TaskQuery>
116112
{
117113
new()
118114
{
119-
Inspection = inspection,
120115
TagId = "test",
121116
RobotPose = new Pose(),
122-
TaskOrder = 0,
117+
TargetPosition = new Position(),
118+
SensorType = SensorType.Image,
119+
AnalysisType = AnalysisType.Fencilla,
120+
Description = "Test description",
123121
},
124122
};
125-
var missionQuery = new CustomMissionQuery
123+
var missionQuery = new MissionQuery
126124
{
127125
RobotId = robot.Id,
128-
CreationTime = DateTime.UtcNow,
129126
InstallationCode = installation.InstallationCode,
130127
Name = "TestMission",
131128
Tasks = tasks,
@@ -246,25 +243,20 @@ public async Task ScheduleMissionOutsideInspectionAreaPolygonFails()
246243

247244
var robot = await DatabaseUtilities.NewRobot(RobotStatus.Available, installation);
248245

249-
var inspection = new CustomInspectionQuery
250-
{
251-
InspectionTarget = new Position(),
252-
InspectionType = InspectionType.Image,
253-
};
254-
var tasks = new List<CustomTaskQuery>
246+
var tasks = new List<TaskQuery>
255247
{
256248
new()
257249
{
258-
Inspection = inspection,
259250
TagId = "test",
251+
TargetPosition = new Position(),
252+
SensorType = SensorType.Image,
253+
AnalysisType = AnalysisType.Fencilla,
260254
RobotPose = new Pose(11, 11, 11, 0, 0, 0, 1), // Position outside polygon
261-
TaskOrder = 0,
262255
},
263256
};
264-
var missionQuery = new CustomMissionQuery
257+
var missionQuery = new MissionQuery
265258
{
266259
RobotId = robot.Id,
267-
CreationTime = DateTime.UtcNow,
268260
InstallationCode = installation.InstallationCode,
269261
Name = "TestMission",
270262
Tasks = tasks,

backend/api.test/Controllers/MissionDefinitionControllerTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public class MissionDefinitionControllerTests : IAsyncLifetime
2222
public required JsonSerializerOptions SerializerOptions;
2323

2424
public required IMissionDefinitionService MissionDefinitionService;
25-
public required ISourceService SourceService;
2625

2726
public async ValueTask InitializeAsync()
2827
{
@@ -40,7 +39,6 @@ public async ValueTask InitializeAsync()
4039

4140
MissionDefinitionService =
4241
serviceProvider.GetRequiredService<IMissionDefinitionService>();
43-
SourceService = serviceProvider.GetRequiredService<ISourceService>();
4442
}
4543

4644
public async ValueTask DisposeAsync()
@@ -60,11 +58,9 @@ public async Task CheckThatListAllMissionDefinitionsEndpointReturnsSuccess()
6058
plant.PlantCode
6159
);
6260

63-
var source = await SourceService.CreateSourceIfDoesNotExist([]);
64-
6561
var missionDefinition = new MissionDefinition
6662
{
67-
Source = source,
63+
Tasks = [],
6864
InstallationCode = installation.InstallationCode,
6965
Name = "Test Mission Definition",
7066
InspectionArea = inspectionArea,

backend/api.test/Controllers/MissionLoaderControllerTests.cs

Lines changed: 0 additions & 107 deletions
This file was deleted.

backend/api.test/Controllers/MissionSchedulingControllerTests.cs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public async Task ScheduleDuplicateCustomMissionDefinitions()
209209
inspectionArea.Id
210210
);
211211

212-
var query = CreateDefaultCustomMissionQuery(robot.Id, installation.InstallationCode);
212+
var query = CreateDefaultMissionQuery(robot.Id, installation.InstallationCode);
213213
var content = new StringContent(
214214
JsonSerializer.Serialize(query),
215215
null,
@@ -263,7 +263,7 @@ public async Task CheckThatNextRunIsCorrectlySelectedWhenSchedulingMultipleMissi
263263
inspectionArea.Id
264264
);
265265

266-
var query = CreateDefaultCustomMissionQuery(robot.Id, installation.InstallationCode);
266+
var query = CreateDefaultMissionQuery(robot.Id, installation.InstallationCode);
267267
var content = new StringContent(
268268
JsonSerializer.Serialize(query),
269269
null,
@@ -373,7 +373,7 @@ public async Task CheckThatMissionDoesNotStartIfRobotIsNotInSameInstallationAsMi
373373
inspectionArea.Id
374374
);
375375

376-
var query = CreateDefaultCustomMissionQuery(robot.Id, installation.InstallationCode);
376+
var query = CreateDefaultMissionQuery(robot.Id, installation.InstallationCode);
377377
var content = new StringContent(
378378
JsonSerializer.Serialize(query),
379379
null,
@@ -442,7 +442,7 @@ public async Task CheckThatMissionFailsIfRobotIsNotInSameInspectionAreaAsMission
442442
inspectionAreaRobot.Id
443443
);
444444

445-
var query = CreateDefaultCustomMissionQuery(robot.Id, installation.InstallationCode);
445+
var query = CreateDefaultMissionQuery(robot.Id, installation.InstallationCode);
446446
var content = new StringContent(
447447
JsonSerializer.Serialize(query),
448448
null,
@@ -459,39 +459,33 @@ public async Task CheckThatMissionFailsIfRobotIsNotInSameInspectionAreaAsMission
459459
Assert.Equal(HttpStatusCode.BadRequest, missionResponse.StatusCode);
460460
}
461461

462-
private static CustomMissionQuery CreateDefaultCustomMissionQuery(
462+
private static MissionQuery CreateDefaultMissionQuery(
463463
string robotId,
464464
string installationCode
465465
)
466466
{
467-
return new CustomMissionQuery
467+
return new MissionQuery
468468
{
469469
RobotId = robotId,
470470
InstallationCode = installationCode,
471-
CreationTime = DateTime.SpecifyKind(new DateTime(3050, 1, 1), DateTimeKind.Utc),
472-
InspectionFrequency = new TimeSpan(14, 0, 0, 0),
473471
Name = "TestMission",
474472
Tasks =
475473
[
476-
new CustomTaskQuery
474+
new TaskQuery
477475
{
478-
RobotPose = new Pose(),
479-
Inspection = new CustomInspectionQuery
480-
{
481-
InspectionTarget = new Position(),
482-
InspectionType = InspectionType.Image,
483-
},
484-
TaskOrder = 0,
476+
TagId = "test",
477+
TargetPosition = new Position(),
478+
SensorType = SensorType.Image,
479+
AnalysisType = AnalysisType.Fencilla,
480+
RobotPose = new Pose(11, 11, 11, 0, 0, 0, 1),
485481
},
486-
new CustomTaskQuery
482+
new TaskQuery
487483
{
488484
RobotPose = new Pose(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f),
489-
Inspection = new CustomInspectionQuery
490-
{
491-
InspectionTarget = new Position(),
492-
InspectionType = InspectionType.Image,
493-
},
494-
TaskOrder = 1,
485+
TagId = "test",
486+
TargetPosition = new Position(),
487+
SensorType = SensorType.Image,
488+
AnalysisType = AnalysisType.Fencilla,
495489
},
496490
],
497491
};

backend/api.test/Controllers/SourceControllerTests.cs

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)