Skip to content

Commit 1e99cac

Browse files
committed
Remove Area
1 parent 3cf832b commit 1e99cac

32 files changed

+60
-1517
lines changed

backend/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ The access matrix looks like this:
269269

270270
| | **Read Only** | **User** | **Admin** |
271271
| -------------------------- | ------------- | -------- | --------- |
272-
| Area | Read | Read | CRUD |
273272
| InspectionArea | Read | Read | CRUD |
274273
| Plant | Read | Read | CRUD |
275274
| Installation | Read | Read | CRUD |

backend/api.test/Controllers/AreaControllerTests.cs

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

backend/api.test/Controllers/MissionSchedulingControllerTests.cs

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ await missionRunThreeResponse.Content.ReadFromJsonAsync<MissionRun>(
276276
Assert.Equal(missionRunOne!.MissionId, activeMissionRun.MissionId);
277277
Assert.Equal(missionRunTwo!.MissionId, activeMissionRun.MissionId);
278278
Assert.Equal(missionRunThree!.MissionId, activeMissionRun.MissionId);
279-
Assert.True(nextMissionRun.Id == missionRunTwo.Id);
279+
Assert.Equal(nextMissionRun.Id, missionRunTwo.Id);
280280
}
281281

282282
[Fact]
@@ -310,48 +310,6 @@ public async Task CheckThatMissionDoesNotStartIfRobotIsNotInSameInstallationAsMi
310310
Assert.Equal(HttpStatusCode.Conflict, response.StatusCode);
311311
}
312312

313-
[Fact]
314-
public async Task CheckThatMissionFailsIfRobotIsNotInSameInspectionAreaAsMission()
315-
{
316-
// Arrange
317-
var installation = await DatabaseUtilities.NewInstallation();
318-
var plant = await DatabaseUtilities.NewPlant(installation.InstallationCode);
319-
320-
var inspectionAreaOne = await DatabaseUtilities.NewInspectionArea(
321-
installation.InstallationCode,
322-
plant.PlantCode,
323-
"InspectionAreaOne"
324-
);
325-
326-
var inspectionAreaTwo = await DatabaseUtilities.NewInspectionArea(
327-
installation.InstallationCode,
328-
plant.PlantCode,
329-
"InspectionAreaTwo"
330-
);
331-
332-
var robot = await DatabaseUtilities.NewRobot(
333-
RobotStatus.Available,
334-
installation,
335-
inspectionAreaOne
336-
);
337-
338-
var query = CreateDefaultCustomMissionQuery(
339-
robot.Id,
340-
installation.InstallationCode,
341-
inspectionAreaTwo.Name
342-
);
343-
var content = new StringContent(
344-
JsonSerializer.Serialize(query),
345-
null,
346-
"application/json"
347-
);
348-
349-
// Act
350-
const string CustomMissionsUrl = "/missions/custom";
351-
var missionResponse = await Client.PostAsync(CustomMissionsUrl, content);
352-
Assert.Equal(HttpStatusCode.Conflict, missionResponse.StatusCode);
353-
}
354-
355313
private static CustomMissionQuery CreateDefaultCustomMissionQuery(
356314
string robotId,
357315
string installationCode,

backend/api.test/Controllers/RoleAccessTests.cs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -76,48 +76,5 @@ public async Task CheckThatRequestingPlantsWithUnauthorizedUserFails()
7676
Assert.False(samePlantResponse.IsSuccessStatusCode);
7777
Assert.Equal("NotFound", samePlantResponse.StatusCode.ToString());
7878
}
79-
80-
[Fact]
81-
public async Task CheckThatAnAuthorizedUserRoleCanAccessAreaEndpoint()
82-
{
83-
// Arrange
84-
var installation = await DatabaseUtilities.NewInstallation();
85-
var plant = await DatabaseUtilities.NewPlant(installation.InstallationCode);
86-
var inspectionArea = await DatabaseUtilities.NewInspectionArea(
87-
installation.InstallationCode,
88-
plant.PlantCode
89-
);
90-
var area = await DatabaseUtilities.NewArea(
91-
installation.InstallationCode,
92-
plant.PlantCode,
93-
inspectionArea.Name
94-
);
95-
96-
var accessRoleQuery = new CreateAccessRoleQuery
97-
{
98-
InstallationCode = installation.InstallationCode,
99-
RoleName = "User.TestRole",
100-
AccessLevel = RoleAccessLevel.USER,
101-
};
102-
var accessRoleContent = new StringContent(
103-
JsonSerializer.Serialize(accessRoleQuery),
104-
null,
105-
"application/json"
106-
);
107-
_ = await Client.PostAsync("/access-roles", accessRoleContent);
108-
109-
// Act
110-
// Restrict ourselves to RoleAccessLevel.USER
111-
HttpContextAccessor.SetHttpContextRoles(["User.TestRole"]);
112-
var response = await Client.GetAsync($"/areas/{area.Id}");
113-
114-
// Assert
115-
var areaFromResponse = await response.Content.ReadFromJsonAsync<AreaResponse>(
116-
SerializerOptions
117-
);
118-
119-
Assert.True(response.IsSuccessStatusCode);
120-
Assert.Equal(areaFromResponse!.Id, area.Id);
121-
}
12279
}
12380
}

backend/api.test/Database/DatabaseUtilities.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class DatabaseUtilities
1515
{
1616
private readonly AccessRoleService _accessRoleService;
1717
private readonly MissionTaskService _missionTaskService;
18-
private readonly AreaService _areaService;
1918
private readonly InspectionAreaService _inspectionAreaService;
2019
private readonly InstallationService _installationService;
2120
private readonly MissionRunService _missionRunService;
@@ -28,7 +27,6 @@ public class DatabaseUtilities
2827
private readonly string _testInstallationName = "Installation";
2928
private readonly string _testPlantCode = "PlantCode";
3029
private readonly string _testInspectionAreaName = "InspectionArea";
31-
private readonly string _testAreaName = "Area";
3230

3331
public DatabaseUtilities(FlotillaDbContext context)
3432
{
@@ -46,13 +44,6 @@ public DatabaseUtilities(FlotillaDbContext context)
4644
_accessRoleService,
4745
new MockSignalRService()
4846
);
49-
_areaService = new AreaService(
50-
context,
51-
_installationService,
52-
_plantService,
53-
_inspectionAreaService,
54-
_accessRoleService
55-
);
5647
_userInfoService = new UserInfoService(
5748
context,
5849
new HttpContextAccessor(),
@@ -165,26 +156,6 @@ public async Task<InspectionArea> NewInspectionArea(
165156
return await _inspectionAreaService.Create(createInspectionAreaQuery);
166157
}
167158

168-
public async Task<Area> NewArea(
169-
string installationCode,
170-
string plantCode,
171-
string inspectionAreaName,
172-
string areaName = ""
173-
)
174-
{
175-
if (string.IsNullOrEmpty(areaName))
176-
areaName = _testAreaName;
177-
var createAreaQuery = new CreateAreaQuery
178-
{
179-
InstallationCode = installationCode,
180-
PlantCode = plantCode,
181-
InspectionAreaName = inspectionAreaName,
182-
AreaName = areaName,
183-
};
184-
185-
return await _areaService.Create(createAreaQuery);
186-
}
187-
188159
public async Task<Robot> NewRobot(
189160
RobotStatus status,
190161
Installation installation,

0 commit comments

Comments
 (0)